开发者

Hundreds of thousands images in web server

Im starting to develop a website that will have 500,000+ images. Besides needing a lot of disk space, do you think that the performance of开发者_C百科 the site will be affected if I use a basic folder schema, for example all the images under /images?

It will be too slow if a user requests /images/img13452.jpg?

If the performance decreases proportional to the quantity of images in the same folder, which schema/arquitecture do you recommend me to use?

Thanks in advance, Juan


Depends on the file system, depends on many other things. On common approach though is to hash the filenames and then create subdirectories, this limits the files per directory and therefore will improve performance (again depending on the FS).

Example given:

ab\
  ab.png
  lm\
     ablm.png

cd\
   cd.png
   xo\
      xo.png

You may also want to search SO for more on that topic:
https://stackoverflow.com/search?q=filesystem+performance


That's going to depend on the OS and filesystem but generally speaking you won't see a performance hit if you reference the file by the full path. Where you might have problems is with maintenance scripts and such having to read a giant directory listing. I always find it better in the long run to organize a large amount of files into some kind of logical directory structure.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜