This is the fourth blog of "Staying 2 Steps Ahead of the Performance of Your Magento Site," a series of five entries from Hostway partner Cynch, an expert on optimization and a leading migration and IT management agency.
As we discussed in our previous article in this blog series, there comes a time when you realize you’re stretching the limits of your web server. The first move to remediate that is to make sure your code, server and services are tuned to perfection, as discussed in earlier posts. If you’ve already been down that road, you can try to improve things by growing vertically – adding more RAM, CPU, or faster disks to your existing server. While that may be your silver bullet, be prepared to deal with the possibility that your website is so awesome that you need to consider adding another server and giving each of them their own roles: web and database.
When all the services needed to run your website are on a single server, you have to be nice to all the kids in class – no preferential treatment, no giving one service more system resources than another. By shifting to a role-based distributed deployment pattern, you not only give each server room to breathe; you also allow them to run services that focus on doing what they’ve been configured and tuned to do best.
For web servers, give more attention to caching, pre-spawning threads, and TCP socket tuning. Since you’ll likely have some extra memory lying around from not having to allocate it to your DB, you can now easily add things like memcache and Varnish, reducing the chatter to your database engine. Reducing the amount of time it takes to establish a connection to the web server will reduce page load times, so its good practice to chew up available file handles by pre-spawning additional web threads (aka workers, helpers, children), so that you have more worker bees waiting around to satisfy bursts of traffic. Lastly, a web server communicates with a lot of remote clients in very short bursts. If the TCP stack on the web server isn’t adjusted, it will likely become overwhelmed as your traffic increases and confuse your developers, system administrators and hosting company with the extra server load.
Database servers have similar needs as web servers, but, of course, we give them different kinds of treats to make them happy. As mentioned in the entry “Default Databases Slow Down Magento Sites,” MySQL loves memory, so don’t force the service become a drama queen – give it as much as you can. Database servers always cause a ton of disk thrashing (the correct technical term is I/O); this is especially the case when you’re short on memory that you can feed MySQL. The magic sauce for this problem is to make sure your DB server has solid-state drives (SSD). While they are more expensive than the alternatives, most Magento databases aren’t huge so you don’t need to “go big.”
So, what are you waiting for? Start conversations with your hosting provider to get the additional server added, as well as a migration and optimization partner, to assist you with moving the database and tuning everything so it runs like a top!
How are we doing so far? Let us know what you think about our blog series below, or shoot us an email at email@example.com.