Realtime? So you couldn't cache your results for say 30 minutes at a time? Between 4 different feeds and all being displayed at once, that's gotta be a relative eternity for the user to wait. Why not use optcode caching to store data serverside? Depending on usage, even a 5-minute cache might save a lot of time and bandwidth.
APC (Alternative PHP Cache) isn't too hard to setup. It does require access to pecl/pear from command line as well as build tools. Might not be available to you if this is paid shared hosting account. If so you might wanna look for it under a phpinfo() or ask your administrator about it. If it's your server, check out installation instructions here.
Your code might look something like this...
<?php
function get_feeds()
{
if ( apc_fetch('feeds') ) {
return apc_fetch('feeds');
} else { //when cache time is used up, apc_fetch returns false
// gets feeds via typical method
//...
//cache data...
apc_store('feeds', $feed_data, 300); //5 minutes
return $feed_data;
}
}
?>
I suggest doing as leatherback suggested: Buffer a certain amount of printed lines and then spit them out. I guess this is the answer to your very first question...
<?php
// turn on output buffering
ob_start();
// loop results
foreach ($results as $result) {
// print out results
echo $result;
// every 30 records, flush the output buffer.
if ( ++$counter % 30 == 0 )
ob_flush();
}
// flush anything that is left over.
ob_end_flush();
?>