简体   繁体   English

S3直接上传性能

[英]S3 direct upload performance

So I'm faced with a choice of whether to implement a direct upload to S3 or to proxy images through my servers and then to S3. 因此,我面临着选择是实现直接上传到S3还是先通过服务器代理映像再到S3的选择。

I do need to process images once they are uploaded, creating thumbs and different versions. 上载图像后,我确实需要对其进行处理,以创建缩略图和其他版本。

So, in short what I would like to know is which approach is better, from those that might have done this before. 因此,简而言之,我想知道哪种方法更好,而以前可能已经做过。

Choice 1. Direct upload to S3 选择1.直接上传到S3

  • User uploads to S3 用户上传到S3
  • Background worker downloads the new image from S3 后台工作者从S3下载新图像
  • Image is processed 图像已处理
  • Images are uploaded to S3 图像上传到S3

Choice 2. Upload through servers 选择2.通过服务器上传

  • User uploads to server 用户上传到服务器
  • Image is processed 图像已处理
  • Images are uploaded to S3 图像上传到S3

Looking at this, it would seem that uploading directly to S3 is actually slower than through my servers first. 以此看来,直接上传到S3似乎比先通过我的服务器慢。 However, does the load that initial upload places on server outweigh the extra download step when going directly to S3? 但是,直接转到S3时,初始上载在服务器上的负载是否超过了额外的下载步骤?

Also are there additional factors involved, such as network performance in each case and similar? 是否还涉及其他因素,例如每种情况下的网络性能以及类似情况?

Regards to performance, uploading directly to S3 is a better solution. 关于性能,直接上传到S3是更好的解决方案。 The reason is that S3 is highly scalable, which means: if you use one thread to upload files to S3, the speed is 1M/s, if you use 10 threads, the speed will be about 10M/s. 原因是S3具有高度可伸缩性,这意味着:如果使用一个线程将文件上传到S3,则速度为1M / s,如果使用10个线程,则速度约为10M / s。

For you problem, if you have a lot of users uploading files at the same time, S3 can handle these requests with less performance personality.As uploading files directly to the server, it requires your server can handle many requests at the same time, if your implementation is salable, it may have a chance to beat S3 on performance. 对于您的问题,如果您有大量用户同时上传文件,则S3可以以较低的性能个性来处理这些请求。由于直接将文件上传到服务器,因此要求您的服务器可以同时处理许多请求您的实现是可销售的,它可能有机会在性能上超过S3。

But solution 1 has more costs as it has more transactions, and also data transfer out. 但是解决方案1的成本更高,因为它具有更多的事务,并且还传输了数据。

One issue with uploading directly to S3 is that you're uploading to the location of the bucket, whereas your servers may be distributed across multiple locations throughout the world. 直接上传到S3的一个问题是您要上传到存储桶的位置,而您的服务器可能分布在世界各地的多个位置。 (For example, if you're running your servers in multiple EC 2 regions). (例如,如果要在多个EC 2区域中运行服务器)。 In that case, you find you have lower latency (higher transfer rates) going to your server than going to S3 directly. 在这种情况下,与直接进入S3相比,您进入服务器的等待时间(更高的传输速率)更低。

Also, there may not be transfer out charges from S3 if you're transferring data to a server running on EC2 in the same region. 另外,如果要将数据传输到同一区域中运行在EC2上的服务器,则S3可能不会产生转出费用。 Otherwise Matt's right - you'll pay anywhere from $0.02 - $0.25 / GB for transferring data from S3. 否则,Matt拥有权利-从S3传输数据,您将支付$ 0.02-$ 0.25 / GB的费用。

Mike 麦克风

I was a member of a big project using S3 storage. 我是一个使用S3存储的大型项目的成员。

S3 upload is not 100% perfect officially. S3上传在官方上不是100%完美。

It is very important that whether you choose one of them you mentioned. 是否选择您提到的其中一项非常重要。 Because each one has different benefits and drawbacks. 因为每个人都有不同的利弊。

You should choose first one if you want to make overload in client side instead of server side because of some reason like 1. Server is low spec or busy 2. There are huge upload files in huge clients side. 如果由于某种原因(例如1.服务器规格低或繁忙),要在客户端而不是服务器端进行过载,则应选择第一个。2.大型客户端中有大量上传文件。 3. Customer want to know the result of upload immediately and want to do next action with uploaded files. 3.客户想立即知道上传的结果,并想对上传的文件进行下一步操作。 But you should make strong error handling logins in upload program. 但是您应该在处理上传程序中的登录时出错。 Otherwise, you might be suffered from customer's complain. 否则,您可能会遭受客户投诉的困扰。

.

You should choose second one if you want to have higher reliability of uploading process in terms of structure or development environment. 如果要在结构或开发环境方面具有更高的上载过程可靠性,则应选择第二个。 Because S3 uploading is HTTP protocol so it is very slow and sometime it may make overload in upload side. 由于S3上传是HTTP协议,因此它非常慢,有时可能会导致上传端过载。 If there are some abnormal cases in client side like stopping upload or network problem, you might get into problem handling the situation. 如果客户端出现异常情况,例如停止上传或网络问题,您可能会遇到问题。 So it is stable to upload files in server side again because error handling is essential as amazon mentioned below link. 因此,再次稳定地在服务器端上载文件是很稳定的,因为错误处理是必不可少的,如下面的链接所述。

http://docs.aws.amazon.com/AmazonS3/latest/dev/ErrorBestPractices.html The URL mentioned "When designing an application for use with Amazon S3, it is important to handle Amazon S3 errors appropriately ..." http://docs.aws.amazon.com/AmazonS3/latest/dev/ErrorBestPractices.html URL提到“设计与Amazon S3一起使用的应用程序时,重要的是适当地处理Amazon S3错误……”

Also I recommend you use just only official APIs from Amazon to handle errors instead of plug-in or S3 application. 另外,我建议您仅使用Amazon的官方API来处理错误,而不要使用插件或S3应用程序。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM