Akka Core

repository·main·Indexed 11 days ago

https://github.com/akka/akka-core

A platform for building responsive, resilient, and scalable distributed services using the Actor Model. Akka provides a high-level SDK, automated operations, and foundational libraries for concurrent and parallel systems. Key features include transparent remote communication, clustered high-availability, and the Akka Distributed Data tool for sharing state across clusters using Conflict-Free Replicated Data Types (CRDTs).

Tokens
263.1K
Snippets
566
Records
1.2K
Agent score
95%

What's inside Akka

  1. Introduction to Akka Libraries

    main

    Akka Libraries provide a foundation for designing scalable, resilient, and high-performance systems. They are built around the actor model, which provides a consistent abstraction for concurrent, parallel, and distributed systems.

    Key capabilities include:

    • Multi-threaded behavior: Avoids low-level concurrency constructs like atomics or locks, managing memory visibility automatically.
    • Transparent remote communication: Simplifies networking by allowing components to communicate across systems without manual networking code.
    • Clustered, high-availability architecture: Enables elastic scaling (in or out) to support reactive systems.

    Akka Libraries serve as the foundation for the Akka SDK (for rapid development with AI assist and automatic clustering) and Akka Automated Operations (a managed solution for auto-elasticity and multi-region high availability).

  2. Overview of the Akka Platform

    main

    Akka is a platform for building responsive, resilient, and scalable services. It is composed of three main layers:

    1. Akka SDK: Designed for rapid development with AI assistance and automatic clustering. Services built with the SDK are automatically clustered and can be deployed on any infrastructure.
    2. Akka Automated Operations: A managed solution for Akka SDK services that handles auto-elasticity and multi-region high availability within your VPC.
    3. Akka Libraries: The foundational building blocks used by both the SDK and Automated Operations to provide distributed systems capabilities.

    Akka is used for building agentic AI, AI inference, transactional systems, digital twins, IoT, and edge-to-cloud systems.

  3. Key features and changes in Artery remoting

    main

    Artery is a high-performance reimplementation of the Akka remoting module. It is designed for high-throughput, low-latency communication and is mostly source-compatible with the old implementation.

    Core Improvements

    • Transport Options: Uses Akka Streams TCP/TLS or Aeron (UDP) instead of Netty TCP.
    • Stability: Isolates internal control messages from user messages using a dedicated subchannel to prevent false failure detection during heavy traffic.
    • Efficiency: Features mostly allocation-free operation, support for a separate subchannel for large messages, and compression of actor paths on the wire.
    • Performance: Supports direct ByteBuffer serialization/deserialization.
    • Observability: Includes built-in Java Flight Recorder (JFR) support for debugging.
    • Lifecycle: Provides protocol stability across major Akka versions to support rolling updates.

    Breaking Changes

    • ActorRef String Representation: The protocol field in the string representation of an akka.actor.ActorRef is now always akka (previously it was akka.tcp or akka.ssl.tcp).
    • Configuration: Configuration properties differ from the legacy remoting implementation.
  4. Explore Higher-level Akka Cluster Tools

    main

    Akka Cluster provides several high-level tools and patterns for distributed applications:

    • Cluster Singleton: Ensures an actor runs as a single instance across the cluster.
    • Cluster Sharding: Automatically distributes actors across the cluster nodes.
    • Distributed Data (ddata): Provides CRDT-based shared state.
    • Distributed Publish Subscribe (pubsub): Enables cluster-wide message broadcasting.
    • Group Routers: Allows routing messages to a group of actors distributed across the cluster.
    • Reliable Delivery: Provides mechanisms for reliable message delivery between nodes.
  5. Explore Akka Streams patterns and recipes

    main

    The Streams Cookbook provides a collection of 'recipes'—targeted code patterns designed to solve common streaming problems. These recipes serve as:

    1. Direct solutions: Code snippets that can be used as-is for small tasks.
    2. Starting points: Templates that can be customized for specific business logic.
    3. Foundations for Alpakka: Bases for implementing more complex patterns involving Alpakka.

    For a complete list of available operators used within these recipes, refer to the operator index.

  6. Use Akka Distributed Data (Classic)

    main

    This documentation covers the Classic Distributed Data API. For new projects or full documentation, it is recommended to use the Typed Distributed Data API instead.

    Classic Distributed Data allows you to replicate data across multiple nodes in an Akka cluster using Conflict-free Replicated Data Types (CRDTs). You interact with this data primarily through a Replicator actor.

  7. Understand Akka Cluster design concepts

    main

    Akka Cluster is a fault-tolerant, decentralized peer-to-peer membership service that allows distributed applications to span multiple nodes (typically multiple typed.ActorSystems). It uses a Gossip Protocol and an automatic failure detector to manage membership without a single point of failure or bottleneck.

    Key components include:

    • Gossip Protocol: Communicates cluster state randomly across nodes.
    • Failure Detector: Monitors node reachability using a Phi Accrual implementation.
    • Leader: A deterministic role assigned to a node to manage membership state transitions (e.g., moving members from joining to up).
    • Seed Nodes: Initial contact points used by new nodes to join the cluster.
  8. Learning Objectives for the Akka Typed Tutorial

    main

    By following this tutorial, you will learn how to apply Akka's core principles to a real-world use case, specifically focusing on:

    • Actor Hierarchy: Understanding how the parent-child relationship influences actor behavior.
    • Actor Granularity: Learning how to decide the appropriate level of detail/scale for creating actors.
    • Protocol Definition: How to define communication protocols using messages.
    • Conversational Styles: Implementing typical interaction patterns between actors.
  9. Use Akka Classic Clustering

    main

    Akka Classic Clustering provides a set of tools for building distributed systems using the Actor API. This index covers several key patterns for managing actors across a cluster:

    • Cluster Usage: Basic management and lifecycle of a cluster.
    • Cluster Routing: Distributing messages to actors across the cluster.
    • Cluster Singleton: Ensuring a single instance of an actor runs in the cluster.
    • Distributed Pub-Sub: Implementing publish-subscribe patterns across nodes.
    • Cluster Sharding: Automatically distributing actors (entities) across the cluster nodes.
    • Cluster Metrics: Monitoring the health and performance of the cluster.
    • Distributed Data: Using CRDTs (Conflict-free Replicated Data Types) for distributed state.
    • Serialization: Managing how data is converted for network transmission.

    Note: This documentation refers to the Classic API. For the modern Akka Typed API, refer to the Cluster documentation in the typed module.

  10. Choose a Persistence storage backend plugin

    main

    Akka Persistence allows you to plug in different storage backends for journals, snapshot stores, durable state stores, and persistence queries. The following plugins are maintained by the Akka team:

    • R2DBC plugin: Supports relational databases like PostgreSQL, H2 (in-process memory or file-based), and Yugabyte. It is generally recommended over the JDBC-based plugin for new projects.
    • Cassandra plugin: Supports Cassandra's data model. Note that some newer features like Durable State are not supported.
    • AWS DynamoDB plugin: Supports AWS DynamoDB. Note that Durable State and recovery from only the last event are not supported.
    • JDBC plugin: Supports relational databases via JDBC drivers. Recommended to use the R2DBC plugin for new projects.

    Feature Limitations Note: The Cassandra and JDBC plugins do not support several advanced features, including eventsBySlices queries, Projections over gRPC, Dynamic scaling of Projection instances, and Durable State entities.