This is a stock XF install, loaded it with 10k threads, 100k posts. Its on a 1 cpu 2gb RAM Linode in Texas ($US12 monthly). I'm in Melbourne running these tests, just to put focus on the distance which adds probably 250ms per query.
This is on CentminMod stable.
I used K9 to load 100 virtual users per second onto the server, randomly choosing threads and pages, forums.
My point in this initial setup test for those dealing with crazy traffic, is that you need to focus on caching. 95th percentile in the image above, the largest single improvement was introducing disk page caching.
Here is the config file I put together for this test:
Code:
<?php
$config['db']['host'] = 'localhost';
$config['db']['port'] = '3306';
$config['db']['username'] = 'dbusername';
$config['db']['password'] = 'dbpassword';
$config['db']['dbname'] = 'dbname';
$config['fullUnicode'] = true;
$config['searchInnoDb'] = true;
$config['enableAddOnArchiveInstaller'] = true;
$config['cache']['enabled'] = true;
$config['cache']['sessions'] = true;
$config['cache']['provider'] = 'SV\RedisCache\Redis';
$config['cache']['config'] = [
'host' => '127.0.0.1',
'port' => 6379,
'database' => 0,
'compress_threshold' => 2048,
'compress_library' => 'zstd',
];
$config['cache']['frontendOptions']['automatic_serialization'] = false;
$config['cache']['context']['page']['provider'] = 'Redis';
$config['cache']['context']['page']['config'] = [
'host' => '127.0.0.1',
'port' => 6379,
'database' => 1,
];
$config['pageCache']['enabled'] = true;
$config['pageCache']['cleanThreshold'] = 500;
$config['pageCache']['lifetime'] = 300;
As outlined in image, Redis itself didn't make a whole lot of change,
BUT, when you also enable page caching, page loading went from seconds to under a second. Big change.
This alone shows what 1 cpu and only 2gb ram can do. No small site, even with all this bot craziness, is being hit with 100 users p/s. Image heavy small forums will benefit greatly from CF edge caching. The CPU went from 95% use to 60% - 80% spikes, once caching was running.
Cache Rule Expression for test forum
Code:
(http.request.full_uri wildcard "https://xfforumtest.com/*.css") or (http.request.full_uri wildcard "https://xfforumtest.com/*.js") or (http.request.full_uri wildcard "https://xfforumtest.com/*.jpg") or (http.request.full_uri wildcard "https://xfforumtest.com/*.png") or (http.request.full_uri wildcard "https://xfforumtest.com/*.woff2") or (http.request.full_uri wildcard "https://xfforumtest.com/*.ico")
Set Edge TTL to 1 day.
Don't get me wrong, /search and /whats-new are still vulnerable using MySQL.
Now if you were using 4gb RAM, then elasticsearch would remove the /search and /whats-new risk near entirely.
For $25 a month, you can have 2 cores and 4gb ram, more than plenty, which would easily run a forum probably up-to around the 500k+ post range.
Pretty much, if there is an optimisation in XF, I have not enabled it. Same with CF, if I can disable anything that would help the site, beyond the testing parameters, then it is disabled. Point is, I am intentionally not being nice to this test site to demonstrate where people should spend time and take seriously, the right caching that will deliver the right results for their website, thus load problems.
This is by no means robust testing, just testing a few things under the worst conditions to outline some important aspects that affect this conversation and global issue, to help those running smaller sites and smaller budgets handle this stuff without suffering, or expensive solutions.
