Re: scalable web gallery

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 10, 2008 at 3:46 AM, paragasu <paragasu@xxxxxxxxx> wrote:
>
> the plan is saving the image metadata in the database and keep the
> original files
> in a folder. while it work perfectly, i afraid how many files 1
> directory can keep.
> in 1 year, there going to be more than 1000 photo uploaded or more.
> sure it bring problem
> to maintain thus files.

    I wrote a gallery script in about two hours last year, and in the
first week alone, over 7,000 images were uploaded by fans of the band
for whom I wrote it.  It had full administrative control, voting, and
user authentication requirements, in addition to some other stuff, all
written from scratch in that time.

    So an existing system that's been around for a while would
*certainly* be able to handle a mere 1,000 in a year.  No worries
about that.

    And for the record, in the "olden days," there was a limit of
about 2048 files per directory, back when no one thought there would
ever be a need for nearly that many files.  Then, with improved
filesystems, the limit was rumored to be another magic number: 65535.
That depended on the operating system, filesystem, and the kernel.  I
think (but don't quote me on this) that BeOS had the 65535 limit.

    Now, on an ext3 filesystem (we're not counting ReiserFS because
(1) I was never a fan, and (2) he might kill me if I say something
bad!  8^O) you're okay with hundreds of thousands of files per
directory.  ls'ing will be a bit of a pain in the ass, and if you're
in Bash, you probably don't want to double-TAB the directory, but all
in all, you'll be okay.

    Still, I'd create 16 subdirectories under the images directory:
0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f.  Then name the file as an MD5 hash of
the image uploaded, and place it in the directory matching the first
character of the new file name.

-- 
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux