The simplest web hosting configuration is to throw everyting on one machine (or virtual machine), install CPANEL and hand it over to your unsuspecting customer. Countless hosting companies operate this way, and the purpose of this article is to discuss why that may not be the best idea for your hosting needs.
The Moving Parts
For most non-trivial websites, there are several moving parts involved. For example, a typical WordPress website will have 3 parts.
- First, a web server that serves up the static content. Static content refers to stylesheets, javascript, logos, images and other assets that are not stored in the database.
- The second part is the application server, running PHP to retrieve dynamic content from the database and merge it to form the web pages or blog posts that are shown to the user.
- Finally, there is the database server which handles storage and retrieval of dynamic content and configuration for the site.
Shared Resources
Each of these parts requires different resources on the host computer (CPU, Memory and Disk I/O). Keep in mind that all 3 of these components are competing for the resources of a single machine in a single-server deployment. Any single machine has a shared CPU, a fixed amount of memory and a single I/O channel to read and write to the hard drive(s). Multiple-core processors, multiple hard drives and very large RAM configurations are sometimes sufficient solutions, but they are far from efficient.
Specialization – Why More is Usually Better
To create an efficient, high-performance deployment, a certain amount of specialization is in order. Database servers require a very different resource profile than application servers, and static web servers are quite different from either.
The Web Server
Web servers are the least demanding of the 3 components, but they do have their own special considerations. A web server's job is to locate files on disk and stream them back to the user. Typically, though, these are relatively large files such as images or video. It is important to have high-performance disks in your web server to optimize finding the file and reading it quickly.
Another very important concern for the web server is proximity to the end user. Most of the time, the slowest part of loading a page is retrieving these large, staic image files from the web server over the network. By separating your static content on to a web server (instead of the application server), you can take advantage of a Content Distribution Network (CDN). A CDN effectively "copies" your web server content on to servers that are strategically located around the world to bring your content closer to the end user. This can result in much faster page load times for your users.
The Application Server
Application servers require a ton of CPU. The job of the application server is to execute code that assembles data from the database with configuration and other assets to render a web page. A single request can result in tens of millions of CPU instructions. Faster CPUs with more cores and large on-chip cache is everything when it comes to application server performance. Fast hard drives on an application server make little to no difference when it comes to this type of performance.
In addition to large CPU requirements for application servers, there needs to be abundant free memory available. Each web request normally allocates a rather large chunk of physical memory (sometimes 50MB or more) to do the necessary calculations and store intermediate results. The application server needs to be properly tuned so as not to overrun the available physical memory by trying to service too many requests at one time. Tuning the application server can be very challenging when you don't know how much physical memory will be available at any given time.
The Database Server
Database servers typically benefit from very fast hard drives and a lot of memory (RAM). Database engines can be configured to "cache" frequently accessed data in memory for lightning-fast data retrieval. When they do need to read or write to disk, fast drives with fast connections (SCSI, SAS) make a huge difference in the overall performance. If your database is not tuned to make optimal use of the hardware it is on, you are missiong out on large performance improvements.
Another consideration that drives people to consider a separate database server is security. A well-desinged database server is not accessible from the public internet. The database server is only accessible from a private network that includes the application server. This type of network configuration is required for PCI compliance if you take credit cards on your web site.
Efficient Complexity
While this might all seem a little overwhelming and potentially costly, these are the facts you will need to deal with if your website gets signifcant traffic. Good hosting providers have made it relatively easy to assemble a high-performance, multi-server deployment at a reasonable cost. Often times we have found that by splitting web deployments into these components can result in a cost savings over a single-server solution. Many customers will find that as their website grows and gets more traffic that they need to move to larger and larger servers to accomodate the load. Split deployments help to identify and allocate resources where they are needed, rather than just moving everything to a bigger server. This can often result in small, incremental upgrades to one of the servers in the system, saving money over the short and long term.
For website owners with significant traffic that may be facing performance issues, we highly recommend considering the points raised here. Design a deployment that matches your needs and you may find yourself with a more stable, faster and less expensive solution overall.
Speak Your Mind
You must be logged in to post a comment.