How can I study the server load/impact impact of my PHP scripts in a shared hosting environment?
October 13, 2008 9:35 AM   Subscribe

How can I study the server load/impact of my PHP scripts in a shared hosting environment?

The hosting company isn't very helpful. I want to be proactive and not wait for a call that my scripts are causing trouble. Also want a website that isn't slow and unresponsive. The server is Apache2 w/PHP5

I'd like to learn in general terms about it but the specific case I have is as follows:

I'm building a website that does a lot of thumbnailing using phpthumb(). I send an AJAX request to the server to generate thumbnails and return a list of SRC tags. This puts a certain load to the server. phpthumb() caches the thumbnail so the load happens only once

I want to also have PHP look up and return the dimensions of the original image using getImageSize. This is additional load and caching wouldn't happen. If I do the lookup 100 times/second would it overwhelm the server?

Is it something I should be concerned about? I have no idea about how my scripts might affect the server. The site gets about 15k hits per day and is growing.

posted by jorlando to Computers & Internet (3 answers total) 1 user marked this as a favorite
Your best bet is to emulate your server environment as closely as you can, on a spare PC if possible, virtual machine if necessary- but that will skew your results. Then run a load testing tool like Apache JMeter or apache bench against your scripts. JMeter is pretty elaborate, but much more complex to set up.

While running, you'll be interested in monitoring CPU Utilization and RAM utilization. You will be unable to certify that your system will meet any particular performance level (there's too much variability between whatever your hardware is and what they are running in production, not to mention whatever random scripts are running on that box), but you can identify things that take too long and verify that your caching, etc is working as desired.
posted by jenkinsEar at 10:04 AM on October 13, 2008

If you're caching as much as possible (if the image info is coming from a database, could you cache the dimensions in there too so they're retrieved along with the info?), then really it's just a matter of waiting until your site is popular enough for the hosting firm to grumble. I'm not sure having measurements is particularly helpful in predicting this, so you might be better off spending the time assessing next-step-up hosting packages to be ready to move when necessary.
posted by malevolent at 10:49 AM on October 13, 2008

2nd benchmarking it somewhere else. Primarily because when you're with a shared host there are too many other variables to take into account. What if someone else is load testing at the same time? Or someone is running a giant chron, or someone else has a runaway script? If you load test fine today, but three other sites on the same server become popular before yours does, yours might be the straw that broke the camel's back.

It's pretty trivial any more to set up a L/WAMP server locally and see how it performs.

Of course from that benchmarking you won't be able to tell at what load limit your hosting provider will get ticked off. If it's like all of the hosts I've used, they'll probably only notice when someone else on the box complains.

Plan to move when things pick up, and be able to do it in a hurry. Make sure your code and data is easily portable.
posted by Ookseer at 11:59 AM on October 13, 2008

« Older Add leaves and fruit, but don't cut the branches   |   Stopz yer b3lly4ch1ng Newer »
This thread is closed to new comments.