YepMsg documentation

High availability and durability

YepMsg's durable message store, lease-based active/passive failover with fencing against split-brain, and what survives a restart or a takeover.

YepMsg documentation

YepMsg documentation

  1. Overview
  2. Binds, accounts and carriers
  3. Routing through the control plane
  4. Delivery receipts
  5. Encodings and concatenation
  6. HTTPS send API and webhooks
  7. High availability and durability
  8. Operations and monitoring

Other products

YepMsg gives two guarantees: an accepted message is not lost, and two nodes are never bound to the same carrier account. The first comes from the durable store and the second from lease fencing.

Durable store

Accepted messages are held in a store until a carrier has taken them and they are no longer needed for retry. The memory backend is for development. Production uses PostgreSQL.

  • On start the gateway replays the store and resumes delivery.
  • A retry loop claims messages with claim semantics, so several workers do not process the same message twice.
  • Receipt correlation uses PostgreSQL as well, so receipts for messages submitted before a restart still match.
  • Webhook deliveries that failed are parked in the same store and retried.
  • Daily and monthly quotas are counted in PostgreSQL, so a restart never resets a customer's allowance.

Messages accepted but not yet delivered by a node that goes down are replayed and retried by the node that takes over.

Why active/passive

Carriers typically allow one SMPP session per account. Two live gateways binding the same carrier fight over the session and double-submit customer traffic. YepMsg therefore runs one active node at a time and keeps the others passive.

The lease

Two or more nodes run an identical configuration against the same PostgreSQL database. A lease in the database elects the leader.

  • Only the leader binds carriers, serves customer sessions and drains the store.
  • A standby keeps its account registry warm, because provisioning runs on every node, but binds nothing and listens on no customer or admin port.
  • The leader renews the lease at a regular interval. A standby claims the lease only after the recorded expiry has passed.
  • A clean stand-down, whether from losing the lease with PostgreSQL reachable or from a shutdown signal, releases the lease at once, and the standby is promoted within about one renewal interval.

The renewal interval and lease lifetime are configurable, and the lifetime must be more than twice the interval. With the defaults, failover completes within a lease lifetime of 15 seconds.

Fencing

The leader stands down, cancelling every bind, the moment it either sees the lease taken by another node or cannot confirm that it holds the lease within the lifetime minus one renewal interval. A standby waits the full lifetime. Because the leader's deadline is shorter than the standby's, the two never overlap, even during a PostgreSQL outage. The leader fences itself on its own clock and drops its carrier binds before any standby could claim.

Teardown on the old leader must finish within one renewal interval. If you shorten the interval, keep it above the time the gateway needs to close its sessions.

Observing the role

A role endpoint on a separate listener answers on every node and reports leader, standby or acquiring, along with the lease holder and expiry. The lease can also be read from the database. A standby has no customer or admin listener open, which makes the active node easy to tell apart.

What happens in a failover

  1. The leader fails or is isolated.
  2. It fences itself, or its lease expires.
  3. A standby claims the lease and builds a fresh gateway.
  4. It replays the durable store, binds carriers and opens the customer listener.
  5. Customers reconnect, and accepted messages are retried from the store.

Plan for customers to reconnect. Carriers see a bind from the new node after the old one has dropped.

Requirements for HA

  • Run the PostgreSQL store, receipt and quota backends. Memory state does not survive a failover.
  • Give both nodes the same configuration.
  • Put a stable address in front of the pair, so customers and carriers reach whichever node is leader.
  • Run PostgreSQL itself with the redundancy that your own availability target needs.

Flight recorder

Every carrier and customer session is captured to hourly pcap files with an index of every PDU. Retention is pruned automatically. This is part of operating the gateway and is described in Operations.

Contact sales

Questions about YepMsg?

Ask an engineer about your deployment, or request the full interface specifications and a demonstration of YepMsg on a traffic profile like yours.

  1. We reply within one business day to arrange a time.
  2. A scoping call about your traffic, network and billing model.
  3. A demonstration on a traffic profile like yours, and a lab deployment if your engineers want one.

Prefer email? hello@yeptelcosoft.com

What would you like?
Interested in

We reply within one business day. We use your details only to respond to your request. Privacy notice