Bluetoba
Bluetoba

Reputation: 965

Global borderless implementation website/app on Serverless AWS

I am planning to use AWS to host a global website that have customers all around the world. We will have a website and app, and we will use serverless architecture. I will also consider multi-region DynamoDB to allow users closer to the region to access the closest database instance.

My question regarding the best design to implement a solution that is not locked down to one particular region, and we are a borderless implementation. I am also looking at high traffic and high number of users across different countries.

I am looking at this https://aws.amazon.com/getting-started/serverless-web-app/module-1/ but it requires me to choose a region. I almost need a router in front of this with multiple S3 buckets, but don't know how. For example, how do users access a copy of the landing page closest to their region?, how do mobile app users call up lambda functions in their region?

If you could point me to a posting or article or simply your response, I would be most grateful.

Note: would be interested if Google Cloud Platform is also an option?

thank you!

Upvotes: 4

Views: 144

Answers (1)

Nicholas Sizer
Nicholas Sizer

Reputation: 3550

S3

Instead of setting up an S3 bucket per-region, you could set up a CloudFront distribution to serve the contents of a single bucket at all edge locations.

During the Create Distribution process, select the S3 bucket in the Origin Domain Name dropdown.

Caveat: when you update the bucket contents, you need to invalidate the CloudFront cache so that the updated contents get distributed. This isn't such a big deal.


API Gateway

Setting up an API Gateway gives you the choice of Edge-Optimized or Regional.

In the Edge-Optimized case, AWS automatically serves your API via the edge network, but requests are all routed back to your original API Gateway instance in its home region. This is the easy option.

In the Regional case, you would need to deploy multiple instances of your API, one per region. From there, you could do a latency-based routing setup in Route 53. This is the harder option, but more flexible.

Refer to this SO answer for more detail

Note: you can always start developing in an Edge-Optimized configuration, and then later on redeploy to a Regional configuration.


DynamoDB / Lambda

DynamoDB and Lambda are regional services, but you could deploy instances to multiple regions.

In the case of DynamoDB, you could set up cross-region replication using stream functions.

Though I have never implemented it, AWS provides documentation on how to set up replication

Note: Like with Edge-Optimized API Gateway, you can start developing DynamoDB tables and Lambda functions in a single region and then later scale out to a multi-regional deployment.

Update

As noted in the comments, DynamoDB has a feature called Global Tables, which handles the cross-regional replication for you. Appears to be fairly simple -- create a table, and then manage its cross-region replication from the Global Tables tab (from that tab, enable streams, and then add additional regions).

For more info, here are the AWS Docs

At the time of writing, this feature is only supported in the following regions: US West (Oregon), US East (Ohio), US East (N. Virginia), EU (Frankfurt), EU West (Ireland). I imagine when enough customers request this feature in other regions it would become available.

Also noted, you can run Lambda@Edge functions to respond to CloudFront events.

The lambda function can inspect the AWS_REGION environment variable at runtime and then invoke (and forward the request details) a region-appropriate service (e.g. API Gateway). This means you could also use Lambda@Edge as an API Gateway replacement by inspecting the query string yourself (YMMV).

Upvotes: 4

Related Questions