CloudFront -> Global Accelerator

Hey all. I am considering options for how to move our app from single region to multi-region active-active.

Today we have CloudFront → ALB → Fargate for our API. Also CF → S3 for static/cacheable content.

In reviewing CF details for multi-region it seems like the answer is latency based R53 DNS for the custom origin. Which is okay but doesn’t offer a lot of control over traffic flow.

CloudFront is (for the near to mid term) likely something that will have to remain. Security response headers are being injected there and that is easier for us than app updates to handle response headers in Fargate. Also probably going to be using CF functions in the future too. And our WAF is associated with CF so we have a single entry/choke point.

I have used GA in the past and know it pretty well.

I am thinking of spinning up GA with endpoints of an ALB per region. Then use the GA DNS as the custom origin in CF. Leaving the S3 origin untouched.

This would give us easy control over traffic flow (take a region out of service for maintenance as an example). I don’t have a specific need for the static anycast IPs that come with GA but it doesn’t hurt anything.

Traffic flow would then be…

Client → CF → GA (likely in the same POP I would imagine) → regional ALB → Fargate.

Anyone have concerns/comments on this idea? What am I overlooking for forgetting about?

Also want to point out in the future we may move from ALB to API Gateway for fronting the API. This will of course break the GA integration. Wondering is there is a way around that or if we go right back to latency based routing?

We chose to use Cloudflare load balancing for multi-region. You can do latency based routing, geo-based, a/b weighted, round-robin, etc.

So our traffic flow is Cloudflare → Cloudfront → ALB → Fargate.

We chose to keep Cloudfront in the mix as it seems that Cloudflare and Cloudfront POPs are closer together or have more efficient routing, so we saw drastically lower latency for full requests (non-cached) to complete vs Cloudflare directly to an ALB.

That requires Cloudflare to host your DNS, but you do get much better DDoS and WAF protections, so it might be something to consider if you can’t get what you want out of AWS alone.

Assuming that you’ve already seen this, but posting just in case you haven’t:

https://aws.amazon.com/blogs/networking-and-content-delivery/latency-based-routing-leveraging-amazon-cloudfront-for-a-multi-region-active-active-architecture/

Route53 supports a bunch of different strategies, so you can mix and match as needed to get your desired effect. -Normally GA would go in front of rather than behind CloudFront-. Behind cloudfront you’d have your S3 origin (left untouched) and your custom origin with route53 load balancing strategy assigned at the DNS level with each ALB being an alias record of your custom origin. And that’s all there is to it.

Is there something that latency based doesn’t work well for you?

EDIT: the previous statement was incorrect. Typically it’s GA or CloudFront. (Not enough coffee)

Plus if you setup your Cache-Control headers etc up properly, you don’t have to pay for that bandwidth.

Depending on how complex you want to get, that could provide some more flexibility by adding GA in the middle. But what is the goal you’re trying to achieve? You have one example for taking a region out of service for maintenance, but is that an actual need for your application? Do you have two or even more regions?

I ask because it sounds like a requirement that is quite unlikely in a cloud native environment, but not impossible. Also, Cloudfront can support origin failover, to route to a secondary origin if the primary fails. For manual pre-emptive change to point to a different primary origin for the maintenance use case you just update your behaviors and it’ll achieve the same effect anyway.

Keep in mind as well, there would be some amount of latency impact when adding GA in the middle because it’s routing via another service at the end of the day, but it should be very marginal (single digit ms in most cases). Without Cloudfront in the mix this is normally mitigated by getting traffic on to the AWS backbone closer to your customers, but Cloudfront is already providing you that same benefit.

For APIGW, you can apply WAF to APIGW and can also transform responses (to a limited degree, not as much as lambda@edge/CF functions though). But yeah, you would be back to something like latency based routing from Cloudfront.

Thanks for the reply. Yeah, I had read through that doc.

How would you put GA in front of CloudFront? From my understanding CloudFront is not a valid endpoint for GA.

Thanks. We have been considering a move to CloudFlare for DNS and DDoS capability. So you have a CF distro for each region or use the latency based routing for the custom CF origin?

So I updated my comment. Sorry about that.

Usually it’s cloudfront or GA. Cloudfront only handles HTTP(S) traffic while GA handles all TCP and UDP workloads. Given CloudFront will be at an Amazon PoP just like GA would be, both are going to give you the optimal path to the Amazon network.

It also wouldn’t surprise me at all if GA is just taking advantage of how route53 health checks work under the covers (really interesting read if you can find the article) for knowing the health of a target for the routing decision. So since in your original post you’re talking about static and dynamic content over HTTP the recommended architecture would be to use a route53 load balancing strategy which will get you routed to a healthy region based on it’s heuristics.

Technically speaking, you cloud do CloudFront → GA → {region} but I doubt it would be any faster and would cost more.