Extreme load when uploading photos and many visitors #2007

Closed
opened 2026-10-05 01:03:48 +02:00 by adam · 0 comments
Owner

See https://piwigo.org/forum/viewtopic.php?id=34021

As described a long time ago (2017) on https://piwigo.org/forum/viewtopic.php?id=28338 there is a performance issue when you have: many photos/albums + frequent user_cache reset + many simultaneous anonymous visitors. With #1367 and the "lounge" we reduced the frequency of user_cache reset because the reset occurs only for a set of uploaded photos, not each photo individually.

First, if you upload photos one by one, the lounge has no effect. That's a first "problem".

Secondly, when the user_cache is reset, if you have 10 pages opened at the same time by user guest (anonymous visitor), the user_cache for guest user is regenerated 10 times in parallel. And of course, the concurrent compute enters into conflict. Instead of taking 1 or 2 seconds to compute, the user_cache may take 40 to 80 seconds (in an example I worked on yesterday). The MySQL server gets stuck and the whole Piwigo becomes awfully slow.

The solution I've worked on is to use the new pwg_unique_execution system (introduced for send_piwigo_infos) : only the first visit triggers the user_cache generation while other requests go into sleep as long as the user_cache is not rebuilt. Result has been crazy efficient 🥳

See https://piwigo.org/forum/viewtopic.php?id=34021 As described a long time ago (2017) on https://piwigo.org/forum/viewtopic.php?id=28338 there is a performance issue when you have: many photos/albums + frequent `user_cache` reset + many simultaneous anonymous visitors. With #1367 and the "lounge" we reduced the frequency of `user_cache` reset because the reset occurs only for a set of uploaded photos, not each photo individually. First, if you upload photos one by one, the lounge has no effect. That's a first "problem". Secondly, when the `user_cache` is reset, if you have 10 pages opened at the same time by user guest (anonymous visitor), the `user_cache` for guest user is regenerated 10 times in parallel. And of course, the concurrent compute enters into conflict. Instead of taking 1 or 2 seconds to compute, the `user_cache` may take 40 to 80 seconds (in an example I worked on yesterday). The MySQL server gets stuck and the whole Piwigo becomes awfully slow. The solution I've worked on is to use the new `pwg_unique_execution` system (introduced for `send_piwigo_infos`) : only the first visit triggers the `user_cache` generation while other requests go into sleep as long as the `user_cache` is not rebuilt. Result has been crazy efficient 🥳 <!-- github-sync-id:2779770910 -->
adam closed this issue 2026-10-05 01:03:48 +02:00
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#2007