Hi @dade88,
I’ve done some basic tests using XHPROF as profiler.
Testing condition
I’m testing locally, with a totally fresh installation of WordPress 6.6.1 and no other plugins than the CrowdSec bouncer :This may not represent production conditions at all, but it’s a start.
details: WordPress 6.6.1, PHP 8.1, Stream Mode ON, Debug log OFF
The test is a simple access to the homepage with a clean IP (no associated decision with this IP) and we are watching the main function of the plugin called safelyBounceCurrentIp
Results
I ran several tests with the same conditions, playing with the cache system and, as the results were not significantly different, I’ll just write a few average measurements :
The total execution time of the safelyBounceCurrentIp
function is around 5000 μs (micro-seconds). This is between 4 and 5% of PHP’s total execution time (around 120000 μs).
This function is mainly divided in 3 parts:
– loading settings in database with the getDatabaseConfigs
function: between 500 and 600 μs
– instantiating the bouncer (mainly init filesystem, redis or memcached cache, init curl or file_get_contents client, and init the bouncer rules depending on various setting) with the CrowdSecWordPressBouncer\Bouncer::__construct
function: between 3500 and 4000 μs
– bouncing: retrieve decision (from cache here) and acts accordingly (do nothing here as we test a clean IP) with the CrowdSecBouncer\AbstractBouncer::run
function: between 600 and 800 μs
Conclusion
I’m not sure these metrics are fast enough for you: it’s a bit subjective. And it should be consolidated with production tests (to see if those 4/5% increase or decrease with high web traffic and a WordPress site with lots of other plugins).
The second part of the process (instantiating the bouncer) is clearly the slower one. Perhaps, we could find a way to improve this.
Finally, if we see a large number of users complaining about performance degradation, we could work on a way to cut out parts 2 and 3 altogether (with your cookie solution or otherwise).
Feel free to open an issue on our GitHub repository if you want us to work on it.
Thanks again