Running Aeron Archive
Aeron Archive is written as a number of Agrona Agents, much like the Aeron Transport, which gives you flexibility in how to run it. You can run it:
- as a standalone application in its own process, using the
Archive
class's
main()
method. When running it this way, you would have to configure it using system properties, not programmatically - co-located with the Media Driver, using the composite ArchivingMediaDriver, which contains a MediaDriver and an Archive
- embedded in one of your own applications, where it can run on its own thread(s) or be invoked by the application
Agents and ThreadingMode
Aeron Archive is similar to the Media Driver, in that it is composed of three Agrona Agents:
- ArchiveConductor, which manages resources within Aeron Archive
- Recorder (an inner class of ArchiveConductor), which handles the recording of Publications
- Replayer (an inner class of ArchiveConductor), which handles the replaying of Publications
Aeron Archive has an ArchiveThreadingMode (similar to the Media Driver's ThreadingMode) to control how many threads are used to drive them:
- INVOKER mode (0 threads): no threads are created, Archive is embedded in your application, which needs to invoke it
- SHARED mode (1 thread): one thread is created, which invokes the duty cycle of ArchiveConductor, Recorder and Replayer
- DEDICATED mode (3 threads): the default, which creates one thread for each of the ArchiveConductor, Recorder and Replayer
When using the ArchivingMediaDriver composite, the Media Driver and Archive threading modes are independent. For example, the Archive could use DEDICATED mode and the Media Driver could use INVOKER. In that case, the Archive would use 3 threads and the Media Driver would use none. The ArchiveConductor would be responsible for invoking the Media Driver, to give it CPU resource.
Agents Example
If you ran Aeron Archive, a Media Driver and a User Application that is a client to Aeron Archive, it would look like this. The Agrona Agents are circled in red. By default, they would each have a dedicated thread.
Aeron Archive has the 3 agents described above. It communicates using Aeron Transport, so it has an Aeron Transport Client (it uses the Aeron class), which contains a Client Conductor.
The Media Driver has its 3 agents, as described in Aeron Transport.
The User Application communicates using Aeron Transport, so it has an Aeron Transport Client. It also sends messages to Aeron Archive, so it contains an Aeron Archive Client, which is the AeronArchive class. Unlike the Aeron Transport Client, it does not contain a Conductor and does not require an additional thread.