Configuration
Configure apps, adapters, cache, queues, rate limits, history, recovery, webhooks, and push notifications.
This page walks through the runtime shape of a Sockudo deployment: where app credentials live, how
nodes fan out to each other, which shared stores carry state, and which protocol features are on.
Read it before your first production deploy, or whenever you add a node, a backend, or a V2 feature.
For TOML versus JSON, file discovery, --config, environment precedence, and secret placement, start
with Static configuration. Every key is listed in the
configuration reference.
How the pieces fit
Sockudo configuration should describe the runtime shape explicitly: app storage, fanout adapter, cache, queue, protocol features, security controls, metrics, webhooks, and push notification providers. Each top-level section owns one concern:
| Section | Owns | Single node | Multi-node |
|---|---|---|---|
[app_manager] | App credentials and per-app policy | memory is fine | A shared database driver |
[adapter] | Cross-node fanout and cluster-wide counts | local | A horizontal driver such as redis or nats |
[cache] | Idempotency claims, token revocations, coordination | memory | redis or redis-cluster |
[queue] | Webhook and background jobs | memory | A broker-backed driver |
[rate_limiter] | HTTP API and WebSocket connect limits | memory | redis |
[connection_recovery], [history] | Reconnect replay and durable history | memory history backend | A shared history backend |
[push] | Push storage, queue, and workers | Memory drivers in dev only | Durable storage and queue |
[database] | Connection details the drivers above reuse |
The rule of thumb: anything a second node must see (a claimed idempotency key, a revoked token, a replay position, a queued webhook) must live in a shared backend, not in process memory.
Minimal local config
A single process with one static app. Good for development and tests.
port = 6001host = "0.0.0.0"debug = true
[app_manager]driver = "memory"
[app_manager.array][[app_manager.array.apps]]id = "app-id"key = "app-key"secret = "app-secret"enabled = true
[app_manager.array.apps.policy.limits]max_connections = 1000
[app_manager.array.apps.policy.features]enable_client_messages = falseProduction shape
Every node points at the same app database, adapter, cache, and queue. Metrics are served on a separate port so you can keep it off the public listener.
port = 6001host = "0.0.0.0"debug = false
[app_manager]driver = "pgsql"
[adapter]driver = "redis"
[cache]driver = "redis"
[queue]driver = "redis"
[database.redis]host = "redis"port = 6379
[metrics]enabled = truehost = "0.0.0.0"port = 9601
[metrics.tcp_exporter]enabled = falsehost = "127.0.0.1"port = 5000buffer_size = 1024[database.redis] is the Redis connection reused by the Redis adapter, cache, queue, and rate
limiter. Sentinel, TLS, and Redis Cluster topology are covered in
Redis connections, Sentinel, and TLS.
App manager
The app manager stores app credentials and app-level policy (limits, features, allowed origins, channel namespaces, webhooks). Memory is useful for local development; persistent managers are preferred for production because they let you add, rotate, and disable apps without a restart.
| Driver | Use when |
|---|---|
memory | Credentials are static and local to one process. |
pgsql (aliases postgres, postgresql) or mysql | You need relational app records and standard operational tooling. |
dynamodb | You run on AWS and want managed key-value storage. |
scylladb | You need wide-column scale. |
surrealdb | You use SurrealDB 4 for app metadata. |
[app_manager]driver = "postgres"# Close live connections of disabled/deleted apps (seconds, 0 = off).availability_check_interval_seconds = 15
[app_manager.cache]enabled = truettl = 300The MySQL and PostgreSQL managers can encrypt app secrets at rest; see App secrets at rest. How disabling an app reaches live connections is covered in Disabling an app.
Adapter
The adapter controls cross-node fanout. When a publish lands on node A, the adapter carries it to every other node so each one can deliver to its own sockets. It also answers cluster-wide questions such as “how many sockets are subscribed to this channel”.
[adapter]driver = "redis"enable_socket_counting = trueaggregate_counts = falsefast_presence_transitions = false
[adapter.redis]prefix = "sockudo_adapter:"requests_timeout = 5000pubsub_ping_interval_ms = 10000Use a shared adapter for every multi-node deployment. The local adapter is intentionally
process-local: a second node never sees the first node’s publishes. Available drivers are local,
redis, redis-cluster, nats, pulsar, rabbitmq, google-pubsub, kafka, iggy, and omq;
see Scaling for how to choose.
pubsub_ping_interval_ms (under [adapter.redis] and [adapter.cluster], default 10000) is how
often each node PINGs its Redis subscriber connection. A subscriber connection only reads, so when
Redis goes away without closing it (a network partition, or a managed instance resized or replaced
behind the same address) it would otherwise wait forever while publishing keeps working, and the
node silently stops receiving events from its peers. When a PING fails or gets no answer within one
interval, the node logs a warning, increments sockudo_horizontal_transport_reconnections_total,
and resubscribes. Set it to 0 to disable the probe.
Redis Cluster broadcast bucketing
Without bucketing every broadcast is published to one channel, which hashes to a single slot and therefore a single shard primary. That primary carries the whole fleet’s broadcast egress.
broadcast_buckets (under [adapter.cluster], 1–64, default 3) splits each broadcast across that
many channel variants, each pinned to a different slot range with a hash tag, and every node
subscribes to exactly one bucket. Set it to the cluster’s shard count. Bucketing requires
use_sharded_pubsub = true and a prefix without { or }; configure the same values on every
node.
broadcast_mode sequences a live migration, one rollout at a time:
| Mode | Publishes to | Subscribes to |
|---|---|---|
legacy (default) | the single #broadcast channel | #broadcast |
publish_both | #broadcast and every bucket | #broadcast |
subscribe_bucket | #broadcast and every bucket | this node’s bucket |
bucketed | every bucket | this node’s bucket |
Any adjacent pair of modes delivers each broadcast exactly once to every node, so move
legacy → publish_both → subscribe_bucket → bucketed and let each rollout finish fleet-wide before
the next. To change broadcast_buckets, step back to publish_both, change the count, then move
forward again. Both knobs have environment overrides, ADAPTER_CLUSTER_BROADCAST_MODE and
ADAPTER_CLUSTER_BROADCAST_BUCKETS.
enable_socket_counting keeps the adapter’s request/reply socket-count path enabled by default.
aggregate_counts is off by default; enable it when you want each node to maintain gossiped
cluster-wide channel counts for local count reads.
fast_presence_transitions is off by default. Enabling it uses the replicated presence registry
for first-join and last-leave checks, which avoids request/reply fanout but makes presence
webhook/history transition decisions eventually consistent.
For high-churn benchmark runs that should avoid distributed count fanout, use:
ADAPTER_ENABLE_SOCKET_COUNTING=falseADAPTER_AGGREGATE_COUNTS=true# Optional: enables eventual-consistency presence transition checks.ADAPTER_FAST_PRESENCE_TRANSITIONS=trueCache and queue
The cache holds short-lived shared state such as idempotency claims and capability-token revocations. The queue carries background work such as webhook delivery.
| Section | Drivers |
|---|---|
[cache] | memory, redis, redis-cluster, none |
[queue] | memory, redis, redis-cluster, nats, pulsar, rabbitmq, google-pubsub, kafka, iggy, sqs, sns, none |
Retry, lease, and dead-letter behavior for queue jobs lives under [queue.reliability]; see
Queue v2 reliability.
Recovery and history
Sockudo keeps two separate stores for past messages. They answer different questions, so size and back them separately.
| Hot replay buffer | Durable history | |
|---|---|---|
| Section | [connection_recovery] | [history] |
| Purpose | Fill the gap after a short disconnect | API reads, rewind, cold recovery, versioned messages, inspection |
| Lifetime | buffer_ttl_seconds (default 120) | retention_window_seconds (default 86400) |
| Size bound | max_buffer_size messages per channel (default 100) | max_messages_per_channel, max_bytes_per_channel |
| Storage | In process | backend: postgres, mysql, dynamodb, surrealdb, scylladb, or memory |
[connection_recovery]enabled = truebuffer_ttl_seconds = 120max_buffer_size = 100
[history]enabled = truebackend = "postgres"retention_window_seconds = 86400max_messages_per_channel = 10000Recovery buffers are for reconnect continuity. Durable history is for API reads, rewind, versioned messages, and operational inspection. Keep those concerns separate.
max_buffer_size bounds both the per-channel hot buffer and a single durable fallback replay, so a
client that missed more than that many messages on one channel gets position_expired and must
backfill from history. The full recovery model is in History and recovery.
Push notifications
Push is a core Sockudo subsystem. Configure it with a queue, provider credentials, retention, admission limits, and metrics before sending production traffic.
[push]storage_driver = "postgres"queue_driver = "redis"publish_status_ttl_days = 30analytics_retention_days = 30scheduler_interval_secs = 5cleanup_interval_secs = 300cleanup_batch_size = 1000cleanup_max_deleted_per_tick = 100000
# Runtime env for FCM monolith workers:# PUSH_FCM_ENABLED=true# PUSH_FCM_SERVICE_ACCOUNT_JSON_PATH=/var/run/secrets/fcm-service-account.json# PUSH_FCM_PROJECT_ID is optional when the service account JSON has project_id.
# Runtime env for APNs monolith workers (token auth):# PUSH_APNS_ENABLED=true# PUSH_APNS_TOPIC=com.example.app# PUSH_APNS_TEAM_ID=ABCDE12345# PUSH_APNS_KEY_ID=KEY123ABCD# PUSH_APNS_PRIVATE_KEY_PATH=/var/run/secrets/apns-auth-key.p8Both storage_driver and queue_driver default to memory, which is node-local and loses push state
on restart. Production mode rejects memory push storage and queues unless
allow_memory_drivers = true is set explicitly.
Use the queue backend for push fanout. Direct synchronous provider delivery is only suitable for tests and can hide production latency.
APNs token auth needs a team ID, a key ID, and the private key (PUSH_APNS_PRIVATE_KEY_PATH or
PUSH_APNS_PRIVATE_KEY). Prefer the FCM service account JSON over PUSH_FCM_PROVIDER_TOKEN: a
static provider token cannot be refreshed and is only suitable for short-lived legacy dispatch.
Channel push rules are top-level entries. They trigger the existing push pipeline after matching realtime publishes:
[[push_rules]]enabled = truechannel_pattern = "notifications:*"event_filter = ["agent-complete"]rate_limit_per_second = 100
[push_rules.payload_mapping]title_field = "title"body_field = "body"template_data_field = "data"include_remaining_fields = truechannel_pattern accepts an exact name, *, or a single trailing wildcard such as
notifications:*, up to 256 bytes. The payload mapping values shown are the defaults. See
Push notifications for providers, templates, and status.
Presence
[presence]max_members_per_channel = 100max_member_size_in_kb = 2update_rate_limit_per_member_per_second = 10ungraceful_timeout_seconds = 0v2_ungraceful_timeout_seconds = 15ungraceful_timeout_seconds = 0 preserves Protocol V1/Pusher’s legacy immediate
member_removed behavior. Protocol V2 defaults
v2_ungraceful_timeout_seconds to 15, retaining presence through short abnormal
disconnects without leave/enter flaps. Clean unsubscribe and clean WebSocket close
remove presence immediately for both protocol versions.
Webhooks
Webhook endpoints are configured per app under policy.webhooks. The server-wide [webhooks]
section controls timeouts, batching, and retries for every app:
[webhooks]request_timeout_ms = 10000
[webhooks.batching]enabled = trueduration = 50size = 100
[webhooks.retry]enabled = truemax_attempts = 5max_elapsed_time_ms = 300000initial_backoff_ms = 1000max_backoff_ms = 60000batching.enabled defaults to true when omitted (the shipped config/config.toml sets it to
false). batching.duration is the flush interval in milliseconds and batching.size the maximum
events per request. Webhooks are delivered through [queue]; with queue.driver = "none" they are disabled.
Webhook consumers must validate signatures with the raw request body. Configure retry behavior and dead-letter visibility before relying on webhooks for workflows. Endpoint setup and payloads are in Webhooks.
Rate limits
The server-wide rate limiter has two buckets: signed HTTP API requests and new WebSocket connections.
Each limit allows max_requests per window_seconds per client IP.
[rate_limiter]enabled = truedriver = "redis"
[rate_limiter.api_rate_limit]max_requests = 100window_seconds = 60trust_hops = 0
[rate_limiter.websocket_rate_limit]max_requests = 20window_seconds = 60trust_hops = 0The values shown are the built-in defaults. trust_hops = 0 ignores forwarding headers and keys
limits on the socket peer; behind a trusted proxy, set it as described in
Rate limiter client IP. Per-app ceilings
such as max_client_events_per_second and max_backend_events_per_second live under
[app_manager.array.apps.policy.limits].
Keep limits close to product intent. A collaboration app, trading dashboard, and push-heavy mobile app need different ceilings.
Environment variables
Use environment variables for secrets and deployment-specific settings:
SOCKUDO_DEFAULT_APP_ID=app-idSOCKUDO_DEFAULT_APP_KEY=app-keySOCKUDO_DEFAULT_APP_SECRET=app-secretREDIS_URL=redis://redis:6379/0PUSH_FCM_PROJECT_ID=project-idPUSH_FCM_SERVICE_ACCOUNT_JSON_PATH=/run/secrets/fcm-service-account.jsonAvoid putting app secrets, encryption master keys, webhook secrets, and push provider credentials in committed config files.
Every runtime environment override is listed in the environment variable reference.