Multi-region operations
Akka applications run in multiple regions with their data transparently and continuously replicated even across multiple cloud providers. Akka applications do not require code modifications to run within multiple regions. Operators define controls to determine which regions an application will operate within and whether that application’s data is pinned to one region or replicated across many.
Akka ensures regardless of which region receives a request, the request can be serviced. Multiple replication strategies can be configured, with each offering varying features for different use cases.
Multi-region operations are ideal for:
-
Applications that require 99.9999% availability
-
Geographic failover
-
Geo-homing of data for low latency access
-
Low latency global reads
-
Low latency global writes
Replicated reads
Akka’s replicated reads offers full data replication across regions and even cloud providers, without any changes to the service implementation: an entity has its "home" in one primary region, while being replicated to multiple other regions.
In the image above, the entity representing Alice has its primary region in Los Angeles. When a user A in the primary region performs a read request , the request is handled locally, and the response sent straight back
.
When the user in the primary region performs a write request , that request is also handled locally, and a response sent directly back
. After that write request completes, that write is replicated to other regions
, such as in London (UK).
A user B in London, when they perform a read , that read operation will happen locally, and a response sent immediately back
.
A user can also perform write operations on entities in non-primary regions.
In this scenario, the user B in London (UK) is performing a write operation on the Alice entity . Since London is not the primary region for the Alice entity, Akka will automatically forward that request to the primary region
, in this case, Los Angeles (USA). That request will be handled in the USA, and a response sent directly back to the user
.
When Bob makes a request in the UK on his data , that request is handled locally
, and replicated to the US
. Exactly the same as Alice’s requests in the USA with her data are handled locally in the USA, and replicated to the UK.
The data however is still available in all regions. If Bob travels to the USA, he can access his data in the Los Angeles region.
When Bob travels to the USA, read requests that Bob makes on his data are handled locally and getting an immediate reply
. Write requests, on the other hand, are forwarded to the UK
, before the reply is sent
.
Meanwhile, all requests made by Alice on her data are handled locally and get an immediate reply
. The write operations are being replicated to the UK
.
Primary selection
How Akka assigns the primary region to an entity is configurable. The two main modes are static, and dynamic.
In the static primary selection mode (which is the default), the primary region for an entity is selected statically as part of the deployment, so all entities have the same primary region. This is useful for scenarios where you want one primary region, with the ability to fail over to another region in the case of a regional outage.
In the dynamic primary selection mode, each entity can have a different region that is considered its primary region. This is selected based on whichever region the entity was first written in. This is useful for scenarios where you want to have the primary region for you data close to the users who use the data. A user, Alice, in the USA, will have her data in the USA, while a user Bob, in the UK, will have his data, in the UK.
The Operating section explains more details about configuring the primary selection mode.