Forum Moderators: open

Message Too Old, No Replies

Speeding up a heavily database driven home page

         

ntbgl

8:47 pm on Feb 7, 2009 (gmt 0)

10+ Year Member



Hello,

I have my front page on my site heavily using database driven content. I would like to speed up this page as well as to reduce strain on my server.

What is the best way to do this?

Right now, I have a crontab execute every five minutes a PHP script that generates queries from my MySQL database all the content for the homepage, and to write the index page as a static file.

Is there a better way? Would executing a PERL script be more efficient? What about implementing some kind of caching feature on the page itself, or maybe MySQL has a built in way of handling this?

If there's a better way of accomplishing my goal I would love to here it, or if what I'm doing is sensible, I'd love to get confirmation. Thanks!

mack

8:49 pm on Feb 7, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I think you have taken the correct approach by using a cron to write the homepage. If you where to keep the page totaly dynamic the server load could indeed be very high.

Mack.

brotherhood of LAN

9:31 pm on Feb 7, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I assume the strain is caused by more than one query?

You might want to single out the biggest culprits and do an EXPLAIN on your query, and see if there are ways to optimise your query.

ntbgl

9:33 pm on Feb 7, 2009 (gmt 0)

10+ Year Member



Thank you Mack much for confirming my approach. I was concerned because I had to use a work around to get my PHP script to work with cron, it seems to prefer PERL.

I don't have any experience with PERL so I was fearing I was getting comparativly sluggish returns with my PHP script.

LAN, yes I am using multiple queries, some are taking more time than others. I've never worked with EXPAIN, but I am always looking to make pages as fast as I can make them. I'll definitly have to look more into this.

Thank you both.

belfasttim

6:08 pm on Feb 10, 2009 (gmt 0)

10+ Year Member



this is probably obvious but also make sure caching is enabled and has enough memory to use, on both the php and the mysql side.

VarX

6:29 am on Feb 20, 2009 (gmt 0)

10+ Year Member



Well i have my own class written for caching purposes so i could cache my queries and retrieve them faster when needed (flat file caching) it cut down the database resource usage as well as time consumption.