Skip to content

93 Comments

  1. Luigi
    January 9, 2018 @ 9:54 pm

    This kind of balancing can be easily done with Google Cloud. Very easy to orchestrate.

    Reply

    • Anon
      January 9, 2018 @ 11:08 pm

      Do you have a link to an article covering the setup on Google Cloud? I’m always interested in any performance solutions for WordPress.

      Reply

    • Michael
      January 10, 2018 @ 3:40 pm

      Thanks for the post – and i am interested in the google as well.

      Reply

  2. Tomas R.
    January 10, 2018 @ 8:30 am

    Great article, I will try to set up, I am also interested how to make it on Google Cloud

    Reply

  3. andrew
    January 11, 2018 @ 12:59 am

    Reply

    • Anon
      January 11, 2018 @ 6:03 am

      I used to use the debops stuff quite a bit – it’s good, but there were bugs around the letsencrypt ssl and the varnish config, and I never made use of updating configs remotely using that system. There was sooo much custom config in their playbooks for me to go through (a lot of it good, but some it was causing problems and was difficult to trace) that I prefer to do it all from scratch so I have the latest code and no extra bumf, and I know exactly what is on there.

      The digital ocean scalable wordpress link you sent – they only have 1 database. I do like their use of glusterfs though, and this could be implemented in the cluster I’ve described above if you wish – it would replace the need for unison to replicate the files. Note that glusterfs would mean you’d need more servers – e.g. 1 load balancer, 3 nodes with db+web, then 3 nodes for your glusterfs. You could theoretically install it on these 3 nodes themselves. BUT, the thing I like about my cluster is that any individual node has all the info it needs to run your entire site. Here’s a guide to installing glusterfs – https://www.cyberciti.biz/faq/howto-glusterfs-replicated-high-availability-storage-volume-on-ubuntu-linux/ I’ll get a site with glusterfs up and running and get some measurements done soon.

      The Rancher/Docker link looks interesting, but the thing I don’t like about playbooks is that it gives you something else that you need to keep up to date. For example, that Rancher link is using playbooks that install PHP 5. The Nginx config is not great either. I do like docker though, and thanks for the links – it’s given me more stuff to investigate!

      Reply

  4. Prabhu Ganesh
    January 11, 2018 @ 6:54 am

    hi
    This is prabhu. i’m a web developer and i work with wordpress. this article about setting up a wordpress cluster for huge sites is really a useful information for everyone. Thanku so much

    Reply

  5. Michel J.
    January 14, 2018 @ 2:05 pm

    Hello Dave,

    Nice blog to read, but you are missing some essential things to get the whole tutorial working (please follow you own tutorial from beginning to end). You also write about 3 nodes in the beginning but you’ll need 4 nodes (loadbalancer) later on. The loadbalancer is your biggest bottleneck here……what if your loadbalancer goes down for any reason? If money ain’t a problem then I would prefer a backup load balancer. then 5 nodes in total is the way to go! Do you also thought about a clustercheck?

    Regards,

    Michel

    Reply

    • Anon
      January 15, 2018 @ 3:39 pm

      Hi Michel – the guide has been updated to note that 4 nodes are used, although if you’re worried about this you can use the Digital Ocean load balancer feature they provide.

      I’ve also updated the guide to replace Unison with GlusterFS which gives instant file replication and eliminates the need to activate plugins at node 1. Now you can do whatever you like on any node and it will replicate properly.

      If your load balancer goes down, firstly it’s an incredibly simple server, so I don’t agree it’s your bottleneck here – all it’s doing is decrypting SSL and proxying traffic through to the other nodes. Secondly, it’s easy to rebuild – takes about 5 minutes.

      Reply

  6. Michel J.
    January 15, 2018 @ 5:12 pm

    Hello Dave,

    thanks for the heads up. I am also working with GlusterFS so we are on the same boat here 🙂

    I know the rebuild of the LB isn’t that difficult and takes aprox 5 minutes. But in my case I am running a very big website which I can’t afford downtime on. Although it’s a simple process, but If my website goes offline overnights (okay I also can ad some monitoring software with SMS or whatever alarms we can think of) I’ve got a problem I don’t want to. Then it’s better to go with en failover loadbalancer. Once again money shouldn’t be the issue with this kind of setup.

    Regards,

    Michel

    Reply

    • Michel J.
      January 15, 2018 @ 5:34 pm

      Btw, perhaps for everyone here following this interesting blog it’s good know which servers and configuration you need.

      My setup is:

      LOADBALANCER 1 (2GB Droplet): LB + Keepalived daemon (NGINX)
      LOADBALANCER 2 (2GB Droplet): LB + Keepalived daemon (NGINX) (Failover)
      NODE 1 (8GB Droplet): Webserver 01 + DB (NGINX + PERCONADB + PHP-FPM 7.1)
      NODE 2 (8GB Droplet): Webserver 02 + DB (NGINX + PERCONADB + PHP-FPM 7.1)
      NODE 3 (8GB Droplet): Webserver 03 + DB (NGINX + PERCONADB + PHP-FPM 7.1)

      Regards,

      Michel

      PS.

      Perhaps it’s even fancier to setup separate caching servers with Memcached or Redis. One server could be used to offload PHP session and the second server could be handled by WordPress.

      Reply

      • Anon
        January 18, 2018 @ 4:49 pm

        There’s no real requirement for servers, other than what I specified. Ubuntu 16.04, although Debian will probably work with the above commands. Other than that, make sure it has some decent amount of RAM, 2GB minimum, the more the merrier, and SSD disks, but these are not really requirements, just nice-to-haves.

        I’ve built these with with as low spec as 3x2GB RAM + 1x1GB RAM (loadbalancer), and as high as 4x8GB RAM + 1x2GB RAM (load balancer) + some other variations of these sizes. There’s no limit to the number of nodes you can have – e.g. you could go 10x32GB RAM if you so wish, and you can also use any load balancer you like, e.g. you could use the digital ocean load balancer.

        And yes, you can set up separate elements in your cluster, like a cluster of redis or memcached servers. The way the Nginx config for the load balancer is set up above, each user will stick to the same node (stickied by IP address) unless that node goes down. Each nginx server in the above config is running its own page cache using fastcgi_cache which is as fast as varnish. That works for logged out users only and switches off when key wordpress things happen, e.g. comments, or add to basket or similar.

        Reply

      • Raghav
        August 21, 2018 @ 3:47 pm

        Hi Michel, David,

        I really appreciate you sharing the DO server hardware configurations. I would like to request you to let us know for what kind of traffic was this setup made? I’m just curious to understand the numbers.. Example: X million users per month and X number of concurrent users / connections / requests in average to load balancer..

        Thanks and looking forward for your reply.

        Best Regards,
        Raghav

        Reply

        • Anon
          August 29, 2018 @ 3:33 pm

          There’s a video being released in September using a variety of load testing tools to simulate user traffic and huge numbers of products, posts, comments etc. I’m sure your question is more: What’s the maximum per hardware/per node? That video will answer those questions.

          Reply

  7. Jeff
    January 19, 2018 @ 3:33 pm

    Hey Dave,

    I am having problems with Issuing the SSL certificate on the Load Balancer.

    When I try to issue the SSL, certbot gives me the following error:

    ////

    Failed authorization procedure. http://www.yet-another-domain.com (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://www.yet-another-domain.com/.well-known/acme-challenge/9KuNEVFp7MWWUcl4D_iqvyod7a3waFKA8VpNDsD8HH0: ”
    <html xmlns="http:", yet-another-domain.com (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://yet-another-domain.com/.well-known/acme-challenge/4QZAR_4OJ-c9gSB8Fxo-eMq0Uj8N5V_JsV9cl2Re3Xo: "
    <html xmlns="http:"

    IMPORTANT NOTES:
    – The following errors were reported by the server:

    Domain: http://www.yet-another-domain.com
    Type: unauthorized
    Detail: Invalid response from
    http://www.yet-another-domain.com/.well-known/acme-challenge/9KuNEVFp7MWWUcl4D_iqvyod7a3waFKA8VpNDsD8HH0:
    "
    <html xmlns="http:"

    Domain: yet-another-domain.com
    Type: unauthorized
    Detail: Invalid response from
    http://yet-another-domain.com/.well-known/acme-challenge/4QZAR_4OJ-c9gSB8Fxo-eMq0Uj8N5V_JsV9cl2Re3Xo:
    "
    <html xmlns="http:"

    To fix these errors, please make sure that your domain name was
    entered correctly and the DNS A/AAAA record(s) for that domain
    contain(s) the right IP address.

    ////

    My A record is set, and CNAME for www, but the host doesn't provide an ipv6 address. But I've used certbot at other times no problem issuing certs for sites.

    Difference is the im trying to issue it on the loadbalancer, never done with certonly to webroot path before. Are there any special permissions, or is that the full configuration needed for the Load balancer above? Or does it require extra settings on the nodes? I used a stripped down regular nginx configuration for the nodes, since I am not using fastcgi_caching, but I did include the ACME stuff in the server block.

    Thanks for any help or pointers you can give.

    Jeff

    Reply

    • Anon
      January 19, 2018 @ 9:01 pm

      Did you install the full file from the page above onto your loadbalancer? Importantly, you need the rule to allow the .well-known files.

      Config above works and is full config for load balancer – i’ve set up a bunch of them. It’ll be the ACME stuff that’s failing – the ACME stuff needs to be on your LOAD BALANCER, not on the nodes.

      Reply

      • Jeff
        January 20, 2018 @ 6:13 am

        Hey David, thanks for the help. Yeah i am absolutely sure it is working, I am trying to adapt it for my workflow, so stripped it back and will re-add your fastcgi_caching and security stuff as I go.

        It’s all good stuff.

        One thing I did note, on the load balancer, I needed to delete the default symlink from the etc/nginx/sites-enabled folder.

        I also had to delete the inverted commas from:
        wsrep_sst_auth=”sstuser:password”
        to:
        wsrep_sst_auth=sstuser:password

        The full file for the load balancer ‘/etc/nginx/conf.d/loadbalancer.conf’ above was up on the load balancer.

        So in the tutorial, all the files from your github ‘https://github.com/dhilditch/wordpress-cluster /root/wordpress-cluster/’ nginx file should be on the load balancer aswell, crucially, the acme stuff?

        I will get to that.

        Nice one!

        Reply

        • Anon
          January 20, 2018 @ 7:55 am

          No I didn’t mean you needed to install the file from github on the loadbalancer. Maybe it’d be easier if I put a copy of the file for the loadbalancer on github, but I just mean the loadbalancer.conf text above.

          There’s a comment in the text above that says: # this block is for letsencrypt.

          Reply

        • Anon
          January 20, 2018 @ 9:10 am

          Maybe it’s because you deleted the default symlink – not sure why you needed to delete that on the loadbalancer?

          Reply

        • Jeff
          January 20, 2018 @ 9:16 am

          I didn’t actually get it working using the webroot/ACME method – I will do later though I am sure.

          Instead, for now, I just created a virtual host on the loadbalancer for my domain, and then used certbot –nginx plugin.

          There is a bit of an issue at the moment with certbot –nginx plugin:
          https://community.letsencrypt.org/t/solution-client-with-the-currently-selected-authenticator-does-not-support-any-combination-of-challenges-that-will-satisfy-the-ca/49983

          So need to use:
          sudo certbot –authenticator standalone –installer nginx -d -d –pre-hook “service nginx stop” –post-hook “service nginx start”

          But this all worked.

          Also with the clusterwpadmin and clusternodes, redirecting admin access to 9443:

          This:
          define( ‘FORCE_SSL_ADMIN’, true );
          if (strpos($_SERVER[‘HTTP_X_FORWARDED_PROTO’], ‘https’) !== false) {
          $_SERVER[‘HTTPS’]=’on’;
          }

          needed to be above this:
          /** Sets up WordPress vars and included files. */
          require_once( ABSPATH . ‘wp-settings.php’ );

          That had me for a while.

          This is all really great. Like I say, I am going through your Nginx configuration, lots to learn from there regarding optimizing an Nginx stack, this is all very much appreciated Dave.

          I’d definitely like to buy you a beer if you have any such a button?

          Jeff

          Reply

          • Anon
            January 20, 2018 @ 10:25 am

            Thanks Jeff – I’ve added a tip button to the sidebar for you 🙂

          • Jeff
            January 20, 2018 @ 1:04 pm

            Tipped, thanks again mate.

  8. Edi
    June 19, 2018 @ 1:15 am

    Hi David,
    thank you for this guide. It is very well written and easy to follow.
    I have some questions:
    1. How do i know which node is delivering my site? I added a header on nginx fastcgi on every node and it returns allways the same node.
    2. Would be easy to switch from ip_hash; to least connections?
    3. If i switch node-1 off, then i am getting an error. Should not the site be served from one of the other nodes?

    edi

    Reply

  9. falinapterus
    July 10, 2018 @ 4:31 pm

    What about DDL? How WordPress manages that considering Galera requires to change RSU method in each node and work in a more isolated way?
    I’m not a master in WOrdpress but this topic really worries me
    Thanks and great post!

    Reply

    • Anon
      August 29, 2018 @ 3:30 pm

      The way Galera is set up here, it confirms that all nodes have made the change before committing on all of them at the same time. It’s a little slower than less strict replication but it avoids these issues.

      Note: It’s important you keep your Redis object cache on however, as the number of writes to the database from transients can cause issues with this replication.

      Reply

  10. Thiago B
    July 15, 2018 @ 1:33 am

    Well written article that helped me on a project I was working with. During setting this cluster up I faced an issue with the percona cluster and got in touch with Dave (the author) who clearly went out of his way, going back and forth with me through e-mail to help me out until the percona database issue was fixed. Working at this project was extremely important to me and I wouldnt have done without this article. Dave has no idea how much he helped me and how much I appreciate it! I am not encouraging people to use Dave as a tech support analyst but I just want to let everyone know that hes the real deal and helped a fellow sysadmin in need.

    Reply

  11. Jose S
    August 10, 2018 @ 4:18 pm

    It didn’t work for me, I followed step by step and I didn’t even change, just copy/paste. Everything works until the replication with Unison but after that when set DNS provider made them to point to the LB, but it didn’t load WordPress installation.

    I check the logs and the LB is receiving the request from my website correctly but seems like something is wrong with loadbalancer.conf

    I will appreciate if you can help me to clarify this.

    Thanks!

    Reply

    • Anon
      August 29, 2018 @ 3:23 pm

      You might want to try removing the /etc/nginx/sites-available/default config on the load balancer and/or restart nginx.

      Reply

  12. Raghav
    August 21, 2018 @ 3:45 pm

    Dear David,

    I would like to sincerely thank you for this great yet simple to understand guide. It’s really difficult to write technical documentation like this and be crystal clear at the same time. So, thank you for taking your time to share your knowledge and ideas with the world for free!

    I’m trying to create a same setup, but will try to replace mysql / percona with something else may be and try to add redis. Not sure how much time consuming that’ll be for me given that I’m not an expert in writing nginx configs.

    I will update here once i’m successful in above.

    Thanks & Cheers!
    Your Fan from India!

    Reply

    • Anon
      August 29, 2018 @ 3:22 pm

      Redis is easy to setup. The only config change you need to make is to make it a non-persistent storage, and set the max memory you’d like your redis cache to use. Then install the redis plugin and add object caching. Apart from the speed boost of object caching, you also get all wordpress transients moved to redis in-memory storage which eliminates a bunch of unnecessary writes to your disks.

      Reply

  13. .
    September 7, 2018 @ 11:55 pm

    Hi David,
    Can’t thank you enough for your good work.
    My question is related to wp all import. How this above setup will help me achieving 1 Million product import every night.
    Feels to me the whole above setup is mainly for serving the site faster?

    Thanks.

    Reply

  14. Amit
    October 2, 2018 @ 7:20 am

    Hi David,

    Request your inputs on this..

    I’m trying to setup multisite install (subdirectory mode) of wordpress. I’m assuming to add nginx rules as per below mentioned link, i have to edit the /etc/nginx/sites-enabled/wpintense.cluster.conf on all the 3 nodes? (except the load balancer node)..

    Is my assumption correct?
    Also, please let me know if the nginx conf shown in below link looks OK?

    https://www.itworld.com/article/2871918/how-to-configure-nginx-for-wordpress-multisite-with-subdirectories.html

    Best Regards,
    Gane

    Reply

    • Dave H.
      October 22, 2018 @ 2:45 pm

      Get in touch through our on-site chat and I can help you out.

      Reply

  15. Moses Oyewole
    October 11, 2018 @ 12:50 am

    Hello David i have tried these processes following every details but i still don’t see the database cluster working, mysql fails to connect on node 2 and 3 after configuring the wsrep.cnf file.

    i also ran `clustercheck` on node 1 even if everything seems okay on it with mysql running but i get this message below

    HTTP/1.1 503 Service Unavailable
    Content-Type: text/plain
    Connection: close
    Content-Length: 57

    Percona XtraDB Cluster Node is not synced or non-PRIM.

    Reply

  16. Andy
    December 12, 2018 @ 11:22 pm

    Hey David,

    I’m pretty late to this article, but wondering if you can help clarify how you setup the FastCGI cache, especially the purging aspect of it.

    How are you clearing the cache from all the servers? Is it a manual operation or did you create a manual plugin to handle it or?

    Thanks in advance.

    Reply

  17. Podo
    December 27, 2018 @ 6:53 pm

    Hm, I am stuck on private networking. I am not using digitalOCEAN and default Ubuntu 16.04 is completely different from this manual.
    Also installing php 7/nginx is throwing error…

    So I guess i am going back to centminmod…

    Reply

    • Dave H.
      December 29, 2018 @ 2:27 pm

      Sorry I can’t help you further. Setting up a cluster is definitely not for everyone – you really should have sysadmin skills.

      Reply

  18. Ruslan
    February 10, 2019 @ 2:21 pm

    Dear Dave, thank you for the detailed guide on WP clustering. Indeed all these steps look like a mammoth task, and can be a nightmare for non-experienced folks. To solve this problem Jelastic team has built “WordPress PaaS Engine” with integrated high availability and load balancing. For example, one of the possible cluster topologies that our solution supports – 2 x Load Balancer + 2 x App Server (NGINX or LiteSpeed) + 3 x MariaDB Galera + 2 x Storage Container + 2 x Redis (per request). A cluster can automatically scale on each layer (lb, app, server, db) based on predefined triggers.

    Two or more clusters can be installed across different regions and covered by Geo-DNS for providing advanced DC failover solution. Multi-region deployment is in closed beta at the moment, but can be provided per request.

    A quick video overview of the dashboard and how to get started with Jelastic WordPress Cluster https://www.youtube.com/watch?time_continue=43&v=GalbkKxC79Y.

    It will be great to get your feedback as an expert in this area and make sure that we did not miss anything important. Please let me know if you would like to get a sandbox for playing around.

    Thank you in advance

    Reply

    • Dave H.
      March 27, 2019 @ 2:08 pm

      Hi – it’s great to hear that others are building clustering solutions to make this simpler. I’ll gladly make your comment visible for others, and yes I’d be keen to get access to a sandbox to play with and run performance tests.

      Reply

      • Arindam
        February 23, 2020 @ 2:15 pm

        Jelastic is indeed a better solution. They also offer great clusters by just one click deployments. Their pricing model is also pay for what you use type.

        Reply

  19. Guest
    March 9, 2019 @ 2:22 pm

    I did a little research and found interesting solutions:

    https://convesio.com/features/
    https://closte.com/features
    https://console.cloud.google.com/marketplace/details/click-to-deploy-images/wordpress-ha

    Maybe you can create your own pre-configured one-click install solution or join the project like: https://github.com/WordOps/WordOps ?

    I know about Kinsta or Cloudways, but they cost more.

    Reply

    • Dave H.
      March 27, 2019 @ 1:55 pm

      Hi – that’s a great idea and something I’ll likely approach in the future. I have considered in the past doing similar one-click installs on Digital Ocean and AWS, so no reason to not include these other platforms at the same time.

      Reply

    • Dristen
      June 11, 2019 @ 12:04 pm

      Have you actually setup a cluster with WordOps? Really want to know that’s possible.

      Looking at SlickStack documentation they said its not tested, and purpose is single WP servers:

      https://github.com/littlebizzy/slickstack

      Reply

  20. Adam
    May 9, 2019 @ 9:26 am

    Thanks for the great article, Dave. I’m currently hosting my website on a single server and I’m looking at this kind of setup in case I might need it. Your incredible article helped me understand important points. Hoping to implement it soon.

    Reply

  21. cakePlease
    May 26, 2019 @ 4:16 am

    hi there,
    Thanks for posting this guide and sharing your knowledge, it is greatly appreciated.

    I’m curious if you or anyone has tried this on Cloudways hosting service. Cloudways’ servers have Apache as part of their tech stack and im not sure how that will affect the whole cluster. I think we can disable Apache, but im not sure if the server will work as intended. Let me know if you know anything. Thanks.

    Reply

    • Dave H.
      May 27, 2019 @ 11:58 am

      Not possible. Cloudways is too locked down. They use a combo of Apache, Varnish and Nginx.

      In my experience supporting people, I’ve found their stack to be a bit overcomplicated and not as fast as the raw stack in this guide.

      I pulled my recommendation for Cloudways as a result about a month ago.

      Reply

      • Guest
        May 27, 2019 @ 12:34 pm

        Hi, have you tested GridPane? Do you recommend it?

        Reply

        • Dave H.
          June 4, 2019 @ 12:15 pm

          I haven’t run the performance tests yet. I’ll be comparing WP Engine, Grid Pane, Kinsta and Siteground in a new article soon.

          Reply

      • cakePlease
        May 30, 2019 @ 12:39 am

        Thanks for confirmation. Yes, i agree Cloudways is pretty locked down. But it definitely has its purpose to simplify most sites i’ve managed. I’m willing to sacrifice a bit of speed (and gain it back elsewhere) to gain ease of provision and maintain–it’s not always possible to sit at a computer and SSH to a raw server all the time.

        Reply

      • cakePlease
        June 6, 2019 @ 1:09 am

        Me again. With the load balancer server you have configured here. Are you aware of any UI we can use to visually view what the LB is doing and how it is routing traffic to each server? Perhaps, also a way to view health on each of the web server as well?

        I know DO has their own LB solution that may do this, but the last time i tried to play around with it, the whole solution was not very intuitive to get up and running

        Reply

  22. David Okwii
    July 6, 2019 @ 2:42 pm

    Hey, Thanks for the tutorial. I see that you had terrible performance results with GlusterFS. Now you turned to Unison which syncs files. However, have you tried with NFS mount instead in place of Unison or GlusterFS?

    Reply

    • Dave H.
      July 6, 2019 @ 3:43 pm

      Yes, I tried it. The problem with NFS is that the file system from each node will try to write or read the file directly. This often results in race conditions. When it reads the file, it grabs a ‘read lease’. This read lease doesn’t prevent other nodes from reading the file, but when the file is then written to that node will have to wait until all read leases are released. That causes sudden halts.

      Worse than that is possible – if some PHP script grabs a read lease at first, then the same script on a different node grabs a read lease, and then node 1 attempts to write to the file it will fail indefinitely – this is the race condition.

      There are a couple of workarounds – avoid writing to files – seriously, that’s an option, since files in WordPress should really only be written once and everything else should be in the database. We’re talking plugin files, images, css, js etc. But, some plugins will write to files and some custom code does too.

      Using Unison, everything is written locally and then queued to be written to the other nodes avoiding any possibility of the local node not being able to quickly read or write to its own files.

      Reply

  23. Sam M
    October 13, 2019 @ 1:05 pm

    Thanks so much for this tutorial. I love that the central node in the star is private. I’m wondering if you or anyone is aware of a way to only activate specific plugins on that node, so that they don’t cause a performance hit on the public nodes?

    Sam

    Reply

    • Dave H.
      October 21, 2019 @ 5:29 pm

      Not that I know of unfortunately – even if you somehow got the plugin files only onto 1 node the other nodes would then notice missing plugin files and deactivate the plugin(s) in the database which would repl back to the first node.

      If someone else has a solution, maybe they can offer one.

      Maybe multisite is what you are looking for?

      Reply

  24. Nicolai G.
    November 7, 2019 @ 3:52 pm

    Hey Dave

    Thank you for the tutorial, I will most likey give this a try in the near future.
    However, I’m new to a lot of this stuff, and therefore have a few questions.

    1. Might be a rookie question, but if you expect having a product database taking up for instance 100gb, is 100gb disk a must on all four nodes or is it enough to have a 100gb disk on 1 node?

    2. I have also been wanting to setup a staging site for some time now. Is it possible to integrate that into this cluster or should that be done separately?

    Thanks.

    Reply

    • Dave H.
      December 18, 2019 @ 8:55 am

      1. These nodes are effectively independent nodes and can run on their own if they have to, so yes 100GB would be required on each disk. If you want to avoid this, you’d need to use a SAN or something.

      2. You could have one extra node that is your staging server and then disconnect that from the cluster. But better practice would be to have a separate cluster.

      Reply

  25. hamid no
    November 23, 2019 @ 6:39 pm

    Thanks so much for this tutorial.
    Ihave a problem with nignx at the loadbalancer configration file.
    i done every thing with your description but the web server dos not start.
    when i save and restart the nignx it showed me an erorr.
    Nov 23 18:14:39 loudbalancer nginx[1405]: nginx: [emerg] no “ssl_certificate” is defined for the “listen … ssl” directive in /etc/nginx/conf.d/loadbalancer.conf:38
    Nov 23 18:14:39 loudbalancer nginx[1405]: nginx: configuration file /etc/nginx/nginx.conf test failed
    Nov 23 18:14:39 loudbalancer systemd[1]: nginx.service: Control process exited, code=exited status=1
    Nov 23 18:14:39 loudbalancer systemd[1]: Failed to start A high performance web server and a reverse proxy server.
    — Subject: Unit nginx.service has failed

    Reply

    • Dave H.
      December 18, 2019 @ 8:11 am

      Sounds like you have uncommented the SSL cert line prior to actually running letsencrypt. You should comment out those SSL lines, then get nginx started, then run letsencrypt again.

      Reply

  26. Mahir Ahmed
    November 29, 2019 @ 9:22 pm

    Thanks for this great tutorial.
    I would like to know how can we do this if i use a mutliole domains in my wordpress multisite that let users choose their preferred domain.

    Reply

  27. Andre
    December 14, 2019 @ 1:19 pm

    I have tried to make use of a 7 pi cluster recently. After trying to do different things with it I have decided I want to make use of it as my personal web server (all 7 of them) using WordPress.

    I was thinking of the following setup:

    1. Load balancer
    2. Website (Apache or NginX)
    3. Website (Apache or NginX)
    4. Database (MySQL)
    5. Database (MySQL)
    6. Cache
    7. Storage for cluster

    Is this a good use for the 7 Pis? could i do better? What is the best way to have a setup like this? What would i need?

    The purpose of it; simply a “distributed computing” style wordpress site.

    In the near future once i have this running satisfactorily i would like to duplicate the whole setup and have redundancy.

    Cheers,
    Andre

    Reply

    • Dave H.
      December 18, 2019 @ 8:00 am

      There are lots of ways you can set up clusters. In the guide I’ve listed I have web + db on each node. But yeah, you could do it your way too.

      Reply

  28. layla
    December 29, 2019 @ 7:39 pm

    how can i add high availability to wordpress for free in oracle virtual box. doing it or school and cant seem to find a way

    Reply

    • Dave H.
      January 15, 2020 @ 7:11 pm

      Follow the guide and set up a cluster. Clusters provide high availability since you only need 1 out of 3 (or however many nodes you have) to be online in order for your service to be available.

      Reply

  29. Darren
    May 23, 2020 @ 9:03 pm

    Really interesting stuff and I’m gobsmacked that you both have the time and energy to keep up with all the comments on all these various articles so congrats. I’ve only recently started reading through your articles and will surely now buy your performance plugin based solely on my understanding of how converting any table scans to seeks can rocket performance.

    Its really only been the last two days I’ve given your rocketstack a go and now having read this article will surely look at building a cluster to offload admin tasks. We’ve been paying way too much for a 4XL AWS server with Cloudways to mask some performance issues on a site with a few 1,000 products and 100k+ orders and users. Using the base rocketstack I’ve been able to replicate the performance of that on a much more cost effective VPS measured using K6.

    So thanks for all the help and knowledge your articles have provided ! I’m just now discovering some of your videos.

    Reply

    • Dave H.
      May 24, 2020 @ 1:15 pm

      Thank you – there are other videos coming out soon and a fresh article for ubuntu 20 and other options for clustering as well as hosting reviews and comparisons.

      If you’re happy administering your own site with SSH, then my stack guides are great but if you’re looking for a control panel I can recommend Gridpane.

      If you need further help, I’m running a deal right now where plugin pack purchases until the 12th June get a 50% off coupon for 2 of my performance analysis and optimisation options.

      Reply

  30. Foxler2010
    June 3, 2020 @ 3:27 am

    I am setting up my cluster a bit different than in the article, using Raspberry Pis and hopefully the Apache server. I would like to know whether I can use
    the apache2 package for this project because I have more experience with that server. Nginx config seems complicated and the Nginx docs are a bit bland so I don’t want to spend a ton of time reading them, although I do think that Nginx would be good for the LB. Is there a way to use Apache for the server nodes and Nginx as the load balancer? Also, is this even a good project for the Raspberry Pi, considering I have lots of storage and caching plugins?

    Reply

    • Dave H.
      June 3, 2020 @ 4:24 pm

      You can use Apache, it’s just that Apache is a memory hog so you’ll get a lower total number of simultaneous visitors possible.

      re: Raspberry Pi – that’s an interesting use case, let me know how it goes.

      Reply

    • Foxler2010
      June 5, 2020 @ 2:00 pm

      I couldn’t install Percona xxtradb cluster on the pi. I first did the instructions in the tutorial, but the package wasn’t found by wget or apt. I went to the Percona website and it said to configure the repository before installing. I did their instructions but the package wasn’t found and the percona-release script I ran said armhf wasn’t supported, so it skipped some packages. I am going to try doing a different database solution and I will use nginx because, like you said, apache is a memory hog.

      Reply

  31. Hanya lewat
    July 1, 2020 @ 7:28 am

    Hello, How to fix I can’t access my domain.com:9443
    I have successfully install let’s encrypt and now I’m using cloudflare. The ssl work well on my domain but if I add port 9443 the site is unreachable

    Reply

    • Dave H.
      July 1, 2020 @ 4:32 pm

      If you’re using cloudflare, they won’t proxy traffic through that port. I checked for you and it seems they allow you to use 8443, so either you can change your config everywhere to forward traffic for 8443 to node 1, or you can access node 1 using the IP address directly with the port number 8443 on it, or alternatively you could configure a different sub domain admin.yourdomain.com in cloudflare and alter your nginx config so that requests for admin.yourdomain.com get directed to node 1.

      https://blog.cloudflare.com/cloudflare-now-supporting-more-ports/#:~:text=CloudFlare%20protects%20and%20accelerates%20web,)%20and%20443%20(HTTPS).

      Reply

      • Hanya lewat
        July 2, 2020 @ 9:45 pm

        Thank you, one more question sir…

        Example, I have 2 domain name on my node1, node2 and node 3
        1. domain.com
        2. api.domain.com

        Then, how i setup it at load balancer server 4?

        Reply

        • Dave H.
          July 6, 2020 @ 1:10 pm

          Well your load balancer should have your public domain name, then on that node you use the “upstream clusternodes” block and then “proxypass http://clusternodes“.

          upstream clusternodes {
          ip_hash;
          server 10.130.47.4 max_fails=3;
          server 10.130.47.11 max_fails=3;
          }

          Reply

  32. Eric M. Klingensmith
    July 6, 2020 @ 2:54 pm

    I’m about to give a go at a similar setup in AWS. Thought it might be worth mentioning that AWS Application Load Balancers have mechanisms built right in to handle this sort of routing with the wp-admin.

    https://i.imgur.com/v5KIkYP.png

    Reply

  33. Roberto Jobet
    July 15, 2020 @ 10:52 am

    Hi Dave,

    Thanks a lot for this nice tutorial!

    I was wondering about the Percona version you are installing (0.1-4). Today (July 15 2020) the latest release is 1.0-10. Should I install this latest one?

    Furthermore, in the “apt install percona-xtradb-cluster-57” command, what stands “57” for? (latest release of XtraDB is 8.0.19)

    Thanks.

    Regards

    Reply

    • Dave H.
      July 15, 2020 @ 11:44 am

      Yeah, you should install the latest of all components. I’ll get an updated article out before the end of the year.

      Reply

  34. Ian Altosaar
    August 6, 2020 @ 8:58 am

    Great article, guide.

    Have You experienced changing the dbhost in wp_config to for example one of the other nodes in the cluster and the site requesting to be installed again? Can’t figure this one out. The DB’s are identical, table prefixes identical. Is there another place that WordPress writes something that requests the install that needs changing along with the DB_HOST?

    Reply

    • Dave H.
      August 31, 2020 @ 6:03 pm

      Are you sure DB replication is running properly? You can test by modifying data manually in wp_options on one server and checking on the other.

      The other potential issue is maybe your web server cannot actually connect to the database on the other server – you can test that using the MySQL command with the IP of the other node.

      Also – you should make sure you use the INTERNAL IP addresses for the database host.

      Reply

  35. Foxlor2010
    October 20, 2020 @ 1:24 am

    Hi, I posted a few months ago and remembered about this one file sync solution I came across that would be really great for this stack. It’s called Syncthing and I successfully got it working on my Pis and it was fantastic. I thought that it would be great if everyone on this website knew about it as an alternative to unison as it is a bit easier to use at least for me. You can find out more about it at syncthing.net. Hope you can get it working.

    Reply

    • Dave H.
      October 20, 2020 @ 8:23 am

      Thank you for letting us all know.

      Reply

  36. Sam B
    January 6, 2021 @ 1:51 am

    Hi there, is there an updated version of this guide for Ubuntu 20.04 and all of the updated software involved with this?

    Thanks!

    Reply

    • Dave H.
      March 1, 2021 @ 5:51 pm

      I’ll be releasing a 20.04 version in the summer. Focusing on plugin updates first.

      Reply

  37. Yuvi Dror
    January 19, 2021 @ 7:15 pm

    Thanks dave for a great article !
    If you want to seperate the Database cluster from the Application cluster,
    I suggest to install ProxySQL on each application server,
    , and Percona PXC (xtraDB Cluster) on separate 3 machines for the database cluster.

    Each ProxySQL you installed must have the same definitions, to contact the cluster.

    CRITICAL – It is recommended to have just 1 node as writer in the Percona PXC cluster.
    The way to make each ProxySQL pick the same Database machine for writing,
    is by setting a DIFFERENT values in the column: weight in the mysql_servers table of ProxySQL.

    For details – See these links regarding ProxySQL configuratoin.
    It is recommended as a great tool to handle the Percona PXC cluster:

    https://proxysql.com/documentation/getting-started/
    https://proxysql.com/blog/effortlessly-scaling-out-galera-cluster-with-proxysql/
    https://proxysql.com/blog/configure-read-write-split/

    Reply

    • Siddharth
      September 21, 2021 @ 4:09 am

      Hi There,

      I have created the cluster using my own setup. And also I generally use ProxySQL and split read and write queries using ProxySQL. In this case, it is not working for me. All the pages in my woo-commerce are working except the checkout page. When I try to click on proceed to payment, it is not moving further.

      I have used MariaDB Galera Cluster + ProxySQL ( 1 Write and 2 Reader )

      Also in the article, they have not mentioned anything about Load Balancing DB queries.

      Reply

      • Dave H.
        September 22, 2021 @ 10:11 am

        Check your debug log, it should tell you what’s going wrong.

        Reply

  38. Brandon
    February 16, 2021 @ 6:58 am

    Great guide. Still relevant in 2021 IMHO. Other than the lack of multi-tier DB, it’s a great option. I love the option of using a separate server as the load balancer rather than a cloud solution (I am using Oracle). It’s cheaper this way and provides a faster load balancer to boot (pardon the pun).

    I am currently using this guide, as well as your Rocket Stack, and searching through others to provide HA multi-tiered MySQL to WordPress. I never liked the idea of running the DB on the same machine as the webserver. I’d rather keep them in separate private subnets, for obvious reasons — security.

    If you could point me in the right direction of the best option as applied to this guide, that would be great.

    Reply

  39. Nari
    August 24, 2022 @ 11:36 am

    Hi Dave, thanks for your great tutorial, please can you tell me where do i have to install varnish cache on load balancer or on nodes?

    Reply

    • Dave H.
      August 26, 2022 @ 10:40 am

      If you are determined to use varnish, you can actually use varnish AS your load balancer and it will also cache.

      Reply

Leave a Reply

Your email address will not be published.

Join me on Discord for Q&A and get a 20% discount coupon - Dave Hilditch, WP Intense