Aeron Documentation

repository·master·Indexed 27 days ago

https://github.com/aeron-io/aeron

A high-performance, reliable messaging transport system supporting UDP (unicast/multicast) and IPC, designed for ultra-low latency and high throughput. The ecosystem includes Aeron Archive for recording and replaying data streams, Aeron Cluster for fault-tolerant services using the Raft consensus algorithm, and a Java agent for event logging. It provides a C API for cross-language communication with the media driver via IPC.

Tokens
25.6K
Snippets
20
Records
189
Agent score
93%

What's inside Aeron

  1. Overview of Aeron Archive features

    master

    aeron-archive is a module for recording and replaying Aeron data streams from durable storage.

    Key capabilities include:

    • Record: Capture a specific subscription (<channel, streamId>). Local network publications use the spy feature for efficiency. If no subscribers are active, you can advance the stream by setting the system property aeron.spies.simulate.connection=true.
    • Extend: Append data to an existing recording.
    • Replay: Replay a recordingId from a specific position for a given length. Using Aeron.NULL_VALUE for length results in an open-ended replay that stops at the recording's stop position.
    • Query: Access the catalog for existing recordings and check the recorded position of active recordings.
    • Truncate: Shorten a stopped recording. Truncating to the start position effectively deletes the recording.
    • Replay Merge: Allows a late-joining subscriber to replay a recording and then merge with the live stream.
    • Replicate: Copy recordings from a source to a destination archive. When using replication, configure the destination channel using aeron.archive.replication.channel.
    • Storage Maintenance: Perform purge, detach, delete, attach, and migrate operations on recording segments.
  2. Overview of Aeron Client usage

    master

    Aeron clients are used to communicate with a media driver to facilitate message passing. Specifically, clients use Publications to publish messages and Subscriptions to consume messages from replicated publication images.

    Clients communicate with the media driver over IPC (Inter-Process Communication), which enables the media driver to run as a separate process and allows clients to be written in different languages than the driver.

  3. Overview of Aeron Cluster

    master

    Aeron Cluster provides fault-tolerant services using replicated state machines based on the Raft consensus algorithm. It aggregates and sequences streams from cluster clients into a single log, which is then replicated and archived across multiple nodes to achieve fault tolerance.

    Key components include:

    • Consensus Module: Sequences the log and coordinates consensus for recording the log to persistent storage.
    • Aeron Archive: Records the log to durable storage.
    • Services: Consume the log once a majority of cluster members have safely recorded it.
    • Snapshots: Enable fast recovery by allowing services and the consensus module to save their state at a specific log position, enabling replay from that point forward.
  4. Overview of Aeron Agent

    master

    Aeron Agent is a Java agent designed to be attached to a JVM to intercept and log specific Aeron events via bytecode weaving. It captures events defined by EventCode, which includes specialized codes for:

    • DriverEventCode
    • ArchiveEventCode
    • ClusterEventCode

    Captured events are recorded to an in-memory RingBuffer. An asynchronous reader consumes these events and appends them to a log.

  5. Overview of Aeron messaging transport

    master

    Aeron is a high-performance, reliable messaging transport system designed for high throughput and low, predictable latency. It supports:

    • Transport Types: UDP unicast, UDP multicast, and IPC (Inter-Process Communication).
    • Client Support: Java, C, and C++ clients are available in this repository. A .NET client is available separately.
    • Interoperability: Clients can exchange messages across different machines or on the same machine via IPC.
    • Persistence: The aeron-archive module allows recording message streams to persistent storage for later or real-time replay.
    • Fault Tolerance: aeron-cluster provides support for fault-tolerant services using replicated state machines based on the Raft consensus algorithm.

    Aeron integrates with Simple Binary Encoding (SBE) for optimal message encoding/decoding performance and utilizes Agrona for many of its underlying data structures.

  6. Overview of the Aeron Media Driver

    master
    The Aeron Media Driver is a core component responsible for replicating publications to appear as images over a network (the media). It can be configured to run either in-process with Aeron clients or as a separate out-of-process entity.
  7. Limit Per-Stream Session Limits

    master
    Aeron allows users to limit the number of different sessions (distinct publication images) that can be created connecting to the same subscription (defined by channel and stream). This prevents resource exhaustion on the driver hosting the subscription when multiple clients attempt to create numerous publication images.
  8. Monitor Aeron Archive recording progress

    master

    To observe the lifecycle and progress of recordings:

    1. Subscribe to Recording Events: Subscribe to the recording events channel to receive messages regarding the start, stop, and progress of recordings (as defined in the SBE codec).
    2. Use AeronStat: For active recordings, use AeronStat to view the rec-pos counter for each stream.
  9. Track connection status in AeronCluster

    master

    Starting with Aeron 1.48.0, AeronCluster includes a state machine to track connection status. This state machine is updated during:

    • Poll operations (AeronCluster#pollEgress and AeronCluster#controlledPollEgress)
    • Sending data to the Cluster (AeronCluster#offer, AeronCluster#tryClaim, AeronCluster#sendKeepAlive)

    If a communication break lasts longer than AeronCluster.Context#newLeaderTimeoutNs(), the AeronCluster will close itself.

    Default Timeout Behavior:

    • If newLeaderTimeoutNs() is not set, it waits for double the leadership timeout from an actual Cluster.
    • If the Cluster is running an older Aeron version and the leadership timeout is unavailable, it defaults to 10 seconds (resulting in a 20-second wait).

    Manual Updates Required: If you use AeronCluster#ingressPublication or AeronCluster#egressSubscription directly, you must manually call the following to update the connection tracking state machine:

    1. After every offer or tryClaim on AeronCluster#ingressPublication, call AeronCluster#trackIngressPublicationResult.
    2. Every time AeronCluster#egressSubscription is polled, call AeronCluster#pollStateChanges.
  10. Configure Aeron Cluster deployment modes

    master

    Aeron Cluster can be deployed in several configurations depending on your requirements:

    • Single Node: Suitable for development and debugging, or when a single-node sequenced and archived log is sufficient.
    • Appointed Leader: A leader is specified via configuration. This avoids elections but requires manual intervention to appoint a new leader if the current one fails. This is not the recommended production configuration.
    • Automatic Elections (Default): The cluster automatically elects a leader from the members with the most up-to-date log. This is the most reliable method for production.

    Cluster Sizing Note:

    • Typical cluster sizes are 3 or 5 nodes to ensure a majority for consensus.
    • 2-node clusters are supported, but both members must agree on the log. If one fails, the remaining member must be manually reconfigured as a single-node cluster to continue progressing.
  11. Run Aeron with required JVM options

    master

    When using Aeron 1.47.0 or later with Java, you must specify the following JVM option to allow access to internal modules:

    --add-opens java.base/jdk.internal.misc=ALL-UNNAMED

    If you are running the Aeron Archive, you must also include:

    --add-opens java.base/java.util.zip=ALL-UNNAMED

  12. Use Persistent Subscriptions in Aeron Archive

    master
    As of Aeron 1.51.0, PersistentSubscriptions are available in Aeron Archive for Java, C++, and C. This feature serves as an alternative to ReplayMerge with IPC and Spy support, and provides a fallback mechanism for slow consumers.