Opening the Media Library in the Gallery block causes server overload when there are a lot of images uploaded to the website #28563
Labels
[Block] Gallery
Affects the Gallery Block - used to display groups of images
[Feature] Media
Anything that impacts the experience of managing media
[Status] In Progress
Tracking issues with work in progress
[Type] Bug
An existing feature does not function as intended
Description
I have 110k images uploaded to my website.
Opening the Media Library in the Gallery block causes server overload when there are a lot of images uploaded to the website.
Images load normally at first, but the entire site is very slow for all users, and finally starts throwing 524 Timeout errors. In the network tab in dev tools, I found that in the background some request to admin-ajax.php is pending, which contains such data:
In the Image block and on the Media page, this problem does not occur.
Perhaps it's because of this arg:
query[posts_per_page]: -1
I checked on a clean WordPress installation by uploading several thousand images and then opening the Media Library in the Gallery block and this query has a large TTFB. The more images the longer TTFB. It also causes very high CPU usage.
Step-by-step reproduction instructions
Upload several thousand images
Add a new post and a Gallery (not Image!) block inside
Click "Media Library" in the Gallery block
The CPU consumption on the server will increase and the entire website will start to run slowly
Expected behaviour
There shouldn't be a request that puts so much load on the server when there are a lot of images uploaded.
Actual behaviour
The website runs very slowly after calling this request and finally throws timeouts. The website is unusable for several minutes. This makes it very difficult to use WordPress because galleries are often used on my site.
Screenshots or screen recording (optional)
WordPress information
The text was updated successfully, but these errors were encountered: