网站的图像存储和 CDN
目前我正在寻求将我的网站图像移动到存储服务。我有两个用 PHP 和 ASP.NET 开发的网站。
使用 Amazon S3 服务,我们可以托管所有图像和视频以提供网页服务。但是当我们想要提供图像时,使用 S3 服务有一些限制。
- 如果网站需要与原始图像大小不同的不同缩略图,那就很困难。我们还需要订阅 EC2。虽然从 S3 到 EC2 的数据传输是免费的,但在处理图像调整大小操作之前,数据传输需要时间。
- 上传 zip 格式的文件数量并在 S3 中解压缩无法减少上传数量。
- 如果我们想转移到另一个提供商,则无法从 S3 下载多个文件。
- S3 中的图像名称区分大小写。如果图像名称与请求不匹配,则不会加载图像。
在所有这些中,第一个非常重要,因为图像调整大小是一般要求。
哪个提供商最适合实现我的目标。我可以仅出于图像托管的目的而迁移到 Google AppEngine,还是有其他供应商可以提供上述服务?
Currently I am looking to move my websites images to a storage service. I have two websites developed in PHP and ASP.NET.
Using Amazon S3 service we can host all our images and videos to serve web pages. But there are some limitations using S3 service when we want to serve images.
- If website needs different thumbnail images with different sizes from original image, it is tough. We have again need to subscribe for EC2 also. Though the data transfer from S3 to EC2 is free, it takes time for data transfer before processing image resize operation.
- Uploading number of files in zip format and unzipping in S3 is not possible to reduce number of uploads.
- Downloading multiple files from S3 is not possible in case if we want to shift to another provider.
- Image names are case sensitive in S3. Which will not load images if image name does not match with request.
Among all these first one is very important thing since image resize is general requirement.
Which provider is best suitable to achieve my goal. Can I move to Google AppEngine only for the purpose of image hosting or is there any other vendor who can provide above services?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我偶然发现了一家名为 Cloudinary 的好公司,它提供 CDN 图像存储服务 - 他们还提供了多种允许飞行图像处理(当您讨论不同大小的缩略图时,裁剪将主要关注您)。
我不确定他们如何在网站速度增强方面与 maxcdn 等其他公司竞争,但从我所看到的 - 他们在图像处理方面有更多选择。
I've stumbled upon a nice company called Cloudinary that provides CDN image storage service - they also provide a variety of ways that allow on the fly image manipulation (Cropping will mainly concern you as you we're talking about different sized thumbnails).
I'm not sure how they compete with other companies like maxcdn in site speed enhancement but from what I can see - they have more options when it come to image manipulation.
S3 确实很慢而且也不是分布式的。相比之下,Cloudfront 也是您可以获得的最慢且最昂贵的 CDN 之一。唯一的好处是,如果您已经在使用其他 AWS,您将收到一张账单。
我在博客中介绍了不同的 CDN 并进行了一些测试:
http://till.klampaeckel.de/blog/archives /100-Shopping-for-a-CDN.html
至于设置,我建议使用原始拉取。因此,您自己托管图像,CDN 会在第一次请求时请求图像的副本。
这也意味着您可以使用脚本“动态”生成图像,因为它们只会被拉取一次左右。只需设置适当的缓存标头即可。然后,图像将被缓存,直到您清除 CDN 的缓存。
华泰
S3 is really slow and also not distributed. Cloudfront in comparison is also one of the slowest and most expensive CDNs you can get. The only advantage is that if you're using other AWS already you'll get one bill.
I blogged about different CDNs and ran some tests:
http://till.klampaeckel.de/blog/archives/100-Shopping-for-a-CDN.html
As for the setup, I'd suggest something that uses origin-pull. So you host the images yourself and the CDN requests a copy of it the first time it's requested.
This would also mean you can use a script to "dynamically" generate the images because they'll be pulled only once or so. Just have to set appropriate cache headers. The images would then be cached until you purge the CDN's cache.
HTH
我刚刚遇到 CloudFlare - 据我从他们的网站了解,你不需要做任何对您的网站的更改。显然,您所需要做的就是更改 DNS 设置。甚至提供免费选项。
I've just come across CloudFlare - from what I understand from their site, you shouldn't need to make any changes to your website. Apparently all you need to do is change your DNS settings. Even provides a free option.
如果您使用 EC2,那么 S3 是您的最佳选择。 “最佳实践”是简单地预渲染所有尺寸的图像并使用不同的名称上传。即:
Digg、Twitter(很久以前,也许 twimg 没有……)和许多其他公司都在使用这种做法。
它可能并不理想,但它是最快、最简单的方法。就切换到另一个提供商而言,您可能不会这样做,因为无论如何传输所有文件的工作量很大。如果您有 1,000,000 张图像或 3,000,000 张图像,您仍然有许多兆字节的文件。
幸运的是,S3 有导入/导出服务。您可以向他们发送一个空硬盘,他们将对其进行格式化并下载您的数据,只需支付少量费用。
就您对区分大小写的担忧而言,您找不到不区分大小写的提供商。如果您的代码编写正确,您将把所有名称规范化为大写或小写,或者使用某种为您处理大小写的 Base 64 ID 系统。
总而言之,S3 将为您提供最好的“物有所值”,并且如果您想加快速度,它还提供 CloudFront 支持。由于原因 3 和 4 而不使用 S3 是无稽之谈,因为它们可能适用于您所在的任何地方。
If you're using EC2, then S3 is your best option. The "best practice" is to simply pre-render the image in all sizes and upload with different names. I.e.:
This practice is in use by Digg, Twitter (once upon a time, maybe not with twimg...), and a host of other companies.
It may not be ideal, but it's the fastest and most simple way to do it. In terms of switching to another provider, you'll likely not do that because of the amount of work to transfer all of the files anyway. If you've got 1,000,000 images or 3,000,000 images, you've still got many megabytes of files.
Fortunately, S3 has an import/export service. You can send them an empty hard drive and they'll format it and download your data to it for a small fee.
In terms of your concern about case sensitivity, you won't find a provider that doesn't have case sensitivity. If your code is written properly, you'll normalize all names to uppercase or lowercase, or use some sort of base 64 ID system that takes care of case for you.
All in all, S3 is going to give you the best "bang for your buck", and it has CloudFront support if you want to speed it up. Not using S3 because of reasons 3 and 4 is nonsense, as they'll likely apply anywhere you go.