Replication

Replication #

In Storages, we distinguished between a primary attribute family and one or more replica attribute families. The primary family receives application writes first and confirms persistence to the caller; therefore, whenever an attribute has replicas, its primary family must be a commit-log.

The runtime component responsible for propagating every update from primary commit logs to all target replicas (as well as executing Transformations) is the ReplicationController.

Architecture #

Based on the configured attributeFamilies and transformations, ReplicationController attaches commit-log consumers to primary families and writes updates to every non-read-only replica family:

Replication controller architecture.

Fault Isolation & Independent Consumers #

Every target replica attribute family runs its own dedicated commit-log consumer (consumer group). This design ensures strict fault isolation:

  • If one target backend (for example, Elasticsearch or Cassandra) slows down or experiences an outage, other replicas (such as S3/GCS batch archival) continue consuming at full speed without blocking.
  • Multiple instances of ReplicationController can run concurrently for horizontal scalability and failover—Kafka/Pub/Sub load-balance partitions automatically across consumers sharing the same consumer name.

By default, consumer group names are derived deterministically from the target family name (via DefaultConsumerNameFactory). You can append a custom suffix per family when migrating consumers or running parallel environments:

attributeFamilies {
  event-batch-storage {
    entity: event
    attributes: [ "*" ]
    storage: "gs://my-bucket/proxima/events"
    type: replica
    access: batch-updates
    replication.consumer.name.suffix: "-v2"
  }
}

Online vs. Bulk Replication #

ReplicationController automatically adapts its commit-log observation strategy to the target writer type:

  • Online replicas (OnlineAttributeWriter, e.g., Cassandra, HBase, Bigtable, Elasticsearch, JDBC): Each element is written asynchronously via writer.write(element, callback) and confirmed (context.confirm()) individually once persisted.
  • Bulk replicas (BulkAttributeWriter, e.g., GCS, S3, HDFS/Hadoop): Observed via observeBulk(...). Elements are buffered into time-windowed files and flushed when the commit-log watermark advances past each window + allowed lateness. On consumer rebalance (onRepartition), writer.rollback() discards uncommitted local buffers so partitions resume cleanly from the last committed offset.

Transient write failures are retried automatically using a Failsafe exponential backoff RetryPolicy (default: up to 3 retries with 3s–20s backoff). On unrecoverable errors, ReplicationController fails fast so an orchestrator (such as Kubernetes) can restart the worker safely without silently dropping data.

Running ReplicationController #

ReplicationController lives in cz.o2.proxima:proxima-ingest-server-grpc (cz.o2.proxima.direct.server.ReplicationController).

Standalone Process #

Package your application configuration (reference.conf / application.conf), scheme classes, transformation classes, and required IO modules on the classpath and launch:

# Loads configuration from classpath (application.conf / reference.conf)
java -cp my-proxima-app.jar cz.o2.proxima.direct.server.ReplicationController

# Or pass an explicit HOCON file path
java -cp my-proxima-app.jar cz.o2.proxima.direct.server.ReplicationController /etc/proxima/application.conf

Programmatic Execution (e.g., in Integration Tests) #

Repository repo = Repository.of(ConfigFactory.load().resolve());
ReplicationController controller = ReplicationController.of(repo);

CompletableFuture<Void> future = controller.runReplicationThreads();

Monitoring & Metrics #

ReplicationController registers JMX metrics (cz.o2.proxima.direct.server.metrics.Metrics) tracking per-attribute ingest counts, payload sizes, discarded/filtered updates, and per-consumer watermark lag.

Multi-Cluster Replication (replications) #

Beyond replicating between primary and replica families within a single cluster, Proxima supports cross-cluster (bi-directional or uni-directional) replication through the top-level replications HOCON section.

When you declare a replications entry, ConfigRepository automatically synthesizes proxy attributes, internal staging families (via), and outbound/inbound replication families (targets / source) so writes made in one cluster propagate safely to peer clusters without infinite replication loops:

replications {
  cluster-a-to-b {
    entity: user
    attributes: [ "event.*" ]

    # Local source storage receiving updates replicated from remote clusters
    source {
      storage: "kafka://cluster-a-kafka:9092/replica_from_b"
    }

    # Remote target clusters to push local writes to
    targets {
      cluster-b {
        storage: "kafka://cluster-b-kafka:9092/replica_from_a"
      }
    }

    # Internal staging commit log used to coordinate local writes and loop prevention
    via {
      storage: "kafka://cluster-a-kafka:9092/user_internal_replication"
    }

    # Optional flags:
    # read-only: false
    # read-non-replicated: false
  }
}

In addition to replicating data between attribute families, ReplicationController executes user-defined attribute derivations. See Transformations next.