These are the slides of a talk I presented at WordCamp Nijmegen 2018, on august 31st. In this talk I show a couple of techniques that can be used to scale a WordPress site with a severely limited budget.
12. Apache Benchmark
• Used to simulate load
• Part of Mac OSX.
• Can be added via apt-get:
apt-get install apache2-utils
13. Apache Benchmark
• We’ll send 1000 sequential
requests to our new WordPress
site
ab -n 1000 http://159.65.195.6
16. Apache Benchmark
• We’ll now send 1000 requests
to our new WordPress site in
batches of 200 concurrent
connections.
ab -n1000 -c200 http://
159.65.195.6
18. Apache Benchmark
• Our shared server can process
16.98 requests per second
BUT…
The time required to process a
single request increases from
130 ms to a whopping 11776
ms.
• Now we’ll send 1000 requests
to our new WordPress site in
one single batch
ab -n1000 -c1000 http://
159.65.195.6
29. Connecting The Cluster To WordPress
Edit db-config.php to contain the various database connection
strings.
Place db-config.php into the same folder as wp-config.php
30. Connecting The Cluster To WordPress
/** The name of the database for WordPress */
define('DB_NAME', 'YourDBName');
/** MySQL database username */
define('DB_USER', 'YourDBUser');
/** MySQL database password */
define('DB_PASSWORD', ‘AReallyStrongPasswordShouldBeFoundHereForSecurityReasons');
/** MySQL hostname */
define('DB_HOST', ‘mysqlserver01.brechtryckaert.com’);
define(‘DB_SLAVE_1', ‘mysqlserver02.brechtryckaert.com’);
define(‘DB_SLAVE_2', ‘mysqlserver03.brechtryckaert.com’);
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
31. Connecting The Cluster To WordPress
Place db.php in the “wp-content” folder
Remove writing permissions to db.php
sudo chmod a-w /path/to/site/wp-content/db.php