Public user page is slow for users with "many" requests
Opened this issue · 1 comments
Ma Dada experienced several OOM crashes in the past few days, which I traced down to the /user/<username>
page for one user with over 40k requests.
Specifically, when loading the public user page, this block calls User.safe_previous_names
which generates about 7 SQL queries per FOI request authored by the user.
In our extreme case, this meant the https://madada.fr/user/open_knowledge_france page would take 110-150 seconds to load on a 12 core/64GB RAM machine, and it often crashed on the production server.
Loading the user page on WDTK for a random user with 650+ requests takes ~10s, which seems like a waste as the conclusion of all these queries is "no previous names" 😅 Put another way, as bots visit all user pages, and the total number of requests is over 1M, my guestimate is that this method wastes about 4.2 hrs of CPU time for each crawl of your users 💩 (the method result does not seem to get cached either, so this could possibly be used to DoS a site)
I have commented out the section in our template for now, but I'll try to improve the code to keep the functionality for the few cases where it is used.
The method does not appear to be used anywhere else.
Just to note that one of the volunteers on WDTK has got in touch to report a slow-loading profile.