存储在一个文件夹中的文件太多会导致其中一个文件的HTTP请求变慢吗? [英] Will too many files storing in one folder make HTTP request for one of them slow?

查看:946
本文介绍了存储在一个文件夹中的文件太多会导致其中一个文件的HTTP请求变慢吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站上有近百万张图片,它们存储在我的Windows服务器上的一个文件夹中。

I've got nearly a million images for my site and they are stored in one folder on my windows server.

由于直接在桌面上打开此文件夹驱动我我的CPU很疯狂我想知道是否使用我的PHP脚本为HTTP请求获取其中一个也很费力。那么,将它们分成不同的文件夹可以提高性能吗?

Since opening this folder directly on desktop drive me and my CPU crazy I am wondering that whether fetching one of them using my PHP script for a HTTP request is also laborious.
So, will separating them into different folders improve the performance?

推荐答案

不,性能不依赖于目录中的文件数。在Windows资源管理器中打开文件夹的原因很慢,因为它必须为每个文件呈现图标和各种其他GUI相关内容。

No, the performance does not depend on the number of files that are in a directory. The reason why opening the folder in Windows explorer is slow is because it has to render icons and various other GUI related things for each file.

当Web服务器获取文件时,它不需要那样做。它只是(或多或少)直接转到磁盘上文件的位置。

When the web server fetches a file, it doesn't need to do that. It just (more or less) directly goes to the location of the file on the disk.

编辑:数百万有点推动极限你的文件系统(我假设在你的情况下NTFS)。似乎目录中超过10,000个文件的任何内容都会降低您的性能。因此,不仅从性能角度来看,而且从组织角度来看,您可能还需要考虑将它们分成子目录。

Millions is kind of pushing the limits of your file system (I assume NTFS in your case). It appears that anything over 10,000 files in a directory starts to degrade your performance. So not only from a performance standpoint, but from an organizational standpoint as well, you may want to consider separating them into subdirectories.

这篇关于存储在一个文件夹中的文件太多会导致其中一个文件的HTTP请求变慢吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆