To reduce the AWS utilization on the elasticloadbalancers (ELB) and the RDS database I've put a memcached in the computing EC2 instances and CloudFlare as the CDN for the static content.
The general architecture is as follows:
![]() |
| AWS Scalable WordPress architecture |
First question I had about this to deliver the best performance possible with the minimum amount of resources was to select which AWS region to use. While looking at the traffic data, most of the traffic can be delivered with the lowest latency possible using Oregon (us-west-2).
Second step was to start provisioning the public and private subnets. This is because we don't want to expose anything but only the load balancer that is allocated inside the public subnet.
Then a little consideration about migrating the mariadb database. Both source and destination databases must be running the same version.
After the dump and import on RDS, next step was to move the wordpress files to the destination AWS storage. I chose EFS with bursting performance as the baseline, since I just want to see the overall performance with the lowest settings possible. For this I've provisioned also the EFS filesystem into two availability zones and then copied everything over with the help of a EC2 instance.
Also an important note is that I had to adjust the wp-config.php file to use the WP_HOME and WP_SITEURL to use the load balancer DNS name. Adjust the database settings and then do a cleanup and reconfiguration of the w3tc plugin.
With this EC2 instance up and running. I've took a snapshot from the EC2 instance to use that as the base AMI for the launch configuration so no need for configuration management needed when launching a new compute resource in the auto scaling group.
And what about putting everything on stress to simulate some traffic load? Well My option was to generate http requests using httperf trying to reach an amount of 3 requests per second and start doing adjustments from that point as the scaling policies.
$ httperf --server theloadbalancer.someavailabilityzone.elb.amazonaws.com --num-conn 1500 --num-cal 1 --rate 3 --timeout 5 --port 443 --ssl
The performance results with a t3a.micro instance:
- Total: connections 1500 requests 1500 replies 1500 test-duration 504.425 s
- Connection rate: 3.0 conn/s (336.3 ms/conn, <=12 concurrent connections)
- Reply status: 1xx=0 2xx=1500 3xx=0 4xx=0 5xx=0
The w3tc WordPress plugin works pretty fine in relation with the database. There's little activity on the connections and the read/write IOPS.
![]() |
| RDS 12h monitoring window |
AWS Resources:
- RDS
- EC2
- EFS
- Elastic Load Balancers
The tools:
- Terraform
- Shell
- Ansible
The helper resources:
So far, I was speaking closely with Aldo Rivadeneira while solving some technical questions and asking for some recommendations for the architecture and overall solution. Thanks for your help buddy.
- https://www.concurrencylabs.com/blog/choose-your-aws-region-wisely/
- https://serverfault.com/questions/630022/what-is-the-recommended-cidr-when-creating-vpc-on-aws
- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/hosting-wordpress.html
- https://stackoverflow.com/questions/2537486/create-dump-file-from-database-in-mysql
- https://www.digitalocean.com/community/tutorials/how-to-import-and-export-databases-in-mysql-or-mariadb
- https://stackoverflow.com/questions/13874836/how-to-use-1-database-connection-for-read-and-another-for-write-wordpress-mysql#13875300
- http://www.akamaras.com/linux/stress-test-your-web-server-with-httperf/
- https://dev.mysql.com/doc/mysql-repo-excerpt/5.7/en/linux-installation-yum-repo.html
- https://stackoverflow.com/questions/33374314/can-not-login-to-mysql-5-7-9-after-change-password
- https://help.dreamhost.com/hc/en-us/articles/214580498-How-do-I-change-the-WordPress-Site-URL-
- https://wordpress.stackexchange.com/questions/253245/wordpress-migration-getting-404-errors-only-home-page-works
- https://www.jeffgeerling.com/blog/2017/mount-aws-efs-filesystem-on-ec2-instance-ansible
- https://docs.bitnami.com/aws/apps/wordpress-pro/configuration/wordpress-aws-s3/
- https://medium.com/qbits/autoscaling-using-custom-metrics-5f977903bc45


No hay comentarios.:
Publicar un comentario