2

My application uses all 3 service layers. Recent feature request to lower the outgoing traffic gives us some uncertainties.

Say, we have a requirement to distribute the image.jpg file with CloudFront. It's all good while there's no dynamic image resizing. Now that we don't need the original size of the image all the time we pass desired variable dimension along with the query string (image.jpg?w=100&h=100).

If we would have routed CF to EC2 directly, then there would not be any problems at all. But, we should have the S3 in between, since EC2 is too small to store media materials.

So the question is - how do you push inexistent file to S3 during the request?

Thanks.

1
  • 1
    Did you actually manage to complete this setup? I am trying something similar where I want to CF to first check if a file is in S3 and if it's not there, to route the request to EC2, so the EC2 would then generate the file, return it and at the same time save it to S3 for future use. I'm trying to accomplish this with multiple origins but without luck. When the file is not in S3, CS immediately returns a 403 error instead of falling back to the next origin.
    – Jacket
    May 13, 2016 at 11:43

1 Answer 1

1

I don't think you need (or would want) to reroute the request after getting a 404 from the S3 bucket. You'd then be making two requests sequentially and slowing things down.

CloudFront does supports multiple origin servers. Don't think of it as S3 between CloudFront and EC2, but S3 next to EC2. Take a look here:

Origin Servers

You can configure one or more origin servers for your Amazon CloudFront download distribution. Origin servers can be an AWS resource, such as Amazon S3, Amazon EC2, Elastic Load Balancing, or a custom origin server outside of AWS. Amazon CloudFront will request content from each origin server by matching the URLs requested by the viewer with rules you configure for your distribution. This feature allows you the flexibility to use each AWS resource for what it’s designed for – Amazon S3 for storage, Amazon EC2 for compute, etc. – without the need to create multiple distributions and manage multiple domain names on your website. You can also continue to use origin servers you already have set-up without the need to move data or re-deploy your application code.

There's also a nice blog post about setting up multiple origins here.

2
  • 1
    This is awesome! How come we've missed this?! Anyway, will give it a go and tell you the outcome. Feb 20, 2014 at 19:19
  • @AleksandrMakov Took me a bit to find anything on it actually. It doesn't seem to be outlined in the docs. If you stumble upon anything more detailed, please let me know!
    – rtf
    Feb 20, 2014 at 20:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .