So you may have noticed that for a while on Sunday, the websites were down.
My account was suspended because I had been tying up the mysql server from one site. My guess is that because all the traffic from bikemart.thesaweb.co.za and automart.thesaweb.co.za was going into one url www.sellstuff.co.za that the code that was working fine on 3 seperate sites now looked to be way too resource intensive.
So I spent a good part of Sunday optimising my code to minimise the calls to the database, which is a good thing because now all the pages on the site load much quicker. I am going to go one better than that by actually caching the ads title and so on.
Currently for each page I get a list of which ads should display then loop through each of those ads, each time selecting that ad from the database to build the title, then one by one I build the lines on the page.
What I am going to try and do now is to generate a small text file the first time that the ad is needed in a list, then every time the ad comes up to be displayed on the page I will simply open that file which contains the url string, ad title and the path to the ads thumbnail (if it has an image).
This will lessen the load on the database as well as speeding up the page (because opening a file is quicker than making a call to a database).
If the user edits thier ad then I will simply delete that cache file and it will be re-generated again when the ad is displayed.
Hope this helps to improve your experience when visiting www.sellstuff.co.za
Posted under Classifeds Sites Updates
This post was written by Shaun on January 26, 2009
