Jump to content

Recommended Posts

I am trying to optimize a high traffic website, and I enabled a feature where there are three photos selected from the most recently submitted ones, and displayed at the top of the page. I figured that if each person is asking for 3 photos every time the page loads, this will put strain on server load. My solution involves having a script generate an xml file of the 30 most recent photos every half hour, and then cycle through the xml on the actual page. Is this a better solution than making a db call, in terms of speed gained/efficiency? I dont have much experience with XML so I wouldn't know how fast parsing it in PHP would be compared to a database call.

Link to comment
https://forums.phpfreaks.com/topic/178235-solved-reading-xml-faster-than-db-call/
Share on other sites

I haven't actually run a test, I think it would depend on the XML format, but in general I think the XML should be faster because it doesn't involve communication between PHP and the DB.

 

However, I generally try to tell myself "keep it simple stupid" when it comes to programming. Why use XML when you could just as easily create a txt file with a list of image URLs separated by a spacer? You could explode the string into an array and choose a random index in the array. Would probably be much faster than parsing an XML file (once again, haven't tested to confirm).

XML is primarily designed to transport data between dissimilar applications.

 

Within a single application, where you are both producing and consuming the data using the same programing language on each side, using XML is just adding unnecessary overhead. So, if your primary goal is performance, don't use XML.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.