AWS Multi region ElastiCache sync

Viewed 4479

Need information on best practices for below AWS specific use case,

  1. Our Java web application is deployed in us-east-1 and us-west-2 regions.
  2. It communicates to Dynamo DB and Memcached based ElastiCache is sitting on top of Dynamo DB in both the regions.
  3. We have Dynamo DB replication enabled between us-east-1 and us-west-2.
  4. Route 53 directs API calls to the appropriate region.

Now, the issue is when we create or update a record in Dynamo DB it get's inserted in Dynamo DB and get's cached in that particular region. Record get's replicated to other regions Dynamo DB as well, but cache doesn't remain in sync since there is no replication between ElastiCache.

How do we address this issue in a best possible way?

2 Answers

DAX is not an answer here. I'm surprised nobody is pointing out this.
Ivan is wrong about this one.

DAX is read-write-through cache indeed, but it doesn't capture data changes happens through direct access to DynamoDB (obviously), nor the data changes that happened through "other" DAX cluster.

So in this scenario,
you have 2 DAX cluster one at west-1 one at east-1, and those two clusters are totally independent. thus, if you make a data change on west-1 through DAX, that change does get propagated to east-1 on DynamoDB Table level, Not the cache(DAX) level In other words, if you update the record that had been accessed from both region, (which than cached in both DAX Cluster), you'll still get the same problem.

Fundamentally, this is the problem of syncing cache layer across different regions, which is pretty hard. if you really need it, there are some ways of doing this by making your own Kafka or Kinesis stream that keep the Cache entry changes and consumed by cache clusters in multi-regions. which is not possible with elasticache by its own now. (but it is possible if you setup lambda or EC2 for this task only) Checkout case studies from Netflix

Related