本文介绍了我可以在目录中放置多少个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我关在一个目录中有多少个文件?如果是这样的话,目录中有多少文件太多了,文件太多会带来什么影响? (这是在Linux服务器上。) 背景:我有一个相册网站,上传的每个图片都被重新命名为一个8位数字的ID(比如说, a58f375c.jpg)。这是为了避免文件名冲突(例如,如果上传大量IMG0001.JPG文件)。原始文件名和任何有用的元数据存储在数据库中。现在,我在图像目录中有大约1500个文件。这使得列出目录中的文件(通过FTP或SSH客户端)需要几秒钟。但是除此之外,我看不出有什么影响。特别是,对于向用户提供图像文件的速度似乎没有任何影响。 我曾经想过要减少图片的数量制作了16个子目录:0-9和af。然后,我会根据文件名的第一个十六进制数字是什么,将图像移动到子目录中。但是我不确定有什么理由这样做,除了偶尔通过FTP / SSH列出目录。 解决方案 FAT32 : 文件最大数量:268,173,300 每个目录的最大文件数量:2 16 = 1(65,535) li> 最大文件大小:2  GiB  -   1没有 LFS ,4   -   1 with NTFS : 最大文件数量:2 32 -   1(4,294,967,295) 最大文件大小 执行:2 44 -   2 6 (16  TiB  64  KiB)理论值(16  -   64  KiB) 最大批量大小 执行:2 32   -   1 群集(256个TiB   64  KiB) 理论:2 -   - 1个群集 ext2 : 最大文件数量:10 18 每个目录的最大文件数量:〜1.3×  10 20 (性能问题超过10,000) 16  GiB(块大小为1的KiB) 256  GiB(块大小为2  KiB ) 2  TiB(块大小为4的KiB) 2 TiB(块大小为8的KiB) $ b 最大交易量 4  TiB (块大小为2 KiB) liB TiB(块大小为4的KiB) 8 TiB 32  TiB(块大小为8的KiB) ext3 : 文件的最大数量:min(volumeSize  /  2 13 ,  numberOfBlocks) 最大文件大小:与ext2相同 最大卷大小:与ext2相同 ul> ext4 : 最大文件数量:2 32 -   1(4,294,967,295) 每个目录的最大文件数量:无限制 最大文件大小:2 44 -   1个字节(16  TiB  最大卷大小:2 48   -   1个字节(256  TiB  / li> Does it matter how many files I keep in a single directory? If so, how many files in a directory is too many, and what are the impacts of having too many files? (This is on a Linux server.)Background: I have a photo album website, and every image uploaded is renamed to an 8-hex-digit id (say, a58f375c.jpg). This is to avoid filename conflicts (if lots of "IMG0001.JPG" files are uploaded, for example). The original filename and any useful metadata is stored in a database. Right now, I have somewhere around 1500 files in the images directory. This makes listing the files in the directory (through FTP or SSH client) take a few seconds. But I can't see that it has any effect other than that. In particular, there doesn't seem to be any impact on how quickly an image file is served to the user.I've thought about reducing the number of images by making 16 subdirectories: 0-9 and a-f. Then I'd move the images into the subdirectories based on what the first hex digit of the filename was. But I'm not sure that there's any reason to do so except for the occasional listing of the directory through FTP/SSH. 解决方案 FAT32:Maximum number of files: 268,173,300Maximum number of files per directory: 216 - 1 (65,535)Maximum file size: 2 GiB - 1 without LFS, 4 GiB - 1 withNTFS:Maximum number of files: 232 - 1 (4,294,967,295)Maximum file sizeImplementation: 244 - 26 bytes (16 TiB - 64 KiB)Theoretical: 264 - 26 bytes (16 EiB - 64 KiB)Maximum volume sizeImplementation: 232 - 1 clusters (256 TiB - 64 KiB)Theoretical: 264 - 1 clustersext2:Maximum number of files: 1018Maximum number of files per directory: ~1.3 × 1020 (performance issues past 10,000)Maximum file size16 GiB (block size of 1 KiB)256 GiB (block size of 2 KiB)2 TiB (block size of 4 KiB)2 TiB (block size of 8 KiB)Maximum volume size4 TiB (block size of 1 KiB)8 TiB (block size of 2 KiB)16 TiB (block size of 4 KiB)32 TiB (block size of 8 KiB)ext3:Maximum number of files: min(volumeSize / 213, numberOfBlocks)Maximum file size: same as ext2Maximum volume size: same as ext2ext4:Maximum number of files: 232 - 1 (4,294,967,295)Maximum number of files per directory: unlimitedMaximum file size: 244 - 1 bytes (16 TiB - 1)Maximum volume size: 248 - 1 bytes (256 TiB - 1) 这篇关于我可以在目录中放置多少个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-16 04:33
查看更多