Which is better: CloudFront with multiple API Gateways or a custom domain?

0
0
Asked By CuriousCoder42 On

I'm working on a project where I need to set up CloudFront in front of multiple API Gateway endpoints. The goal is to unify everything under one domain name while having different API Gateways manage separate paths. I'm contemplating two possible approaches:

1. **API Gateway Custom Domain with Path Mappings**: This involves creating a custom domain for the API Gateway and setting up two distinct API Gateways on the same domain, each with its own path mappings. Then, I'll use this custom domain as a single origin in CloudFront.

2. **CloudFront with Multiple Origins**: Alternatively, I could create a CloudFront distribution that identifies the two different API Gateways as separate origins, each mapped to different path patterns.

My main concern is **performance**—which approach is likely to be faster and more efficient? Has anyone here implemented either method at scale? I've included diagrams for both options for better understanding.

Thanks for any insights!

4 Answers

Answered By QuestionAsker On

Great point! Is the content served by your API Gateways cacheable? If it’s not, CloudFront might not help much unless you're utilizing edge-optimized gateways, or the outcomes of your queries are cacheable. While there are advantages to using CloudFront with API Gateways, if your slow paths aren't cacheable, it might not add much benefit besides maintaining a single domain and managing CORS.

Answered By TechSavvy123 On

Option 2 seems to make the most sense here. It has a logical structure, and I don't think you'll see much difference in performance between the two methods. Just a thought, are your customers spread globally? If so, you might want an edge-optimized API Gateway for improved performance across the board. But remember, it all depends on your specific backend setup.

Answered By CloudGuru88 On

I’d suggest going for multiple origins with path-based routing. It’s straightforward and efficient.

Answered By GlobalNerd99 On

If performance is your main goal, definitely go with Option 2. It should give you the best results.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.