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

Posted on 2006-04-20
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
    LVL 15

    Accepted Solution

    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

    I aggree with m1tk4.
    I'd prefer b).

    Author Comment

    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

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
    If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now