I'm designing a highly available WP site on AWS using Elastic Beanstalk, and testing use load with a Locust.
Everything looks alright: my EC2s are t2.mediums, auto scaled over 3-6 availability zones. Load balancer is set to "Cross-zone" load balancing (so traffic should be distributed to 3 servers in 3 different zones), I am using Aurora (db.t2.medium) with a master->read replica setup.
Things are fine when I visit the site in my browser, but as soon as I spin up Locust (with 100-500 users, 90-100 second wait times, 10 user hatch rate) my site will almost instantly lose the connection to the database and eventually throw a 50x error.
My Apache/PHP setup is pretty out of the box from Beanstalk (Amazon Linux AMI, php 5.6), specs listed below. opcache is enabled by default, but phpfpm is not currently installed.
Here is a diagram of my setup, and then the specs:
- EC2
- 3 t2.Mediums
- 2 vCPUs
- 24 CPU credits/hour
- 4g RAM
- Apache 2.4
- PHP 5.6
- upload_max_filesize => 64M
- post_max_size => 64M
- max_execution_time => 120
- memory_limit => 256M
- Opcache
- opcache.enable=1
- opcache.memory_consumption=128
- opcache.interned_strings_buffer=8
- opcache.max_accelerated_files=4000
I am unsure whether or not this is a hardware configuration issue, or if I need to tweak PHP/Apache/MySql
SHOW FULL PROCESSLIST;
andSELECT @@MAX_CONNECTIONS;
.SELECT @@MAX_CONNECTIONS;
shows 45 connections While I am running the swarm, the process list shows a bunch of connections from WordPress (DB_USER's user name), the command is sleep and state is "cleaned up", as well as a bunch of unauthenticated users running the "connect" command.