In the post an inquiry into the performance difference of various wordpress setups is examined. A Vanilla WordPress Instance is compared with the following factors: PHP Opcache, W3 Total Cache plugin with redis, disk enchanced and memcached page caches enabled.
This can be used to give an idea but as always with performance your context matters and should test on all factors in your specific case.
Local means local to the server – on the same box.
All these tests were conducted on a 2 CPU VM (that has a single core each) running Ubuntu 22.04. It has 4GB RAM. It uses a mysql db.
Baseline (no-cache) vanilla performance
Setup: HTTP2, Nginx, PHP8.1-fpm, Opcache Enabled
Local (100 users at 0.3 a second for 5 minutes):
- Average response time: 373 ms
- Median response time: 170 ms
- Min response time: 153 ms
- Requests per second: 12.9 RPS
- 98 percetile: 2200 ms
The site looks like it blows up at 20 RPS.
Baseline (no-cache) alternate HTTP1.1
Setup: HTTP2, Nginx, PHP8.1-fpm, Opcache Off
Local (100 users at 0.3 a second for 5 minutes):
- Average response time: 5913 ms
- Median response time: 6400 ms
- Min response time: 286 ms
- Requests per second: 4.94 RPS
- 98 percetile: 12000 ms
Opcache allows for 2.5x more load and produces responses 15 times quicker. It is certainly something you don’t want to turn off and makes sense why it is turned on by default.
Enter Cache: W3 Total Cache Installed
After installing there will be a getting started guide. The homepage will be tested and compared with cache.
To get redis and memcached results – they need to be installed along with required extensions. Otherwise they will stay greyed out.
sudo apt install redis-server
sudo apt install php-redis
sudo apt install memcached
sudo apt install php-memcached
The above times will be tested under load
Page Cache: Disk Enhanced
Local (100 users at 0.3 a second for 5 minutes):
- Average response time: 56 ms
- Median response time: 13 ms
- Min response time: 5 ms
- Requests per second: 14.79 RPS
- 98 percetile: 240 ms
The search endpoint was slowing everything down. 6 times faster across the board.
Page Cache: Redis
Each key stores about 49272
bytes.
Doesn’t use much memory:
127.0.0.1:6379> info memory
# Memory
used_memory:32949200
used_memory_human:31.42M
Local (100 users at 0.3 a second for 5 minutes):
- Average response time: 86 ms
- Median response time: 21 ms
- Min response time: 6 ms
- Requests per second: 11.37 RPS
- 98 percetile: 560 ms
Enchanced disk is better
Page Cache: Memcached
Check memory usage:
telnet localhost 11211
stats
or
echo "stats settings" | nc localhost 11211
STAT rusage_user 1.415501
STAT rusage_system 1.985034
Not sure what that means…
Local (100 users at 0.3 a second for 5 minutes):
- Average response time: 72 ms
- Median response time: 16 ms
- Min response time: 6 ms
- Requests per second: 14.91 RPS
- 98 percetile: 370 ms
Memcached performs better with pagecache comapared to redis. However disk enhanced still wins overall.
Under load
Now we will launch it up to 1000 users and see how each performs….
Memcached
Local (300 users at 1 a second for 5 minutes):
- Average response time: 869 ms
- Median response time: 500 ms
- Requests per second: 38.73 RPS
- 98 percentile: 3100 ms
Redis
Local (300 users at 1 a second for 5 minutes):
- Average response time: 740 ms
- Median response time: 420 ms
- Requests per second: 40.15 RPS
- 98 percentile: 2600 ms
Redis performed better under load in this case
Disk
Local (300 users at 1 a second for 5 minutes):
- Average response time: 764 ms
- Median response time: 370 ms
- Requests per second: 39.98 RPS
- 98 percentile: 3100 ms
Performance similar to redis
Conclusion
In terms of load:
- memcached blows up at 53.5 RPS
- redis blows up at 65 RPS
- disk blows up at 54 RPS
Overall Redis appears to be the best general choice. For raw speed disk enhanced is best.