What is the most efficient way to store and access

2019-09-03 11:06发布

I am working on a project which has to store tens and thousands of images on a server and let the users access them. I need the most efficient method to store these images and to retrieve them. Also, I need information about which technology I should opt. I haven't started the project yet. So, I am thinking between PHP w/ CodeIgniter and Ruby on Rails.

The site hosts many images that are uploaded only by the Authors of the content, and not by the users.

3条回答
小情绪 Triste *
2楼-- · 2019-09-03 11:23

If you use PHP, you could always use some of the software available for image storage and manipulation, like Gallery, or phpThumb, or at least, have a look at their code so you don't have to reinvent the wheel. Having said that, I am sure there must exist similar libraries for ruby.

查看更多
够拽才男人
3楼-- · 2019-09-03 11:31

Look a bit around, this is very common question. But these links might help you

You may want to research more

Edit#1: One suggestion, just don't store your images in database.

查看更多
萌系小妹纸
4楼-- · 2019-09-03 11:40

When you store images, it is beneficial to generate a checksums for them so you can check if images are duplicated and store only one instance.

Organization of folders is important as file system seeks images just like a relative database and many images in one folder would be a problem. When you have already implemented checksumming, you could easily create a directory structure from checksum, for example first two characters of MD5 would be 1st level of subfolders and two next characters would be a second level. The remaining characters would be the image file itself. If you want to allow duplicates, after checksum you can add a suffix for image name.

Regarding storage - you should have a separate static content server with fast and specialized web server like nginx or lighttpd to forget about performance issues. HDD should set up as a a RAID array.

EDIT: For your web project requirements, just store information about images in the database, used framework is not relevant to image storage itself.

查看更多
登录 后发表回答