Wordpress deployment in a scalable infrastructure
A scalable infrastructure is comprised by a web server with a load balancer and multiple instances that are provisioned in periods with high demand. In order to ensure persistence a database instance is required. Static files are stored in a network file system (NFS).

Persistence VMs
Create two VM that will handle persistence
web-storage
web-db
Web Server
The web server has a load balancer and multiple instances that run the application. Cloud providers ensure the capabilities required to provision the infrastructure.
We will start the configuration by creating a Web Server with one instance. This will allow us to start with the minimal configuration required for the application and new instances will be added based on the snapshot of the master instance.

Creating the Web Server example
1. Select Programming Language: PHP
2. Select Web Server Type: nginix
3. Select Cloud: DigitalOcean
4. Select Location: Amsterdam
5. Select Operating System: Ubuntu 20.04
6. Select Plan: 2 vCPU /2 GB
Number of Servers: 1
Web Servers Name: web
Provisioning the resources will take around 10 minutes. When the operation is completed you should be able to see the load balancer and droplet in Digitalocean's dashboard.
Install Wordpress
Scale the infrastructure
Scaling the infrastructure to match our demand is a matter of increasing the number of instances.

Wordpress config
if($_SERVER['PHP_SELF']=="/index.php")
{
define('WP_HOME','http://shop.dovelopers.com');
define('WP_SITEURL','https://shop.dovelopers.com');
} else {
define('WP_HOME','https://shop.dovelopers.com');
define('WP_SITEURL','http://shop.dovelopers.com');
}
Pricing
Component
Monthly price
Load balancer
$10
Instances
$30
Storage
$10
Persistance
$20
Bunnyshell
$49
Total
$110
Performance improvements
Enable opcache


Network file system VM (nfs)
This step is optional. You only need to do it if you want to manually configure the nfs
Install NFS
sudo apt-get install nfs-kernel-server
Create a directory
sudo mkdir /nfsdata
Edit /etc/exports file
sudo nano /etc/exports
Add the following content at the end of the file and save it
/nfsdata 10.0.0.0/8(rw,sync,no_subtree_check,no_root_squash)
Export share
sudo exportfs -rav
Mount NFS
sudo apt install nfs-common
sudo showmount --exports <private_ip_of_nfs_server>
Edit /ect/fstab
<privateip_of_nfs_server>:/nfsdata /var/www nfs defaults,nfsvers=3,noatime 0 0
sudo mount -a
Last updated
Was this helpful?