What's the the best way to host lots of blogs?

March 23, 2017 222 views
PHP MySQL Ubuntu

I need to host 50+ wordpress blogs.
Currently, I have 10 droplets, some is 6 * $10/mo, some is 4 * $20/mo. ($140 / mo)
Each droplets have apache + php + mysql server.

Sometimes my database will crash due to resource issue.

I am considering to use one high performance droplet to host database and others only apache.

Any suggestion for me? How do I arrange the budget?

For example:
1 * $80/mo for MySQL
6 * $10/mo for apache+wordpress+php


1 Answer


I'm slightly biased since I work with it the most, though when it comes to hosting multiple WordPress sites, I recommend NGINX over Apache.

The most common module to use with Apache is mod_php, which can be slightly resource intensive in various traffic scenarios (even low traffic, and especially on low RAM VPS's). With NGINX, you'd be working with php-fpm, which is what NGINX passes requests over to.

I find that it's far easier to work with and tune for specific needs, whereas mod_php is lacking in that area. Most configuration and/or optimization needs to be done with Apache alone.

Combine that with the fact that rewrites with NGINX are far easier to manage. I recently posted this in another community post, though it's a prime example. Take for instance the default .htaccess file for WordPress:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

It's not overly confusing by any means, but with NGINX, it's simplified. NGINX achieves the same thing with just:

    location /
        try_files $uri $uri/ /index.php?$args;

The PHP location block handles the rest for you and would look something like:

    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        fastcgi_index index.php;
        include /etc/nginx/config/php/fastcgi_params;

Going back to resource usage, Apache may very well be what's eating in to your RAM. While MySQL does normally occupy between 500MB and 1GB on most small configurations, Apache can eat up as much with just 2-3+ processes.


That being said, there's a few recommendations I could make that would surely help drive you in the right direction, though ultimately, what I'd recommend would depend on what type of blogs you are running, what plugins they rely on, and what their traffic levels are / are expected to be.

One cluster that I setup for a client recently was an NGINX proxy setup which featured a single server in front of multiple backend servers -- each backend server hosted numerous sites, though the single server in front was the entry point that proxied the requests to the correct server. This allows for SSL termination at the proxy instead of having to rely on it on each and every backend server.

For example, if we used six Droplets, we'd setup one as the proxy and five as the actual web servers used for hosting. Domains would be pointed to the proxy and the proxy would route them to the correct server.

It'd look something like:

-- proxy.domain.com
-- -- web01.domain.com
-- -- web02.domain.com
-- -- web03.domain.com
-- -- web04.domain.com
-- -- web05.domain.com

When a request is received on the proxy, it checks the currently NGINX server blocks for a match and if found, proxies the request to the defined backend server.

Each of the backend servers would then connect to your database server to pull database content and data. You'd be using NGINX on all 6 of the servers (but of course, not on the database server).

It sounds complex, but it's actually a very very simple setup and I can easily show you how to get it up and running if interested.

Have another answer? Share your knowledge.