简体   繁体   English

Amazon EC2-图片上传

[英]Amazon EC2 - picture upload

I have a web application and I'm moving the picture upload from my machines to EC2 machines. 我有一个Web应用程序,我正在将图片上传从我的机器上移到EC2机器上。 Basically I will have a web application where the user can send a jpg file through HTTP post. 基本上,我将有一个Web应用程序,用户可以在其中通过HTTP发布发送jpg文件。

  1. User upload the jpg file to the EC2 instance 用户将jpg文件上传到EC2实例
  2. Several sizes of the image are created (about 9 of them) 创建了几种尺寸的图像(大约有9种)
  3. All the sizes are uploaded to S3 所有尺寸都上传到S3

Any ideas on which machine would best be suited for this job ? 关于哪种机器最适合该工作的任何想法? I was thinking of the c3.large instance http://aws.amazon.com/ec2/pricing/ 我在想c3.large实例http://aws.amazon.com/ec2/pricing/

Do you guys have any other suggestions ? 你们还有其他建议吗? Thanks 谢谢

Tough to say, going to depend on the volume of images coming in. Any of the instances (except the micro IMO), would do what you want if the volume of users was matched to the instance size, but we don't know the # of users. 很难说,这取决于传入的图像量。如果用户数量与实例大小匹配,则任何实例(微型IMO除外)都可以满足您的要求,但是我们不知道用户数。

Couple of suggestions, instead of trying to guess the correct size, setup your application the way AWS intends it to be used - automatically scalable, so you don't have to guess, or worry about what to do if suddenly your system becomes very popular. 几个建议,而不是尝试猜测正确的大小,而是按照AWS打算使用的方式设置应用程序-自动可伸缩,因此您不必猜测,也不必担心如果系统突然变得非常流行怎么办。

Consider building in the ability for your system to respond to higher volumes by spinning up more instances as they are needed, instead of paying for a single machine that is bigger than you need 95% of the time so that that 5% of the time when the volume spikes you have the extra capacity to meet your need. 考虑通过增加需要的实例数量来增强系统响应更大容量的能力,而不是为一台大于您所需时间的机器付费(95%的时间)音量峰值可以满足您的需求。 This will require more work upfront, but may save your butt and money down the road. 这将需要更多的前期工作,但可能会节省您的屁股和金钱。

Some general thoughts: 一些一般的想法:

  • When a user posts an image to your app, put a message into a 'work queue'. 当用户将图像发布到您的应用程序时,将一条消息放入“工作队列”。 (SQS) (SQS)
  • Have a worker machine watch the SQS queue for 'work to do' (the resizing your images) 让工作人员机器在SQS队列中查看“要做的工作”(调整图像大小)
  • Build in autoscaling metrics that watch the size of the SQS queue and spin up new instances if the backlog starts to get big (consider using spot instances to save money). 内置自动缩放指标,以监视SQS队列的大小,并在积压开始变大时启动新实例(考虑使用竞价型实例以节省资金)。
  • Save your processed images to S3, instead of your ec2 instance - offload that storage and bandwidth to where it is going to be cheaper, faster and more redundant and not dependent on ephermeral EC2 instances. 将处理后的图像保存到S3中,而不是ec2实例中-将存储和带宽转移到便宜,更快,冗余更多的位置,而不依赖于EC2实例。
  • Consider using cloudfront to deliver your s3 images for better performance worldwide (if applicable). 考虑使用Cloudfront交付s3映像,以便在全球范围内获得更好的性能(如果适用)。
  • Shut down instances as your SQS queue gets smaller to save money, but don't shut them down to fast. 随着您的SQS队列变小以节省资金,请关闭实例,但不要快速关闭它们。 Once they spin up, you pay for the whole hour, so keep that in mind. 一旦它们旋转起来,您就需要全天付钱,因此请记住这一点。

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

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