最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Could a large quantity of files in the uploads folder affect performance?

programmeradmin1浏览0评论

There is a site, where images are not organized into month- and year-based folders. There are more than 20 000 of images in one folder (uploads) now. When I try accessing the folder via a file browser, it notably freezes.

So, my question is: could this affect site performance?

There is a site, where images are not organized into month- and year-based folders. There are more than 20 000 of images in one folder (uploads) now. When I try accessing the folder via a file browser, it notably freezes.

So, my question is: could this affect site performance?

Share Improve this question asked May 23, 2015 at 9:42 Igor SkoldinIgor Skoldin 3911 gold badge4 silver badges14 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 3

Short Answer: No

A different question is: Will uploading a large number of files in WordPress affect performance? The answer to this: Most likely not.

Reason:

  • WordPress uses the DB to get a list of uploaded files (almost no difference for many files)
  • FTP uses the filesystem (slower for many files)

Details:

WordPress does not list the directory contents of the uploads folder, so you can dump any amount of files there without WordPress even noticing it.

When you upload a file via WordPress a new DB entry is made to your wp_posts table. WordPress only knows about the media files by looking into wp_posts, so uploading a ton of files will add more lines to that table and therefore makes SQL queries a bit slower. Though honestly the amount (20.000 entries in DB) will not have a big impact on most hosting environments. Also WordPress has optimizations at every end to make it run fast (e.g. it caches SQL results and limits the number of queried rows)

However, as you noticed: When accessing the folder via FTP it freezes. This is caused by FTP requesting a list of all files the folder, and the server takes a while to answer with a list of 20.000 filesnames. But this performance issue is not affecting WordPress itself.

Well, does it affect site performance? If you are not noticing in actual site operation then likely not, at least at your number of files.

There are performance considerations for large amounts of files. Budget hosts (which know what they are doing) typically even put in explicit limits on filesystem usage.

However in WordPress operation you are not hitting filesystem that much. The way attachments work is that paths to file (and its sizes in case of images) are stored in database. In that way there is rarely need to access (or worse - scan) filesystem just to know where the files is and point to it.

I hadn't encountered this directly, but to my knowledge the issues with large (like millions of files large) amounts of attachments in WordPress start to exhibit on database querying level before filesystem. But then I would guess people with millions of files would already have server/filesystem setup capable of handling it.

Yes. Too many files or directories in one directory can impact site performance badly, though 20,000 isn't too bad, your really start to see problems over 100,000+

Make sure in your WordPress settings you've set media to distribute uploads into date-named folders (such as 2019/01/), but be aware WordPress appears to use file creation date to determine which folder it puts a file in, so you may need to override that if your users are uploading a lot of files created in a single date.

See https://hetzner.co.za/help-centre/website/inode-usage/ for more

发布评论

评论列表(0)

  1. 暂无评论