Replicated Akka Persistence journal and snapshot store backed by Apache Cassandra.
To include the Cassandra plugins into your sbt
project, add the following lines to your build.sbt
file:
resolvers += "krasserm at bintray" at "http://dl.bintray.com/krasserm/maven"
libraryDependencies += "com.github.krasserm" %% "akka-persistence-cassandra" % "0.3.3"
This version of akka-persistence-cassandra
depends on Akka 2.3.4 and is cross-built against Scala 2.10.4 and 2.11.0. It is compatible with Cassandra 2.0.3 or higher.
- All operations required by the Akka Persistence journal plugin API are fully supported.
- The plugin uses Cassandra in a pure log-oriented way i.e. data are only ever inserted but never updated (deletions are made on user request only or by persistent channels, see also Caveats).
- Writes of messages and confirmations are batched to optimize throughput. See batch writes for details how to configure batch sizes. The plugin was tested to work properly under high load.
- Messages written by a single processor are partitioned across the cluster to achieve scalability with data volume by adding nodes.
To activate the journal plugin, add the following line to your Akka application.conf
:
akka.persistence.journal.plugin = "cassandra-journal"
This will run the journal with its default settings. The default settings can be changed with the following configuration keys:
cassandra-journal.contact-points
. A comma-separated list of contact points in a Cassandra cluster. Default value is[127.0.0.1]
.cassandra-journal.port
. Port to use to connect to the Cassandra host. Default value is9042
.cassandra-journal.keyspace
. Name of the keyspace to be used by the plugin. If the keyspace doesn't exist it is automatically created. Default value isakka
.cassandra-journal.table
. Name of the table to be used by the plugin. If the table doesn't exist it is automatically created. Default value ismessages
.cassandra-journal.replication-factor
. Replication factor to use when a keyspace is created by the plugin. Default value is1
.cassandra-journal.max-partition-size
. Maximum number of entries (messages, confirmations and deletion markers) per partition. Default value is 5000000. Do not change this setting after table creation (not checked yet).cassandra-journal.max-result-size
. Maximum number of entries returned per query. Queries are executed recursively, if needed, to achieve recovery goals. Default value is 50001.cassandra-journal.write-consistency
. Write consistency level. Default value isQUORUM
.cassandra-journal.read-consistency
. Read consistency level. Default value isQUORUM
.
The default read and write consistency levels ensure that processors can read their own writes. During normal operation, processors only write to the journal, reads occur only during recovery.
To connect to the Cassandra hosts with credentials, add the following lines:
cassandra-journal.authentication.username
. The username to use to login to Cassandra hosts. No authentication is set as default.cassandra-journal.authentication.password
. The password corresponding to username. No authentication is set as default.
To limit the Cassandra hosts this plugin connects with to a specific datacenter, use the following setting:
cassandra-journal.local-datacenter
. The id for the local datacenter of the Cassandra hosts that this module should connect to. By default, this property is not set resulting in Datastax's standard round robin policy being used.
- Detailed tests under failure conditions are still missing.
- Range deletion performance (i.e.
deleteMessages
up to a specified sequence number) depends on the extend of previous deletions- linearly increases with the number of tombstones generated by previous permanent deletions and drops to a minimum after compaction
- linearly increases with the number of plugin-level deletion markers generated by previous logical deletions (recommended: always use permanent range deletions)
These issues are likely to be resolved in future versions of the plugin.
- Implements its own handler of the (internal) Akka Persistence snapshot protocol, making snapshot IO fully asynchronous (i.e. does not implement the Akka Persistence snapshot store plugin API directly).
To activate the snapshot-store plugin, add the following line to your Akka application.conf
:
akka.persistence.snapshot-store.plugin = "cassandra-snapshot-store"
This will run the snapshot store with its default settings. The default settings can be changed with the following configuration keys:
cassandra-snapshot-store.contact-points
. A comma-separated list of contact points in a Cassandra cluster. Default value is[127.0.0.1]
.cassandra-snapshot-store.port
. Port to use to connect to the Cassandra host. Default value is9042
.cassandra-snapshot-store.keyspace
. Name of the keyspace to be used by the plugin. If the keyspace doesn't exist it is automatically created. Default value isakka_snapshot
.cassandra-snapshot-store.table
. Name of the table to be used by the plugin. If the table doesn't exist it is automatically created. Default value issnapshots
.cassandra-snapshot-store.replication-factor
. Replication factor to use when a keyspace is created by the plugin. Default value is1
.cassandra-snapshot-store.max-metadata-result-size
. Maximum number of snapshot metadata to load per recursion (when trying to find a snapshot that matches specified selection criteria). Default value is10
. Only increase this value when selection criteria frequently select snapshots that are much older than the most recent snapshot i.e. if there are much more than 10 snapshots between the most recent one and selected one. This setting is only for increasing load efficiency of snapshots.cassandra-snapshot-store.write-consistency
. Write consistency level. Default value isONE
.cassandra-snapshot-store.read-consistency
. Read consistency level. Default value isONE
.
To connect to the Cassandra hosts with credentials, add the following lines:
cassandra-snapshot-store.authentication.username
. The username to use to login to Cassandra hosts. No authentication is set as default.cassandra-snapshot-store.authentication.password
. The password corresponding to username. No authentication is set as default.
To limit the Cassandra hosts this plugin connects with to a specific datacenter, use the following setting:
cassandra-snapshot-store.local-datacenter
. The id for the local datacenter of the Cassandra hosts that this module should connect to. By default, this property is not set resulting in Datastax's standard round robin policy being used.