Hi all,
We run an automatically scaling Moodle setup. We noticed recently that each instance running was generating a very large amount of CPU load on the database - even when the given instance was removed from the load balancer.
I used wireshark to compare the queries sent to the database from that instance to the queries sent from an instance without this issue. I noticed a disproportionately large (500 in 2 minutes) amount of queries of the structure:
SELECT id FROM mdl_user WHERE deleted = '0' AND mnethostid = '1' AND username = '~md5 hash~' LIMIT 0, 1Mostly with MD5 hashes, some with usernames. Most of the queries return nothing, and our usernames aren't stored as md5 hashes in the db.
1. Is it likely that this is the cause for the excess CPU load?
2. Where are these queries coming from and why?
Searching the codebase, a few possible sources of these queries are:
user/externallib.php
function update_users($users)
Line 556
cohort/externallib.php
function add_cohort_members($members)
Line 594
function delete_cohort_members($members)
Line 689
group/externallib.php
function add_group_members($members)
Line 466
function delete_group_members($members)
Line 544
Regards,
Nick