I use a somewhat obscure webserver on my sites and recently I have had trouble that all sites have been really slow. 10 seconds TTFB.
This corresponds with the timeout set in php.ini. And when I started logging slow php request I found that Defender was the culprint.
Example from slow log file:
[01-Nov-2019 16:40:00] [pool www] pid 807
script_filename = /var/www/doya/ordisky/index.php
[0x00007f973aa22480] curl_exec() /var/www/doya/ordisky/wp-includes/Requests/Transport/cURL.php:162
[0x00007f973aa22000] request() /var/www/doya/ordisky/wp-includes/class-requests.php:379
[0x00007f973aa21d20] request() /var/www/doya/ordisky/wp-includes/class-http.php:384
[0x00007f973aa21180] request() /var/www/doya/ordisky/wp-includes/class-http.php:630
[0x00007f973aa210b0] head() /var/www/doya/ordisky/wp-includes/http.php:204
[0x00007f973aa21000] wp_remote_head() /var/www/doya/ordisky/wp-content/plugins/wp-defender/app/behavior/utils.php:656
[0x00007f973aa20b80] determineServer() /var/www/doya/ordisky/wp-content/plugins/wp-defender/app/module/hardener/model/settings.php:155
[0x00007f973aa20980] __construct() /var/www/doya/ordisky/wp-content/plugins/wp-defender/app/module/hardener/model/settings.php:231
[0x00007f973aa20850] instance() /var/www/doya/ordisky/wp-content/plugins/wp-defender/app/module/hardener.php:30
[0x00007f973aa206d0] initRulesStats() /var/www/doya/ordisky/wp-content/plugins/wp-defender/app/module/hardener.php:20
[0x00007f973aa20630] __construct() /var/www/doya/ordisky/wp-content/plugins/wp-defender/main-activator.php:34
[0x00007f973aa20200] init() /var/www/doya/ordisky/wp-includes/class-wp-hook.php:286
[0x00007f973aa1fe90] apply_filters() /var/www/doya/ordisky/wp-includes/class-wp-hook.php:310
[0x00007f973aa1fde0] do_action() /var/www/doya/ordisky/wp-includes/plugin.php:465
[0x00007f973aa1fa90] do_action() /var/www/doya/ordisky/wp-settings.php:525
[0x00007f973aa1c970] [INCLUDE_OR_EVAL]() /var/www/doya/ordisky/wp-config.php:83
[0x00007f973aa1c770] [INCLUDE_OR_EVAL]() /var/www/doya/ordisky/wp-load.php:37
[0x00007f973aa1c1e0] [INCLUDE_OR_EVAL]() /var/www/doya/ordisky/wp-blog-header.php:13
[0x00007f973aa1c0c0] [INCLUDE_OR_EVAL]() /var/www/doya/ordisky/index.php:17
From what I can read from the source code, Defender don’t recognize my webserver and then makes a request to the website to get header information from the webserver.
Could this lead to an infinite loop? Defender makes request, and on request tries to fetch headers from webserver, and on and on and on….
I can see a bunch of these request with just a couple of seconds interval.
This will slow down all other request because my php-pool only allows a set number of active connection and when all are taken the server need to wait for a free spot. Thus, 10 seconds for TTFB.