It is common to have a single LAMP-based website on a cloud server so the database and web server are on the same “container”. With the advent of database-as-a-service, some of the web hosts are already offering MySQL, PostgreSQL database servers as separate instances. The question is, to run a WordPress installation, is it practical to have MySQL database on a different server? What are the advantages of having this kind of setup?
If your website or application does face a huge load, then you can quite easily run your site with an Apache web server and database on the same machine. It is just not the easiest step in scaling but also easier to maintain. If your website or application does have a huge load, then you can continue to read the rest of this article.
A WordPress site with 50K hits per month running these two components on separate servers will have a slightly longer page loading time than while running Apache and MySQL on a single server. This is because the number of queries per second is too low and can be easily handled by virtually any quality of hardware! Two server setup does decrease the page loading time, but only when the number of queries per second is enough high to put stress on the machine. Proper caching on the disc is sufficient for a WordPress site with 50K hits per month.
---
Advantages of Running Apache Web server and MySQL Database on Separate Cloud Servers
Webservers have different hardware requirements than the hardware requirements of MySQL database servers. Database servers require a lot of memory and a faster disk. While Apache web servers require enough memory to cache files. When we need a higher magnitude of resources (24GB of RAM or more) then it is safer to separate them.
Security is a big concern. Technically, it is correct for your database server to be sitting behind a firewall with only a few ports opened to perform data access by another server. When you lose the control of Apache web server as a result of a devastating hacking attempt, your application’s database may be compromised but not the database server. It will not take a lot of time to spin another web server from the backup and make the site online. Working with MySQL takes a lot of time since most of us are not database experts.
Most of the common databases tend to reserve up all the available memory and hold it for use when it wants to use it. This can considerably slow data access. When you separate Apache and MySQL, this problem does not arise.
Conclusion
Separating MySQL server from Apache web server decreases the security risk on a setup. However, for a small to a medium website, often the budget is limited and also the manpower working on a server is less. Hence, for small to medium sites, the strategy to separate MySQL server from the Apache web server is optional.
As for scalability, it is easy to add web servers into a cluster to handle increased traffic.