13
votes

I've been introduced recently to AWS and I really loved it. However, I'm asking myself some questions (that may be stupid) about architecturing for multi-regions.

Let's say an application is used by Europeans and Asians. My first idea was to add EC2 instances in Europe, as well as a S3 bucket to hold static data and a SQS queue and ElastiCache in Europe. It's going to be blazingly fast for European people, but slower for asians.

To solve this, I'd add CloudFront for static data, so that images are served quickly for Asians too. However, requests to server (Ajax requests...) still going to have some latencies, so the solution would be to add an EC2 instance in Singapore/Tokyo region too.

However, new problem arise: if a request is dispatched to Tokyo EC2 instance, then if it needs to receive a message from SQS that is stored in Europe or access ElastiCache data => latency again + costs for inter-regions transfer. So we need to add a SQS and ElastiCache in Asia too ?

Maybe I miss something, and cross-regions AWS requests are super-fast, but from what I've understood, if we want fast experience for multi-regions, we basically need to duplicate all services too every regions (excepting S3 maybe, as we can use CloudFront for that, and I suppose we can live with the latency if a SQS job in Asia need to access a S3 resource in Europe).

Anyway, did I understand this correctly ? Do you have any resources about how to architecture applications that target multi-regions ?

Thanks :)

2

2 Answers

7
votes

These aren't stupid questions at all! This part is absolutely correct:

Maybe I miss something, and cross-regions AWS requests are super-fast, but from
what I've understood, if we want fast experience for multi-regions, we basically
need to duplicate all services too every regions

Cross-region requests will be limited by the speed of light and the network topology between regions. I would expect requests from Asia to reach the European application in about 1/4 second round trip. Most requests would be faster, but you can't guarantee all of them will be faster, so you have to design accordingly. If that isn't fast enough, then yes, you'll need to deploy to a closer region and route users to the appropriate region. The number of times that round trip is required is up to your application's architecture. If you have many requests to Elasticache or SQS, those 1/4 seconds will add up very quickly. If you can batch the requests, it might be tolerable.

To route users to the appropriate region, you'll want to look at Route 53, which is another part of the AWS family. This announcement about Route 53 describes the latency-based routing between regions that you would need. Once users are routed to the appropriate EC2 instances, each region you've deployed to should be isolated. You would configure your European deployment with EC2, SQS, Elasticache, and any other AWS offerings all served from the European region (eu-west-1). For your Asian deployment, you might host it all in the ap-southeast-1 region. Once Route 53 connects an Asian user to an EC2 instance within ap-southeast-1, the requests to SQS, Elasticache, etc. would be within the same region and thus very fast.

1
votes

The utilities model that Amazon Web Services introduced is helping you to deploy the same service in multiple regions. The same CLI commands/web console/CloudFormation scripts are working in all the regions in the same way. Therefore to launch a similar service in Singapore and in Europe should not be complicated for you. More than that, you can also manage all of them from the same location - the power of the cloud.

It will also not going to be more expensive as you are paying for what you use, and if you distribute the load between the regions, you will have more or less the same cost. For example, if you need 10 servers to serve your users, you can have 5 servers in Europe and 5 servers in Singapore. More than than; you can have different number of servers in different regions based on the hour of load using auto-scaling. for example, 8 server in Europe when Europe is awake and only 2 in Singapore when it is night there, and vice versa.

With the combination of the above multi-region services (EC2, S3, ElasticCache, RDS...) with Amazon CloudFront (CDN) and Route 53 (DNS) you can create a very scalable and affordable service, with excellent latency globally (Europe, Asia, North and South America...).