Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will too many files storing in one folder make HTTP request for one of them slow?

Tags:

http

php

windows

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

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?

like image 330
dotslashlu Avatar asked Oct 10 '22 07:10

dotslashlu


1 Answers

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.

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.

EDIT: 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.

like image 189
tskuzzy Avatar answered Oct 13 '22 01:10

tskuzzy