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).
horizontal scalable infrastructure Persistence VMs
Create two VM that will handle persistence
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.
A web server running PHP applications with one 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
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
Create a directory
Edit /etc/exports file
Add the following content at the end of the file and save it
Export share
Edit /ect/fstab