Most efficient setup for Wordpress

June 7, 2017 2.4k views
Control Panels Ubuntu 16.04

I'm trying to build an efficient setup right off the bat and migrate a lot of client sites over to DO. Does anyone have a good idea of how to set up a sustainable efficient ecosystem of droplets for multiple WordPress sites where the files are on one server, database on another, etc. for "medium" sized site load? I'm assuming if I want to use a control panel and other apps I should probably use a different server for them as well right?

I know as an open ended question it could go infinitely more efficient but let's say 1-5 sites is one droplet with everything on that server, what about 10-20 sites with ~2000 pageviews/month?

3 Answers
hansen June 8, 2017
Accepted Answer

@tannerchung Just starting a new thread, because it was getting very narrow.

Yes, that's a good, sustainable solution to use Block Storage - and if you follow the question thread you've linked to (which I also answered) - then you can always move to other solutions in the future, if that would ever be needed.
Just remember that Block Storage isn't available in every data center yet, so when you choose data center for your droplet, it has to be FRA1, NYC1, SFO2 or SGP1.

  • To start with, create a single $5 droplet.
  • After it's created, you can resize to $10 or $20, but without resizing the storage, so you can downscale again.
  • Do not expect to be able to run WordPress on $5 - it needs minimum $10 (if you run everything on a single droplet) - and the more plugins, themes and/or multiple sites, the more expensive you need to go.
  • Do not use Apache - just run with Nginx, it's faster and instead of two services, there would only be one.
  • When you feel you're ready for more servers, just setup a new droplet, dump the entire database and copy it over to the new droplet (and setup logins/security), and then you just change your WordPress configuration wp-config.php to use the database on the new droplet. And finally you remove and uninstall the database from the original droplet.
  • When you need more space for media/files, then you would setup Block Storage by following the question you've already linked to. Just a note, I created that guide for a single WordPress site, so it need to be changed a bit to accommodate multiple sites.
  • And from there, you can expand by adding load balancer, cache, or other server types.

You can get pretty far by following this tutorial (it's for a single server setup):
https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lemp-on-ubuntu-16-04

WordPress is the most popular CMS (content management system) on the internet. It allows you to easily set up flexible blogs and websites on top of a MySQL backend with PHP processing. WordPress has seen incredible adoption and is a great choice for getting a website up and...
  • I'm so impressed by how awesome DO's forums are and how helpful so thank you for all the information you're giving me.

    I currently use VV on my local for dev and it uses nginx. I ran into issues with it because I'm unfamiliar with nginx and not sure how to deal with items that use .htaccess and I realized a lot of plugins rewrite .htaccess. Any advice on that?

    This article shows how to use just 512MB - http://ryanfrankel.com/run-wordpress-digital-ocean-512mb-vps/, do you see any flaws with that?

    And can a service like Cloudflare replace the need for Varnish/reverse nginx proxy?

    • @tannerchung
      That's great you feel that - we're only able to help because DO has created a really good, solid platform, so credit where credit is due :-)

      Good article - doesn't go into a lot of details, but he seems to be pretty knowledgeable, which might mean that he doesn't run a lot of plugins and has a very small theme.
      On top of that, he caches almost everything, so almost no-one actually hits WordPress (Apache, PHP and MySQL) - they just get a static page served by Varnish.

      But there's one place where he's "cheating" - and that's swap. He has 511MB swap available, meaning when he runs out of RAM, the system will offload to the swap on disk and then be able to load more data into RAM. So he kinda have 1GB RAM.
      Swap is slow and on DigitalOcean it's a very bad practice, but in general, when you're using your swap, it means you have too little RAM.
      Read the warning here: https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-16-04

      It's possible for me to setup an extremely tuned server that can serve WordPress on 512MB, but I get into problems sometimes when there's security updates - or if you're using certbot to get Let's Encrypt certificates.
      Then the server runs out of RAM and either the update-process fails or it crashes MySQL, since that's the biggest consumer of RAM.

      I've been running other systems I've built, where I know all the code I'm running and I've created every database query. These systems can easily run on 512MB (with 200MB to spare) and handle 8-10 connections per second and almost 100 database queries per second. And that's with millions of records in the database.

      One of the easiest way of increasing the responsiveness of your server and guarding against out of memory errors in your applications is to add some swap space. In this guide, we will cover how to add a swap file to an Ubuntu 16.04 server. <$>[warning] [label...
      • Thanks for the tip on certbot! I'll have to read up on it more

        Do you have any info about the whole htaccess thing and nginx, I can even look it up if there's a name for that situation. I just wasn't sure what to google.

        And did you have any thoughts about using Cloudflare?

@tannerchung

Sorry, forgot about the .htaccess and CloudFlare.

I've only seen a couple of plugins, which requires .htaccess (or manual changes to configuration).
Most of the plugins lists the exact configuration changes needed for Nginx in the documentation or on their website.
If not, just tell me which plugins you're having problems with.

CloudFlare can never fully replace Nginx cache or Varnish, since they do something you control and can make very specific to your needs. But if you just use simple full page cache, then CloudFlare is probably a good choice.
But then again, CloudFlare offers a lot more than just cache, so it's a very simple, easy way to add some security, cache and CDN offloading to your site.

Have another answer? Share your knowledge.