-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extremely slow _wp_handle_upload() #373
Comments
~300ms sound right if your server is located in a different region than the S3 Bucket. Not sure why it would take 2.6 seconds, it depends on how "chatty" the protocol is. |
I experience a similar issue using WordPress 5.3. As far as I can tell, they changed the logic behind |
@asretux : ouch, if that's the case it's a serious problem for scalability! |
It looks like this may be due to https://core.trac.wordpress.org/changeset/46822 - we've not yet replicated this, but from reading the code seems fairly obvious. This might need changing in WordPress core. We'll continue to look into this issue. |
The same issue. Scanning a directory with 208614 files takes over 90s:
Is there a workaround for this if I don't want to override |
WorkaroundPlace every new uploaded file to a unique name subdirectory. Then the slow
|
@jakubkol I don't think creating a new directory for each file, in terms of scalability, would be a good workaround. On sites with thousands of uploads per day, like a news magazine portal, the number of subdirectories per month would surpass the threshold number for optimal performance. |
Source: https://docs.aws.amazon.com/AmazonS3/latest/user-guide/using-folders.html |
1.3 million in that directory:
|
Mmm this is a good issue! Indeed, the The logic / use case WordPress is protecting against is valid, and I don't see a way of achieving the same algorithm without doing some kind of scan on the currently uploaded files. However, I think there is a significant performance improvement we can make by adjusting the The challenge is how to appropriately hook in this behavior. I don't see any other lower level hooks in Core, and I'd rather be able to fix this without needing a patch to WordPress. If we can provide a copied-but-modified version of |
Another larger hack, which might work would be to inspect |
Please for give me for what I have done. Fixes #373.
Mmm ok, after trying the above approach, the filters via |
I've also opened a Trac ticket with patch for a potential Core change: https://core.trac.wordpress.org/ticket/50587 |
Patch has been committed: https://core.trac.wordpress.org/changeset/48369 @joehoyle can you prepare the filter for this? We can add it immediately even though it won't take effect until the next major WP version is out, and then leave the (now-inert) backtrace hack for a few versions afterwards. |
This has been fixed in version 2.2.2 of S3 Uploads. |
Hey guys,
Love this plugin - been using it for years.
I've stumbled across a problem with
_wp_handle_upload()
where it's taking way too long to handle the uploaded file. I discovered this when trying to import attachments programmatically withmedia_handle_sideload()
.I've wrote a small script on a fresh WP install to test this out with an 12KB image.
Which outputs:
If I disable S3-Uploads plugin I get:
Just to check I ran
wp s3-uploads verify
and it verified in around 2-300ms.Not sure if this is expected or not - would appreciate any input you guys might have on this.
The text was updated successfully, but these errors were encountered: