Search code examples
phpperformancerssfeed

Multiple RSS feeds with PHP (performance)


In my recently project i work with multiple rss feeds. I want to list only the latest post from all of them, and sort them by timestamps.

My issue is that i have about 20 different feeds and the page take 6 seconds to load (only testing with 10 feeds).

What can i do to make it perfrom better?

I use simplexml:

simplexml_load_file($url);

Which i append to an array:

function appendToArray($key, $value){
$this->array[$key] = $value;
}

Just before showing it i make krsort:

krsort($this->array);

Should i cache it somehow?


Solution

  • Have you done any debugging? Logging microtime at various points in your code.

    You'll find that it's the loading of the RSS feed, rather than parsing it, that takes the time but you might find that this is due to the time each RSS feed takes to generate.

    Save those ten feeds as static xml files, point your script at them and see how fast it takes to load.