Hello,
I tried to generate the same behavior in a test environment and apparently the slowness, in fact, has to do with the timeout of the unsuccessful attempt to bind with LDAP. Unfortunately this timeout affects users who are not authenticated by LDAP and in my case, we had a spike in login attempts added to that, which seems to have compromised the entire system.
I am still in doubt about why other Moodle tasks are slow because of this? Is it related to CRON?
As a way around this, I thought about increasing the "task_scheduled_concurrency_limit" or finding a way to reduce the LDAP bind timeout
tail -f php_errors.log
[24-Sep-2020 16:09:59 America/Sao_Paulo] [ENROL LDAP] Inscrever usuário 'prof' no curso 'MOODLE - ESTRATÉGIAS PEDAGÓGICAS E POSSIBILIDADES - TESTE' (id 267)
[24-Sep-2020 16:11:01 America/Sao_Paulo] [ENROL LDAP] Desinscrever usuário 'prof' do curso 'MOODLE - ESTRATÉGIAS PEDAGÓGICAS E POSSIBILIDADES - TESTE' (id 267)
[24-Sep-2020 16:12:12 America/Sao_Paulo] [ENROL LDAP] Inscrever usuário 'prof' no curso 'MOODLE - ESTRATÉGIAS PEDAGÓGICAS E POSSIBILIDADES - TESTE' (id 267)