Key points for improving efficiency of massive small file storage

Source: Internet
Author: User
In WEB development, you may often encounter file writing. The most common case is to save image files. If the number of files is small, there is no need to worry about its efficiency. However, when you have a large number of files, you will often encounter file writing in WEB development. The most common is to save image files. If the number of files is small, there is no need to worry about its efficiency. However, when you have a large number of users and images, how to store image files directly affects the efficiency of the entire image storage system.

Generally, there is a saying that, for example, if a directory contains 10000 sub-files, the speed of reading a file will be significantly reduced. Which of the following statements is true? Let's take a look:

Q: Why does too many sub-files in a single directory affect performance? For example, if a directory contains 10000 sub-files, the reading speed of a file will be obviously slow? Is this related to the file index? How to organize these nodes in the index?

A: Yes, it depends on the index. Not too many. We can see from the millions. However, we recommend that you set no more than 10000 instances.

Q: How is the relationship between the file system and the current directory? A file system that supports millions of files is nothing

A: I mean that a directory contains hundreds of thousands or millions of files without any sub-directories. in this case, it is very resource-intensive to search for this directory index.

The supported quantity is limited because the size of the directory object is limited. The directory is a container that contains the inode number corresponding to the file name and file, then, the contained entries are limited.

The speed of reading a file is not affected. However, searching is hard. The indexing mechanism of some file systems is not complete, and there is no optimization algorithm, resulting in more time for each search.


As we can see from the above Q & A, "If a directory contains 10000 sub-files, the speed of reading a file will be significantly reduced ." Is true. How can we split directories?


In fact, it is relatively simple. you can divide by month, hash, and time plus hash. as to which method to use, it depends on your project requirements...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.