Public user page is slow for users with "many" requests #8204
Labels
f:user-profiles
improvement
Improves existing functionality (UI tweaks, refactoring, performance, etc)
performance
x:france
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.
The text was updated successfully, but these errors were encountered: