简体   繁体   中英

Amazon EC2 - picture upload

I have a web application and I'm moving the picture upload from my machines to EC2 machines. Basically I will have a web application where the user can send a jpg file through HTTP post.

  1. User upload the jpg file to the EC2 instance
  2. Several sizes of the image are created (about 9 of them)
  3. All the sizes are uploaded to 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/

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.

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.

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. 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)
  • Have a worker machine watch the SQS queue for 'work to do' (the resizing your images)
  • 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).
  • 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.
  • Consider using cloudfront to deliver your s3 images for better performance worldwide (if applicable).
  • Shut down instances as your SQS queue gets smaller to save money, but don't shut them down to fast. Once they spin up, you pay for the whole hour, so keep that in mind.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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