logo

Akka Cluster Interview Questions and Answers

Akka Cluster is a module in the Akka toolkit that allows you to build fault-tolerant, distributed systems by connecting multiple nodes (or instances) into a cluster. It enables nodes to communicate seamlessly with each other, providing resilience, scalability, and support for location transparency.

Key Features of Akka Cluster :
  1. Distributed Systems Support:

    • Akka Cluster enables an application to run across multiple machines or instances, where each node participates as a part of the cluster.
  2. Location Transparency:

    • Nodes can send messages to actors without knowing the actor's physical location, whether local or remote.
  3. Resilience:

    • If a node fails, Akka Cluster can redistribute tasks and maintain functionality using fault-tolerant techniques.
  4. Dynamic Membership:

    • Nodes can join or leave the cluster dynamically without disrupting the entire system.
  5. Cluster Sharding:

    • Distributes entities (actors) across the cluster automatically, providing load balancing and scalability.
  6. Cluster Singleton:

    • Ensures only a single instance of a specific actor runs in the cluster, even if nodes fail or restart.
  7. Failure Detection:

    • Uses a gossip protocol and heartbeat messages to monitor node health and detect failures.
Use Cases of Akka Cluster :
  1. Microservices:

    • Used to coordinate and communicate between distributed microservices.
  2. Real-time Data Processing:

    • Handles large-scale data pipelines in distributed environments.
  3. Scalable Systems:

    • For systems that need to scale horizontally by adding new nodes dynamically.
  4. Resilient Actor Systems:

    • Provides redundancy and fault tolerance in actor-based applications.
How It Works :
  1. Cluster Nodes:

    • Each instance of an Akka application participating in the cluster is called a node. These nodes communicate via the Akka remoting mechanism.
  2. Gossip Protocol:

    • Nodes exchange state information using the gossip protocol to maintain cluster state consistency.
  3. Membership State:

    • Nodes can have different statuses like Joining, Up, Leaving, or Down, depending on their role in the cluster.
  4. Message Delivery:

    • Messages are routed automatically to the appropriate actors, regardless of their physical location.
Code Example : Here’s a basic setup of an Akka Cluster node:
import akka.actor.ActorSystem
import akka.cluster.Cluster
import com.typesafe.config.ConfigFactory

object ClusterNode extends App {
  // Load cluster configuration
  val config = ConfigFactory.load("application.conf")

  // Create an ActorSystem
  val system = ActorSystem("ClusterSystem", config)

  // Join the cluster
  val cluster = Cluster(system)

  println(s"Node [${cluster.selfAddress}] started and joined the cluster.")
}?

application.conf Configuration Example :
akka {
  actor.provider = cluster
  remote.artery.canonical.hostname = "127.0.0.1"
  remote.artery.canonical.port = 2551
  cluster.seed-nodes = [
    "akka://ClusterSystem@127.0.0.1:2551",
    "akka://ClusterSystem@127.0.0.1:2552"
  ]
}?

A seed node in Akka Cluster is one or more designated nodes used to bootstrap and initialize the cluster. Seed nodes are responsible for helping other nodes discover and join the cluster.

When a node starts, it contacts one or more seed nodes (defined in the configuration) to obtain the current cluster membership information. Once the new node communicates with a seed node, it can successfully join the cluster and participate in distributed operations.

Key Points About Seed Nodes :
  1. Discovery Mechanism:

    • Seed nodes act as a discovery point for other nodes to join the cluster.
    • They are not a "special" type of node but regular cluster members with an additional responsibility for the join process.
  2. Required for Initialization:

    • At least one seed node must be available for a cluster to form. Other nodes use the seed nodes to get the cluster state.
  3. Redundancy:

    • Multiple seed nodes are typically defined in the configuration to provide fault tolerance. If one seed node is unavailable, new nodes can contact the next one in the list.
  4. Not Persistent:

    • Seed nodes do not store persistent information about the cluster. They only assist in the discovery process.
How Seed Nodes Work :
  1. When a new node starts, it uses the seed node list to find an existing member of the cluster.
  2. The new node sends a Join message to the first reachable seed node.
  3. If the seed node is part of the cluster, it forwards the Join request to the cluster leader.
  4. The cluster leader decides whether the new node can join the cluster. If approved, the new node becomes part of the cluster.
Configuration of Seed Nodes :

Seed nodes are defined in the application.conf file under the akka.cluster.seed-nodes setting.

akka {
  actor.provider = cluster
  remote.artery.canonical.hostname = "127.0.0.1"
  remote.artery.canonical.port = 2551
  cluster {
    seed-nodes = [
      "akka://ClusterSystem@127.0.0.1:2551",
      "akka://ClusterSystem@127.0.0.1:2552"
    ]
  }
}
Through self-healing mechanisms like :

* Membership monitoring via heartbeat messages.
* Automatic rebalancing of actors when nodes fail (Cluster Sharding).
* Gossip protocol for decentralized communication.
* Partition handling to avoid split-brain scenarios.

The gossip protocol in Akka Cluster is a key mechanism used to distribute cluster state information across all nodes in the cluster. It ensures that every node in the cluster has a consistent and up-to-date view of the cluster's current membership and health.

This decentralized approach is lightweight, scalable, and fault-tolerant, making it ideal for distributed systems.

How Gossip Protocol Works :
  1. Cluster State Propagation:

    • Each node maintains a local view of the cluster's state, including information about other nodes (e.g., their status, reachability).
    • This cluster state is periodically "gossiped" (shared) between nodes to synchronize their views.
  2. Randomized Communication:

    • Nodes communicate with a small, randomly selected subset of other nodes during each gossip cycle. This randomness ensures scalability and avoids overwhelming specific nodes.
  3. Eventual Consistency:

    • The gossip protocol guarantees eventual consistency, meaning that all nodes will eventually converge to the same cluster state as information propagates.
  4. Failure Detection:

    • Gossip messages include information about node health and reachability, allowing the cluster to detect node failures or network partitions.
  5. Scalability:

    • The protocol is designed to scale well in large clusters, as each node communicates with only a subset of other nodes during each cycle.
Cluster Membership Life Cycle :

The gossip protocol manages the states of nodes in the cluster:

  • Joining: A node sends a request to a seed node to join the cluster.
  • Up: The cluster leader marks a node as fully available for work.
  • Leaving: A node signals its intention to leave.
  • Exiting: A node finishes its work and prepares to leave the cluster.
  • Removed: The node is completely removed from the cluster state.
  • Unreachable: Nodes that fail health checks are marked as unreachable.
Advantages of the Gossip Protocol :
  1. Decentralized:

    • No single point of failure; all nodes participate equally in sharing state.
  2. Fault Tolerance:

    • Handles node failures and network partitions gracefully.
  3. Scalable:

    • Communication grows linearly with the number of nodes, making it efficient for large clusters.
  4. Resilient:

    • Nodes eventually synchronize even if some messages are lost due to transient network issues.

Consider a cluster with three nodes: NodeA, NodeB, and NodeC.

  1. Initial State:

    • NodeA is aware of itself but knows nothing about NodeB and NodeC.
  2. Gossip Communication:

    • NodeA gossips its state to NodeB, and NodeB updates its local view.
    • NodeB gossips to NodeC, propagating the updated state.
  3. Convergence:

    • Over multiple gossip cycles, all nodes learn about each other and converge to a consistent cluster state.
Example: Configuring Gossip Interval :

You can configure gossip settings in the application.conf file :

akka {
  cluster {
    gossip-interval = 1s          # Frequency of gossip messages
    failure-detector {
      threshold = 8.0            # Adjust failure detection sensitivity
      heartbeat-interval = 1s    # Frequency of heartbeat messages
    }
  }
}
Akka Cluster Roles are tags assigned to cluster nodes, allowing for fine-grained control over actor deployment. They enable the distribution of actors across specific nodes based on their roles, optimizing resource usage and system performance.

To use roles in controlling actor deployment, follow these steps:

1. Assign roles to nodes by configuring ‘akka.cluster.roles’ in the application.conf file.
2. Implement a custom router with role-based logic using Group or Pool routers.
3. Define routees paths or props with role-specific settings.
4. Use ‘ClusterRouterGroupSettings’ or ‘ClusterRouterPoolSettings’ to configure role-aware routing.
5. Deploy the router on appropriate nodes using ‘withDeploy’ method and ‘RemoteScope’.
6. Ensure proper configuration of seed nodes and cluster joining mechanisms.

By leveraging Akka Cluster Roles, you can efficiently distribute workload among specialized nodes, improving overall system resilience and scalability.
Akka Cluster Sharding is a feature of the Akka toolkit that enables horizontal scaling of stateful actors across multiple nodes in an Akka cluster. It manages actor instances, distributing them evenly and ensuring fault tolerance by rebalancing and relocating actors when necessary.

Cluster sharding helps scale applications by :

1. Distributing load : Actors are spread across available nodes, reducing individual node workload.

2. Automatic rebalancing : As nodes join or leave, actors are redistributed to maintain balance.

3. Location transparency : Clients interact with actors without knowing their physical location.

4. Persistence : State changes can be persisted for recovery after failures or restarts.

5. Message routing : Messages are routed to appropriate shard regions, which locate target actors.

6. Passivation : Idle actors can be passivated to free up resources.
Akka Cluster and Kubernetes are both clustering technologies, but they serve different purposes and operate at different levels of abstraction.

Akka Cluster is a toolkit for building distributed, fault-tolerant systems using the Actor model. It focuses on managing actor-based applications within a cluster, providing location transparency, automatic sharding, and failure recovery. Akka Cluster is language-specific (Scala/Java) and tightly integrated with the Akka framework.

Kubernetes, on the other hand, is a container orchestration platform that manages the deployment, scaling, and operation of containerized applications across multiple nodes. It provides features like load balancing, rolling updates, and self-healing. Kubernetes is language-agnostic and works with any application packaged in containers.
In an Akka Cluster, data consistency and partition tolerance are handled using the CAP theorem by prioritizing consistency (C) and partition tolerance (P), while sacrificing availability (A). To achieve this, Akka employs a few strategies:

1. Sharding : Distributes entities across cluster nodes, ensuring only one instance of each entity is active at any time.
2. Persistence : Stores events and snapshots to recover actor state in case of node failures or rebalancing.
3. Distributed Data module : Implements Conflict-Free Replicated Data Types (CRDTs) for converging replicas’ states without coordination.

For example, consider a shopping cart application with multiple instances running on different nodes. Using sharding, each cart’s state is managed by a single entity, avoiding conflicts. Persistent actors store events like “item added” or “item removed,” allowing recovery after failure. Finally, CRDTs ensure that concurrent updates from different nodes eventually converge to a consistent state.
Seed nodes play a crucial role in Akka Cluster formation by acting as initial contact points for other nodes to join the cluster. They facilitate communication and help establish the underlying gossip protocol, which ensures consistent state across all members.

In the absence of seed nodes, new nodes cannot join the cluster, leading to potential issues such as:

1. Isolated nodes : Nodes unable to connect with others, causing disjointed clusters or single-node clusters.
2. Inability to scale : The system cannot expand horizontally, limiting its capacity to handle increased workloads.
3. Reduced fault tolerance : Without proper clustering, the system becomes more susceptible to failures, impacting overall reliability and availability.

To mitigate these risks, it’s essential to configure an appropriate number of seed nodes and ensure their accessibility during cluster formation. Additionally, employing strategies like DNS-based discovery can improve resilience against seed node failures.
To plan and implement version upgrades and schema migrations in an Akka Cluster environment, follow these steps:

1. Analyze dependencies : Ensure compatibility between the new Akka version and other libraries used in your project.

2. Rolling upgrade strategy : Use a phased approach to minimize downtime by upgrading nodes one at a time while maintaining cluster functionality.

3. Data migration : If necessary, create data migration scripts or tools for converting persistent data to the new schema format.

4. Test extensively : Perform thorough testing of the upgraded system, including unit tests, integration tests, and stress tests.

5. Monitor performance : Continuously monitor the cluster during and after the upgrade process to identify potential issues early on.

6. Document changes : Keep detailed records of all changes made during the upgrade process, including configuration adjustments and code modifications.
In an Akka Cluster, high availability is maintained during failover and node restarts through several strategies :

1. Cluster Sharding : Distributes actors across nodes, ensuring that a single actor instance exists in the cluster. In case of node failure, shards are automatically rebalanced to available nodes.

2. Persistent Actors : Store their state using Event Sourcing or other persistence mechanisms, allowing them to recover from failures by replaying stored events.

3. Cluster Singleton : Ensures only one instance of a specific actor runs within the cluster. If the node hosting the singleton fails, it’s automatically started on another node.

4. Split Brain Resolver (SBR) : Resolves network partition scenarios by monitoring unreachable nodes and taking appropriate actions like downing nodes or keeping majority side operational.

5. Rolling Updates : Deploy new versions without downtime by updating nodes sequentially, ensuring continuous service availability.

6. Circuit Breakers : Prevent cascading failures by isolating problematic services and giving them time to recover.

7. Monitoring and Supervision : Use tools like Lightbend Telemetry for monitoring cluster health and implement supervision strategies to handle actor failures.
The new node :

* Contacts seed nodes.

* Exchanges membership information via the gossip protocol.

* Moves from Joining → Up state after being approved by the cluster leader.
Common membership states :

* Joining : A node is attempting to join the cluster.
* Up : The node is a fully active member.
* Leaving : A node is gracefully leaving the cluster.
* Exiting : The node has completed leaving but hasn’t been removed yet.
* Removed : The node has been removed from the cluster.
* Down : A node is marked as unreachable.
18 .
How do you gracefully leave a cluster?
Use the Cluster(system).leave(Address) API or the akka.cluster.jmx.enabled JMX feature to notify the cluster that the node intends to leave. The node transitions from Leaving to Exiting.

A Cluster Singleton in Akka is a feature that ensures a single instance of an actor is running across the entire cluster at any given time. This is useful for scenarios where you need centralized processing or coordination within a distributed system, but still want fault tolerance and failover support.

Key Features of Cluster Singleton :
  1. Single Instance Across the Cluster:

    • Only one instance of the singleton actor exists in the entire cluster, regardless of the number of nodes.
  2. Automatic Failover:

    • If the node hosting the singleton actor fails or leaves the cluster, the actor is automatically recreated on another node.
  3. Cluster Membership Awareness:

    • The singleton is tied to the cluster's lifecycle and automatically adapts to changes in the cluster (e.g., nodes joining or leaving).
  4. Location Transparency:

    • Other actors or components can send messages to the singleton without needing to know where it is currently running.
How Cluster Singleton Works :
  1. Singleton Manager:

    • The SingletonManager is responsible for managing the singleton actor across the cluster.
    • It ensures that only one instance of the singleton actor exists at any time.
  2. Singleton Proxy:

    • The SingletonProxy allows other actors in the cluster to communicate with the singleton actor without worrying about its physical location.
  3. Leader Node:

    • The cluster leader is typically responsible for hosting the singleton actor. If the leader changes, the singleton will move to the new leader node.
Configuration for Cluster Singleton :

You need to define a SingletonManager and (optionally) a SingletonProxy in your code.

Example : Cluster Singleton Implementation
import akka.actor.{Actor, ActorSystem, Props}
import akka.cluster.singleton._
import com.typesafe.config.ConfigFactory

object ClusterSingletonExample extends App {
  // Actor to be used as a singleton
  class SingletonActor extends Actor {
    override def receive: Receive = {
      case message => println(s"Singleton Actor received: $message")
    }
  }

  // Create ActorSystem with cluster configuration
  val config = ConfigFactory.load("application.conf")
  val system = ActorSystem("ClusterSystem", config)

  // SingletonManager definition
  val singletonManager = system.actorOf(
    ClusterSingletonManager.props(
      singletonProps = Props[SingletonActor], // Props for the singleton actor
      terminationMessage = PoisonPill,       // Message to terminate the singleton
      settings = ClusterSingletonManagerSettings(system)
    ),
    name = "singletonManager"
  )

  // SingletonProxy definition
  val singletonProxy = system.actorOf(
    ClusterSingletonProxy.props(
      singletonManagerPath = "/user/singletonManager", // Path to SingletonManager
      settings = ClusterSingletonProxySettings(system)
    ),
    name = "singletonProxy"
  )

  // Send a message to the singleton actor via the proxy
  singletonProxy ! "Hello, Singleton!"
}

In Akka Cluster Sharding, the Shard Region plays a critical role in distributing and managing entities (actors) across a cluster. It is responsible for routing messages to the appropriate shard and, ultimately, to the specific entity (actor) within the shard, regardless of where the entity resides in the cluster.

This allows location transparency and dynamic scaling of actors across the cluster while simplifying actor management.

Role of Shard Region in Cluster Sharding :
  1. Message Routing:

    • The Shard Region serves as the main entry point for messages sent to sharded entities.
    • It determines which shard an entity belongs to using a shard ID and then routes the message to the appropriate shard.
    • If the entity for the message doesn't exist yet, the Shard Region creates it automatically.
  2. Shard Management:

    • The Shard Region oversees the lifecycle of shards.
    • It ensures that shards are evenly distributed across cluster nodes and manages shard rebalancing when nodes join or leave the cluster.
  3. Entity Lifecycle Management:

    • The Shard Region ensures that entities are created and terminated based on activity and lifecycle policies (e.g., passivation when entities are idle for a specific time).
  4. Fault Tolerance:

    • If a node hosting a shard fails, the Shard Region detects the failure and relocates the shard to another available node in the cluster.
  5. Location Transparency:

    • Actors and clients can send messages to entities without knowing their physical location in the cluster. The Shard Region handles the underlying routing transparently.
  6. Scaling and Rebalancing:

    • The Shard Region dynamically adjusts shard distribution to ensure load balancing when new nodes join the cluster or existing nodes leave.

Akka Distributed Data is a module in Akka that provides a way to manage eventually consistent, replicated, and distributed data across nodes in a cluster. It is built on the foundation of Conflict-Free Replicated Data Types (CRDTs), which are data structures designed to resolve conflicts automatically when data is updated concurrently on different nodes.

This module is particularly useful in scenarios where strong consistency isn't required, but availability and partition tolerance are critical.

Key Features of Akka Distributed Data :
  1. Eventual Consistency:

    • Updates to data on different nodes are eventually propagated and resolved across the cluster.
  2. Conflict Resolution:

    • CRDTs handle conflict resolution automatically using predefined merge strategies (e.g., merging sets or counters).
  3. High Availability:

    • The data is available for read and write operations even during network partitions.
  4. Scalability:

    • Data is replicated across multiple nodes, and the system scales as the cluster grows.
  5. Distributed State Management:

    • Ideal for scenarios where a shared, distributed state is needed, such as distributed caches, collaborative tools, or leaderboards.
  6. Immutable and Persistent Data:

    • Data changes are propagated as immutable deltas, ensuring safe and consistent replication.
What are CRDTs?

Conflict-Free Replicated Data Types (CRDTs) are special data structures designed for distributed systems. They allow for concurrent updates from multiple nodes and ensure eventual consistency by resolving conflicts automatically without requiring coordination between nodes.

Common CRDT Types in Akka Distributed Data :

  1. Counters:

    • GCounter (Grow-only Counter): Can only be incremented.
    • PNCounter (Positive-Negative Counter): Can be incremented and decremented.
  2. Sets:

    • GSet (Grow-only Set): Allows adding elements but not removing them.
    • ORSet (Observed-Removed Set): Supports adding and removing elements.
  3. Maps:

    • ORMap (Observed-Removed Map): A map of CRDTs that supports adding, updating, and removing entries.
  4. Registers:

    • LWWRegister (Last-Write-Wins Register): Stores a single value with timestamp-based conflict resolution.
  5. Flags:

    • Flag: A boolean flag that can be switched from false to true (one-way toggle).
To create and deploy an Akka application using Docker and Kubernetes, follow these steps:

1. Develop the Akka application with a suitable build tool (e.g., sbt or Maven).
2. Create a Dockerfile to package the application into a container image.
3. Build the Docker image using docker build command.
4. Push the built image to a container registry (e.g., Docker Hub or Google Container Registry).
5. Write a Kubernetes deployment YAML file referencing the pushed image.
6. Apply the deployment using kubectl apply -f <deployment-file.yaml>.

Benefits of this approach include :

* Isolation : Containers encapsulate dependencies, ensuring consistent runtime environments.
* Scalability : Kubernetes can scale applications based on demand, improving resource utilization.
* Resilience : Kubernetes monitors and restarts failed containers, enhancing fault tolerance.
* Rolling updates : Deployments enable zero-downtime updates, minimizing disruption to users.
Akka Persistence integrates with Akka Cluster by providing stateful actors, called Persistent Actors, which store their internal state as events in an event log. This enables the recovery of actor state after crashes or node failures within a clustered environment.

Benefits :
1. Fault tolerance : Actor state is preserved across crashes and node failures, ensuring system resilience.
2. Scalability : Stateful actors can be distributed across cluster nodes, allowing for horizontal scaling.
3. Event sourcing : Storing events allows for easy auditing, debugging, and analysis of system behavior.

Drawbacks :
1. Increased complexity : Implementing persistent actors requires additional code and understanding of event sourcing concepts.
2. Performance overhead : Persisting events introduces latency and potential bottlenecks in high-throughput systems.
3. Data storage management : Choosing and managing appropriate data stores for event logs adds operational complexity.
Akka Cluster is a distributed system that provides high performance and low latency. However, there are specific considerations to ensure optimal operation.

1. Network Latency : As nodes communicate across the network, latency can impact performance. Use fast networks and minimize physical distance between nodes.
2. Message Serialization : Efficient serialization reduces overhead and improves throughput. Choose serializers like Protobuf or Kryo for better performance.
3. Location Transparency : Design your actors with location transparency in mind, allowing them to be moved without affecting functionality.
4. Balancing Load : Distribute work evenly among cluster members using routers, sharding, or custom balancing strategies.
5. Failure Recovery : Implement supervision strategies to handle failures gracefully and maintain system stability.
6. Monitoring : Utilize tools like Lightbend Telemetry (Cinnamon) or Kamon to monitor key metrics such as message rates, mailbox sizes, and actor states.
7. Tuning : Regularly profile and optimize your application, adjusting configuration settings like dispatcher types, thread pools, and timeouts to improve performance.
Debugging and tracing issues in a distributed Akka Cluster system can be challenging due to the following reasons :

1. Asynchronous nature : The non-blocking, asynchronous communication between actors makes it difficult to trace the flow of messages and identify bottlenecks.
2. Distributed environment : With multiple nodes running concurrently, pinpointing the exact location of an issue becomes complex.
3. Fault tolerance : Akka’s fault-tolerance mechanisms like supervision and backoff strategies may mask underlying problems.


To overcome these challenges :

1. Use logging tools : Implement structured logging with context information (e.g., actor path, message type) for better visibility into the system.
2. Monitor metrics : Collect and analyze performance metrics (e.g., message throughput, latency) to detect anomalies and potential issues.
3. Employ tracing frameworks : Utilize distributed tracing tools (e.g., Zipkin, Jaeger) to track message flows across nodes and visualize dependencies.
4. Test rigorously : Perform thorough testing, including stress tests and chaos engineering, to uncover hidden issues before they manifest in production.
5. Leverage debugging libraries : Integrate Akka-specific debugging tools (e.g., akka-tracing) to gain insights into actor interactions and message processing.
In Akka Cluster, deployment strategies like rolling updates, blue-green, and canary deployments help maintain system availability during upgrades or changes.

1. Rolling Updates : Nodes are updated incrementally, ensuring minimal downtime. In Akka Cluster, use cluster-aware routers to redirect traffic away from updating nodes. Implement graceful shutdowns using CoordinatedShutdown for safe removal of nodes.

2. Blue-Green Deployments : Two environments (blue and green) run concurrently with identical configurations. One serves live traffic while the other is updated. In Akka Cluster, switch between environments by adjusting routing rules in load balancers or DNS settings.

3. Canary Deployments : A small portion of the cluster runs the new version alongside the majority running the old version. Monitor performance and gradually increase the new version’s presence if successful. In Akka Cluster, create separate node groups with different versions and adjust router configuration to control traffic distribution.

A split-brain scenario in an Akka Cluster occurs when a network partition divides the cluster into two or more isolated sub-clusters that are unable to communicate with each other. Each partition may still function independently, but they are unaware of the other partitions. This situation can lead to inconsistent state, duplicate work, or data corruption, as multiple nodes may assume leadership or perform conflicting tasks simultaneously.

Why Does Split-Brain Happen?

Split-brain can occur due to:

  1. Network Failures:
    • Temporary loss of communication between nodes in different partitions.
  2. Infrastructure Issues:
    • Faulty switches, routers, or firewalls can block communication.
  3. High Latency:
    • Delays in message delivery can be mistaken as node failures.
  4. Node Crashes or Failures:
    • Unexpected failures can cause cluster instability.
Challenges of Split-Brain :
  1. Duplicate Leadership:

    • Multiple sub-clusters may elect their own leaders, causing conflicting decisions.
  2. Inconsistent State:

    • Sub-clusters may maintain diverging views of the system state.
  3. Data Corruption:

    • Write operations performed independently by each partition can result in data inconsistencies.
  4. Service Downtime:

    • Resolving split-brain can disrupt normal operations if improperly handled.

Akka provides mechanisms to detect and resolve split-brain scenarios automatically. These include:

1. Failure Detection :
  • Akka Cluster uses heartbeat messages and a failure detector (based on the Phi Accrual Failure Detector) to monitor node availability.
  • Nodes are marked as unreachable if they stop responding to heartbeats.
2. Split-Brain Resolver (SBR) :
  • The Split-Brain Resolver (SBR) is a built-in Akka module that resolves split-brain situations by deciding which partition should survive.
  • The SBR can terminate nodes in smaller or less-preferred partitions to restore the cluster to a healthy state.