Aeron Publication Mode
In Aeron, different Publication objects do not append to the same log buffer file within the Aeron media driver, even if they have the same (channel, streamId).
The allocation of a log buffer file is based on the specific type of publication and the unique combination of its channel, stream ID, and session ID.
Publication types and log buffers
ExclusivePublication
Log Buffer: Each ExclusivePublication instance gets its own dedicated log buffer file. This means multiple ExclusivePublication objects, even for the same (channel, streamId), will write to separate log buffers.
Concurrency: This type is designed for a single producer thread and does not require thread-safe access to a shared resource, which provides the highest throughput.
Session ID: Every ExclusivePublication has a unique Session ID, even if the channel and stream ID are the same. This is what guarantees that each publication writes to its own log buffer.
ConcurrentPublication
Log Buffer: For a given (channel, streamId) pair on a single media driver, all ConcurrentPublication instances share the same log buffer file.
Concurrency: This type is designed to be thread-safe, allowing multiple threads or processes to write to the same log buffer. The Aeron client library uses atomic operations to manage access and prevent write conflicts.
Session ID: All ConcurrentPublication objects for the same (channel, streamId) on the same machine share the same Session ID.
Log buffer file structure
Every publication, whether it's exclusive or concurrent, writes data to its own log buffer file, which is structured as follows:
Three term buffers: These are equal-sized sections where message data is written. The publication cycles through these terms.
A metadata section: This stores information about the publication, including the term lengths, MTU size, session ID, and the initial term ID.
Appending logic and its implications
The logic for appending data is defined by the publication type and its (channel, streamId):
Exclusive publications: These are designed for a single producer thread and offer the highest throughput. Because each ExclusivePublication gets its own log buffer, multiple exclusive publications will not compete for access to the same buffer.
Concurrent publications: These are thread-safe and can be used by multiple threads or even processes. The Aeron driver serializes messages offered to a shared log buffer, and the stream's session ID is the same for all concurrent publishers on that machine.
Last updated
Was this helpful?