beecherbowers.com

of all the places on the internet, you ended up here.

optimize for heavy traffic

No Comments »

One of my sites got linked from a pretty popular website on Friday afternoon. Unfortunately, some of the code in one of my main files wasn’t at all optimized for heavy site traffic. The result? The host suspended access to the file to prevent it from draining the server resources.

On Friday, LifeHacker added a link in one of their articles to DesktopGaming.com . From that one link, over 45k pageviews came pouring in, in one day. One of the primary pages on the site used php’s getimagesize function that can read an image and return the height/width. It is also pretty cpu intensive when getting hit hundreds of times an hour.

The function was called to dynamically size a page div to match the size of the image displayed. I’ve started a workaround for it that adds these dimensions to the file’s properties in the database so that the query getting the image info will return these values as well. The mysql overhead is much lighter than that of getimagesize. Hopefully, this will keep the site live next time a rush occurs.

I’m pretty pleased with my host through all of it, they didn’t drop access to the entire site to fix the issue, they just stopped access for the one offending file. I even got a call from their tech support letting me know what was going on and what steps they were taking to resolve the load.

Leave a Reply