Shared knowledge · Beginner → Advanced
One target, two billing services, one call-site contract
checkout calls billing.charge.
Two app hosts can connect directly through CoAkka Runtime on a LAN,
private network, VMs, bare metal or edge devices. CoAkka Runtime selects
billing-a or billing-b without business code
keeping a host list. Kubernetes is not required; failover, retry and
rollout stay in the Advanced sections.
Beginner · 01 · Distributed shape
Checkout calls a capability, not a replica
Assume two processes, billing-a and
billing-b, register a handler for
billing.charge. They are equivalent endpoints for one
capability, not two charges. CoAkka Runtime selects exactly one
endpoint for the request.
Direct distributed path.
checkout runs OUTBOUND_ONLY; both billing
processes run NETWORK_NODE. They communicate directly
through CoAkka Runtime transport, with no required Kubernetes Service,
sidecar or service-mesh data plane.
- 01Checkout asks
billing.chargeThe payload carries the order, amount and business idempotency key. - 02CoAkka Runtime reads the active route generationThe route has eligible billing-a and billing-b endpoints.
- 03One billing handler takes ownershipThe selected endpoint validates and charges under the business contract.
- 04Checkout receives one terminal outcomeA business reply or correlated Deadletter/timeout.
checkout
ask target=billing.charge
↓
CoAkka Runtime route generation 7
├─ billing-a:19301 eligible
└─ billing-b:19301 eligible
↓ choose one
business reply / Deadletter / timeout
The call site keeps the same target while running Embedded, moving billing to a peer or adding a replica. The topology owner changes the route snapshot; business handlers and callers do not manage sockets or host lists.
Beginner · 02 · Outcome
Failover does not turn every failure into success
- Business reply
- One billing handler accepted ownership and returned a domain result. Success and business refusal are responses, not Deadletters.
- Deadletter
- Delivery could not complete. Read the stable reason, generation, resolved endpoint and
endpoint_attempt_count. - Caller timeout
- No matched terminal arrived in the wait budget. This does not prove a billing handler never ran.
- No route
ROUTE_MISSorNO_ACTIVE_SNAPSHOTis a configuration defect; resubmission does not repair topology.
Keep Beginner simple
Start with one Embedded billing handler. Split into two peers only for explainable scaling, isolation, availability or ownership needs.
When Advanced is needed
Continue below when CoAkka Runtime sees multiple endpoints directly, the app must handle ambiguous outcomes, or operators are rolling out topology.
Advanced · 03 · Direct peers and route snapshot
Configure direct peers first, then choose a platform
checkout
mode OUTBOUND_ONLY
listener none
billing-a
mode NETWORK_NODE
bind 0.0.0.0:19301
advertise billing-a.internal
port 19301
billing-b
mode NETWORK_NODE
bind 0.0.0.0:19301
advertise billing-b.internal
port 19301
billing-a.internal and billing-b.internal
may be private DNS names or stable private IP addresses. An OS,
container or device supervisor manages the processes. The app host
obtains topology from static config, files/environment, private DNS,
a registry, a control plane or Kubernetes and builds the CoAkka
Runtime route snapshot.
generation: 7
routes:
- target: billing.charge
strategy: WEIGHTED_ROUND_ROBIN
endpoints:
- host: billing-a.internal
port: 19301
weight: 1
flags: [NONE]
- host: billing-b.internal
port: 19301
weight: 1
flags: [NONE]
generation- Monotonic version of the whole snapshot. A topology change or rollback publishes a new, higher generation.
target- The capability address checkout calls; it contains no replica name.
WEIGHTED_ROUND_ROBIN- Shares selection across equivalent handlers. Weight is relative, not a concurrency limit.
RENDEZVOUS_HASH- Use it when a customer/order key should tend to one owner; endpoint-set changes can still remap some keys.
NONEendpoint flag- The zero flag; in a caller snapshot it means an ordinary eligible peer.
UNAVAILABLE- Keeps an endpoint in the snapshot/evidence while excluding it from new selection for draining.
Direct does not mean self-organizing. CoAkka Runtime does not perform discovery, manage membership, elect a leader, run consensus or repair split brain. The topology owner still supplies identity and one consistent snapshot; after accepting it, Core owns listeners, transport, endpoint selection, bounded failover, correlation and outcomes.
Kubernetes is only one optional topology and lifecycle source. With one Kubernetes Service DNS endpoint, CoAkka Runtime sees one endpoint and Kubernetes selects a pod. With individual pod endpoints, CoAkka Runtime owns selection, affinity, draining and failover evidence.
Choose weights from measured throughput.
Advanced · 04 · CoAkka Runtime failover
Failover is safe only before business ownership
Endpoint failover is one request lifecycle: the same business intent, correlation, active generation and monotonic deadline. Core excludes attempted endpoints and selects the next eligible endpoint using the route strategy; it does not reset the timeout.
Core may fail over
- Endpoint unavailable or drained before selection.
- Connect/send failed before accepted handoff.
- Remote CoAkka Runtime refused admission before handler ownership.
- A forwarded Deadletter proves pre-handler refusal such as queue rejected, local handoff failed or
RUNTIME_STOPPED.
Core must stop the attempt chain
- The endpoint may have accepted the Envelope.
- The handler may have started.
- Remote reply timeout or ambiguous delivery certainty.
- The business handler returned a response.
- Invalid Envelope, route/handler mismatch or another terminal CoAkka Runtime outcome.
Exact transport rule. Only a
failure with certainty=NOT_DELIVERED and
scope=ENDPOINT permits automatic endpoint failover. A
local-profile, connection-scoped or ambiguous failure is not repaired
by silently trying another billing endpoint.
request #1 → billing-a
connect failed before handoff (NOT_DELIVERED / ENDPOINT)
remaining deadline → billing-b
billing-b replies OK
application sees: one successful request
CoAkka Runtime evidence: endpoint_attempt_count=2
Advanced · 05 · Application retry
Retry is a new business attempt
Only after a terminal outcome does the application decide whether to
submit again. The new attempt gets a new message_id, keeps
its business idempotency context, consumes a retry budget and uses
suitable backoff. Core cannot guess whether a charge command is safe
to replay.
- CoAkka Runtime failover succeeded
- Do not retry in the application. The caller already received a reply for the current request.
REMOTE_REPLY_TIMEOUT- The outcome may be ambiguous. Query the idempotency record or reconcile with billing before retrying a charge.
ROUTE_MISS/INVALID_ENVELOPE- Repair topology or the producer; retry does not change the cause and only adds load.
QUEUE_REJECTED/ pressure- Back off, shed load or await capacity. Increase a queue only when evidence shows a suitable bounded burst.
- Business error response
- Apply domain policy. A declined card, duplicate charge and temporary provider failure do not share one retry law.
Billing idempotency checklist
- Create a stable business key in checkout before the first submit; do not use transport
message_idas the business key. - Billing stores or looks up the outcome by that key inside the charge consistency boundary.
- Every application retry has a new
message_idwhile preserving the business key and request meaning. - Bound attempt count, total time and backoff; surface the final terminal outcome to the caller.
- Do not retry a OneWay charge without a verified reconciliation/idempotency contract.
Advanced · 06 · Generation and rollout
Generation makes skew visible; it does not create global atomicity
- One topology publisher/single writer creates the next snapshot; Core rejects stale or invalid updates and preserves the active snapshot.
- An in-flight request keeps the generation used for routing. New requests use the current active local generation.
- Two processes can temporarily observe different generations. Outcomes must record generation and endpoint instead of hiding skew.
- Drain billing-a with a newer snapshot carrying
UNAVAILABLE, wait for old work, then remove it in a later generation. - Rollback is a valid snapshot with a higher generation, not a return to an older generation number.
- If the deployment needs atomic cutover everywhere, the platform/control plane must provide that protocol; CoAkka Runtime does not become a consensus system.
Advanced · 07 · Operator evidence
Count endpoint attempts; do not call them user retries
remote_failover_attempt_count- Core selected a replacement endpoint inside the same request lifecycle.
remote_failover_success_count- A request that used failover later completed with a response.
remote_failover_exhausted_count- Failover evidence existed but no eligible endpoint, matching generation or deadline remained.
endpoint_attempt_count- Endpoint attempts attached to one request's terminal Deadletter.
- Recent event log
- Bounded diagnostic context for attempt/success/exhausted; it can be evicted and is not a durable audit log.
- Business retry count
- A separate application-owned metric tied to an idempotency key and user/business attempt.