Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filesystem slow read behavior, possible errors #9

Closed
ChezRD opened this issue May 15, 2014 · 1 comment
Closed

filesystem slow read behavior, possible errors #9

ChezRD opened this issue May 15, 2014 · 1 comment

Comments

@ChezRD
Copy link

ChezRD commented May 15, 2014

point:
files in one directory cannot be more than 100k or something. filesystem will stuck on read this directory. even delete one file can stop the system

anyway solution:
add at least 3 dir levels inner based on image name or other algorithm to prevent this type of errors

as example http://shots.m18.ru
but we use nginx to send static files by pattern as address to image is like domain/image/longlonglonghash.png
when real file not under root/image but under next directory files/s/o/m/e/longlonglonghash.png

@juggl3r
Copy link

juggl3r commented Jul 16, 2014

or for easier way to sort the files you can do several steps of splitting like 'extension' then first 2 characters
example :
1- 78805a221a988e79ef3f42d7c5bfd418.png
/files/png/7/8/78805a221a988e79ef3f42d7c5bfd418.png

2- 943359f44dc87f6a1679c987280e8dc7.jpg
/files/jpg/9/4/943359f44dc87f6a1679c987280e8dc7.jpg

this way u wont need db's and extra resource consumption just a tiny line that will read the filename and return the path

$ext = end(explode('.', $filename));
$imgfile = /files/$ext/$filename[0]/$filename[1]/$filename

and for the upload it should be pretty much the same where u check if the directory of the first chars exist or if u want to create empty directories to save the mkdir time its up to u

cheers

ziggi added a commit that referenced this issue Oct 12, 2014
@ziggi ziggi closed this as completed Oct 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants