Linux – Scaling architecture: separate Apache and MySQL servers, or keep them together and add resource/nodes

apache-2.2linuxMySQL

Will likely be serving multiple independent WordPress websites and am trying to determine the best general approach. At present I'm looking at two VPS, one with Apache/PHP/FastCGI and another running MySQL with a private interface between the two. This allows me to tune and scale the web server and database server independently, if necessary. On the other hand, it introduces some additional complexity, requires a heavier MySQL process, creates more chance of bottlenecking at the database, and probably exposes more attack surface-area.

The other approach is to put all services on one, larger VPS, and simply add resources or additional self-contained nodes as necessary.

Does anyone have specific experiences with the pros and cons of both approaches? Additional suggestions? Recommended resources?

Best Answer

In terms of scaling, it's always best practice to separate roles from each other, for both security and performance perspectives. Separate Web and DB layers are usually the first thing one does to scale. This is done so each host can be tuned specifically for the workload it performs.

One other thing to consider, when roles are separated to different hosts, the OS caches will be filled with more relevant data than if the two roles were combined. Since I/O is almost always the bottleneck in any web architecture, any time you can take advantage of extra caching is a plus.

Related Topic