什么是存储和访问图像的最有效的方法 [英] What is the most efficient way to store and access images

查看:96
本文介绍了什么是存储和访问图像的最有效的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个项目,它必须在服务器上存储数以万计的图像,并让用户访问它们。我需要最有效的方法来存储这些图像和检索它们。此外,我需要有关我应该选择哪种技术的信息。我还没有开始这个项目。所以,我在PHP w / CodeIgniter和Ruby on Rails之间思考。

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.

推荐答案

存储图像时,为其生成校验和有助于检查图像是否重复,只存储一个实例。

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.

文件夹的组织很重要,因为文件系统寻找图像就像一个相对数据库,一个文件夹中的许多图像将是一个问题。当您已经实现校验和时,您可以轻松地从校验和创建目录结构,例如MD5的前两个字符将是第一级子文件夹,两个后续字符将是第二级。其余的字符将是图像文件本身。如果要允许重复,在校验和后,您可以为图像名称添加后缀。

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.

关于存储 - 您应该有一个单独的静态内容服务器,像nginx或lighttpd来忘记性能问题。 HDD应设置为aa RAID阵列。

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.

编辑:
对于您的web项目要求,只需存储有关数据库中的图像的信息,到图像存储本身。

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

这篇关于什么是存储和访问图像的最有效的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆