I am getting thousands of pictures uploaded by thousands of users on my Linux server, which is hosted by 1and1.com (I believe they use CentOS, but am unsure of the version).
What I used for another requirement but which can fit your needs is to use a simple convention.
Increment by 1 and get the length of the new number, and then prefix with this number.
For example:
Assume 'a' is a var which is set with the last id.
a = 564;
++a;
prefix = length(a);
id = prefix + a; // 3565
Then, you can use a timestamp for the directory, using this convention:
20092305 (yyyymmdd)
Then you can explode your path like this:
2009/23/05/3565.jpg
(or more)
It's interesting because you can keep a sort order by date, and by number at the same time (sometimes useful) And you can still decompose your path in more directories