Although you can go a long way to increase the speed of your solution by tweaking and tuning your code and database schemata, there is a physical limit that can only be overcome by upgrading the hardware that runs your code. Fortunately this is a little less trial-and-error than code tweaking, which means I am able to give you this list of ideas to get you started:
Having a multi-core machine makes an enormous difference, and there's no reason not to have at least two cores on your site unless you're making something extremely small.
I have seen no evidence to show that expensive chips incorporating SSE3, Hyperthreading, or even AMD64 extensions provide any meaningful benefit for Apache web servers. There are some benefits to be gained in using 64-bit chips for your MySQL server, though.
The amount of RAM you have depends on how much you use your database and how much you want to put in memcache, but you're looking at 1GB as a minimum for virtual servers and 8GB to 16GB for dedicated servers.
Hard disks are not all that important in high-performance web sites, as most of the data is stored in RAM. However, if you must load from disk, you might find that SSDs are cheap enough to suit your need – and they are substantially faster than hard disks.
When you network, Gigabit Ethernet is essential, preferably with each machine connected directly to a switch. Good switches come with an extra port for an intrusion detection computer to monitor the flow of traffic, which is essential for truly secure operation.
Using a round robin DNS system is a simple load-balancing system. When a request for example.com comes in, it is randomly sent to one of your farm of web servers. Be careful with sessions, however: if you aren't using databases for session data, it will be stored on the server and therefore lost if the user is transferred to another machine.
Blade servers are a cheap and efficient solution for web server systems, but not for SQL servers. The issue is that although they invariably come with a lot of processing power, their storage options are equally invariably poor.
If you are able, set up one machine as a reverse proxy for your site. Reverse proxies essentially store a static cache of your site, refreshing when appropriate. This allows you to keep the load off your dynamic servers, which is ideal for extremely popular sites.
Don't be afraid to split your site across multiple servers based on use. By that I mean you can easily have one server handling HTTP, one handling database stuff, and one handling memcache – it's easy to set up and easy to maintain, so it's a good start for scaling.
If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!
Next chapter: PHP Accelerators >>
Previous chapter: Know MySQL's strengths
Home: Table of Contents
Copyright ©2015 Paul Hudson. Follow me: @twostraws.