Learn how to a build a cloud-first strategyRegister Now


Do LOTS of files in a folder make webserver slower?  (apache 1.3.34)

Posted on 2006-04-20
Medium Priority
Last Modified: 2010-03-04
This is Apache 1.3.34.

I have heard too many folders or files in a folder can slow down a webserver.
(Like, thousands, 10s of thousands, in a folder.)
Is this true for Apache?

If so what is the maximum # of jpgs that should be allowed in one folder?...
What is the maximum # of FOLDERS that should be allowed in one folder?

No browsing or indexing or ftping on the folder.
Only jpgs moved into folder by php and displayed in html.

Thank you.
Question by:boise2004
  • 2
LVL 15

Accepted Solution

m1tk4 earned 320 total points
ID: 16496260
It's true for any server, because it makes the filesystem slower. Basically, the more files/folders you have in a single directory, the slower fopen()s are going to be - doesn't matter if they are done by Apache, PHP or else.

The solutions are:

a) switch to a filesystem that is faster at handling large directories (ReiserFS, JFS)

b) organize your files in subdirectories, like pics/012345.jpg woud become pics/012/012345.jpg for example.
LVL 27

Expert Comment

ID: 16496285
I aggree with m1tk4.
I'd prefer b).

Author Comment

ID: 16500493
thanks for the comments -- do you have any idea of how many you can stash in a directory before it becomes a problem?  

by the way, no fopens() done on the files, just move_uploaded_file to dir then served up in html pages.
LVL 15

Expert Comment

ID: 16500666
When you serve the file in html page it does a fopen(), it's just not PHP's fopen(). Moving the files is also slow because most of the time is consumed in reading the directory, and it's done both on fopen() and file moves.

In EXT2/3 you don't have the max number of files in a directory, you have a total maximum number of files and directories (inodes) IN A VOLUME. This ratio is defined when you create a volume by the number of kb you allocate per node. It's quite HIGH.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month20 days, 23 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question