How to Build a Scalable WordPress/WooCommerce Store

So you can run a small WordPress site on a single server. The web server (NGINX/Apache), PHP, MySQL database are all running on the same computer. That’s a good place to start when you first launch your own website (which you should do for a variety of good reasons. Read “Why I should build my own porn website.”) It’s the simplest method and you probably won’t have the traffic to justify a large server.

The thing about running a video platform is you have to store a lot of really large files — hunderds of 1GB+ files for your customers to buy or stream online. You don’t wanna run out of room to upload new files so you need to make sure the hard drive for the server is appropriately sized to fit your entire catalog and handle the next few years of uploads/updates. My site currently stores 557.5 GB of video content. That’s not even including the trailers.

Sp either I need to rent a server from Vultr (or some other webhost) with over 500GB hard drive (block storage) on it, which can get quite expensive — 500GB on Vultr costs $50/mo. Or better yet I can store these movies on an S3 storage server (object storage) for only $10/mo on Vultr. S3 object storage is a filesystem that expands infinitely, and you just pay what you use. You can also mount this S3 storage to you Linux server’s filesystem and use it exactly like a native hard drive, and never have to worry about running out of space — ever! Also, if you move your WordPress Site to a new server you don’t have to copy the files from one site to the next — you simply mount your S3 storage “bucket” to the new server using S3FS.

I’d recommend using S3FS to mount your S3 bucket to either /var/www/html/wp-content/uploads/ to ensure all your user-uploaded files of your WordPress installation will be saved to your cloud storage account. A better approach would be to save your entire web applications files to an S3 bucket and mount that to your /var/www/html/ folder, and that contains your WordPress files, themes, plugins, uploads, everything in the root WordPress folder. Doing this will allow you to create a scalable app that can spin up multiple application servers using 1 copy of the same site files mounted to the multiple app servers. That way if you make one change to your sites files it gets updated across all your app servers because they’re all using the same mounted filesystem.

Tiered WordPress/WooCommerce Site

Here’s a diagram I made of Each 3D shape is a server (or network of servers — like the CDN). This is what a high-availability (redundant) WordPress site looks like on paper.

From front-to-back it’s as follows:

    Web Tier

  1. DNS Server. The domain name server itself, in my case hosted on Cloudflare — they are nice and help protect my IP address and include a firewall, caching, and other services to speed up or secure my site.
  2. Reverse-proxies w/ SSL acceleration
  3. HTTP accelerator Varnish
  4. App Tier

  5. WordPress installed on NGINX server cluster.
  6. PHP server cluster.
  7. Cache Tier

  8. Cache w/ REDIS
  9. Database Tier

  10. MySQL Cluster

Leave a Reply

Your email address will not be published. Required fields are marked *