A hands-on introduction
Akka Cluster is all about membership
Akka Cluster provides a fault-tolerant decentralized peer-to-peer based cluster membership service with no single point of failure or single point of bottleneck.
A cluster is a group of nodes, each running an actor system.
Each actor system runs independently of other remote instances
Akka Cluster provides Membership and Fault-tolerance automatically
Cluster doesn’t support a zero-configuration discovery protocol. A list of seed nodes must be specified so that nodes can join the cluster.
Provide seed nodes:
Failure detection using simple heartbeats is not good enough for production. Network partitions (or split brain scenarios) may occur. Do not use auto-down for production.
Provide a way to resolve network partitions:
https://github.com/lregnier/reactive-tickets
case class Event(id: String, name: String, description: String)
case class Ticket(id: String)
Event:
Create Event: POST /events
Get Event: GET /events/{eventId}
Remove Event: DELETE /events/{eventId}
List Events: GET /events
Event Tickets:
List Tickets: GET /events/{eventId}/tickets
Buy a Ticket: POST /events/{eventId}/tickets/purchase
EventHttp
Endpoint
Event
Manager
Event
Repository
TicketSeller
Supervisor
Ticket
Seller(1)
Ticket
Seller(2)
Ticket
Seller(n)
Rest API
Services
Persistence
Message Driven:
Reactive Systems rely on asynchronous message-passing to establish a boundary between components that ensures loose coupling, isolation and location transparency.
Responsive:
Responsive systems focus on providing rapid and consistent response times, establishing reliable upper bounds so they deliver a consistent quality of service.
Elastic:
The system stays responsive under varying workload. This implies designs that have no contention points or central bottlenecks, resulting in the ability to shard or replicate components and distribute inputs among them.
Resilient:
The system stays responsive in the face of failure.
Message Driven:
An asynchronous message-passing stack is being used among the different system layers: Akka-Http, Akka, Reactive Mongo.
Responsive:
Under varying workload the system might not be able to provide rapid and consistent response times.
Elastic:
We need to be able to increase and decrease resources horizontally in order to be elastic.
Resilient:
In the face of failure the system does not stay responsive since we have only one instance.
Message Driven:
An asynchronous message-passing stack is being used among the different system layers: Akka-Http, Akka, Reactive Mongo.
Responsive:
System can scale out and potentially provide rapid and consistent response times.
Elastic:
TicketSellerSupervisor singleton represents a bottleneck as it allocates all TicketSellers in one single node and does not distribute them evenly across the Cluster.
Resilient:
TicketSellerSupervisor singleton represents a single point of failure too. In case the node containing the TicketSellerSupervisor and the TicketSellers fails, their state is lost.
Message Driven:
An asynchronous message-passing stack is being used among the different system layers: Akka-Http, Akka, Reactive Mongo.
Responsive:
System can scale out and potentially provide rapid and consistent response times.
Elastic:
All TicketSellers are distributed evenly across the Cluster.
Resilient:
In case any node containing a TicketSeller fails, its state is lost.
Message Driven:
An asynchronous message-passing stack is being used among the different system layers: Akka-Http, Akka, Reactive Mongo.
Responsive:
System can scale out and provide rapid and consistent response times.
Elastic:
All TicketSellers are distributed evenly accros the Cluster.
Resilient:
In case any node containing a TicketSeller fails, the TicketSeller gets restarted in some other node holding its original state.