Push gateway
The push gateway lets applications push small signals to browsers, apps and field devices over
server-sent events without holding the streams themselves. It is an optional, separately switched
component of fc-server (FC_PUSH_ENABLED, default off; fcdev turns it on) that runs the
application framework’s push module, configured for many applications at once.
What push is, the topic and ticket model and when to host push in the application instead are on the push concept page. The wire is in the push wire reference. This page is how the platform hosts it.
Architecture
Section titled “Architecture”flowchart LR
APP["Application<br/>(any SDK)"] -->|"PUSH row in its transaction<br/>+ NOTIFY fc_outbox_push"| OB[("outbox_messages")]
OB --> OP["Outbox processor"]
OP -->|"POST /api/push/batch"| ING["Ingest<br/>(any gateway task)"]
ING -->|"one transaction per batch"| PO[("fw_push_outbox")]
PO --> RL["Relay<br/>(one task, svc:push-relay lock)"]
RL --> LOG[("Log: fw_push_log<br/>or a Redis stream")]
LOG -->|"follow"| HUB["Hub on each task"]
HUB -->|"SSE"| CL["Browsers, apps, field devices"]
APP -.->|"rules and ticket keys<br/>POST .../push/sync"| CFG[("push_rules, push_ticket_keys,<br/>push_app_settings")]
CFG -.->|"NOTIFY fw_push_config"| HUB
| Part | What it does |
|---|---|
| Component | pushgw.Start builds a small embedded framework application: configuration from the environment only, the platform database on a pool of its own (FC_PUSH_DB_POOL_MAX, 10), locks on that database, and the push module in multi-application mode. Routes are mounted under /api/push/* before the listeners bind |
| Ingest | POST /api/push/batch, a small API of the gateway’s own (not part of the platform’s OpenAPI document), so a gateway running without the platform API still serves it |
| Relay | Moves pushes from the push outbox into the log. Exactly one task relays at a time, chosen by the svc:push-relay database lock (lease 5 s) |
| Log | postgres (default): fw_push_log in the platform database. redis: a Redis stream (FC_PUSH_DRIVER=redis, FC_REDIS_URL, Redis 6.2+ or Valkey). Kept for FC_PUSH_RETENTION (24 h) so clients can resume |
| Hub | On every task: follows the log and fans each push out to that task’s open streams whose topics match |
| Store | Rules, ticket keys and limits per active application, from push_rules, push_ticket_keys and push_app_settings; reloaded on NOTIFY fw_push_config (every task within about a second) and polled every 60 s |
Because the relay is single and the log is shared, any number of gateway tasks can serve streams: a client connected to any task hears every push.
Publishing
Section titled “Publishing”- The application’s SDK writes a
PUSHrow to its ownoutbox_messagesin the business transaction (payloadtopic,type,data,clientCode,pushId; message group the topic by default). On PostgreSQL the same statement notifiesfc_outbox_push, delivered at commit, and an outbox processor that listens wakes at once instead of at its next poll. Measured locally, insert to frame on a listening stream took a few milliseconds. - The outbox processor posts the rows to
POST /api/push/batch. - Ingest checks each item in order: topic syntax; that the topic belongs to the caller’s application
(
TOPIC_NOT_OWNED); type and data, against the application’s data limit; thepushId; and that the caller may write for the client (CLIENT_FORBIDDEN). Duplicate push ids, within the request or from an earlier one, are answeredSUCCESSwith codeDUPLICATEand written once; the ids are recorded inpush_ingest_idsin the same transaction as the write. The answer is positional, one result per item. The caller needsplatform:messaging:batch:push-write, which the built-in application-service role carries. - Pause and rate. A paused application, or one over its publish rate (a token bucket per
application per task; default 500 a second, burst 2,000), gets the whole batch answered
429withRetry-Afterand nothing written. The outbox processor holds the group and puts the rows back with no attempt counted, so the pushes wait in order in the application’s own outbox. The rate is per task, so N tasks admit N times the configured rate.
Rules and ticket keys are synced from the application’s code with
POST /api/applications/{appCode}/push/sync (platform:application-service:push:sync): one
transaction replaces the application’s rules (at most 200) and public Ed25519 ticket keys (at most 4),
after refusing rules for another application’s topics, open rules that are not marked public, and
malformed keys. The sync is audited. Applications keep their private keys; the gateway only verifies.
Subscribing and authentication
Section titled “Subscribing and authentication”POST /api/push/subscriptions opens a subscription and returns a stream token (HMAC-signed with
FC_PUSH_STREAM_SECRET, at most FC_PUSH_STREAM_MAX_LIFETIME, 1 hour); GET /api/push/stream
streams; GET /api/push/keys serves keys. A subscriber authenticates with:
| Credential | Checked by |
|---|---|
| A platform bearer access token (user or service account) | The platform’s own token validation |
| The platform session cookie | The same, plus the console’s CSRF rule; a stale cookie counts as no credential |
| A field token with a DPoP proof | Proof signature, method and URL, access-token hash, key thumbprint (cnf.jkt), the session still live; each proof’s jti is accepted once (recorded in push_dpop_proofs for the proof’s window) |
| Tickets alone | The application’s ticket keys |
Clients. A user who acts for several clients names one in the subscribe. A platform-wide stream
needs the platform client named explicitly and platform:push:stream:all-clients.
Field workers are confined to their own application. A field token is issued for one application.
The gateway adds a synthetic requirement fc:push:app:<code> to every non-public rule (a platform
credential holds all of them, a field worker only its own), and strips from a field worker’s subscribe
the tickets another application issued. Public rules stay public.
Revocation. A trigger on field_sessions notifies fc_push_session_end when a field login
family’s last session is revoked, and every platform sign-out notifies fc_push_principal_end. Each
task listens and ends the matching streams on every task through the log’s end channel, so a
signed-out user or revoked device stops hearing pushes at once, whichever task holds its stream.
CORS. Only /api/push/* and /field/* answer cross-origin requests, for the origins in the platform’s
allowed-origins table (cached 15 seconds), never with credentials; a preflight from an unlisted
origin gets 403. The /field/* rule is the field-worker sign-in’s own; the push gateway’s is separate.
Isolation and limits
Section titled “Isolation and limits”| Limit | Host-wide default | Per application |
|---|---|---|
| Open streams | FC_PUSH_MAX_STREAMS 50,000 |
Override in push_app_settings |
| Streams per principal | FC_PUSH_MAX_STREAMS_PER_PRINCIPAL 20 |
|
| Topics per stream | FC_PUSH_MAX_TOPICS 100 |
|
| Data per push | FC_PUSH_MAX_DATA_BYTES 16 KiB |
Override |
| Publish rate and burst | 500 a second, 2,000 | Override, and a pause switch |
Per-application overrides and the pause are set with GET and PUT /api/applications/{appCode}/push/settings (anchor, platform:admin:push:manage), audited, and take
effect on every task within a second.
Console and observability
Section titled “Console and observability”Pages under /ui/push/ (anchor only; platform:admin:push:view to see, :manage to change):
- Applications: synced rules and ticket key ids, the four limits with default, override and effective value, and the pause.
- Live: every task writes its counts to
push_gateway_statsevery 10 seconds; the page sums the live tasks (streams by application and client, relay lag p50 and p99). - Recent pushes: the newest pushes from the log, shown only while a time-boxed trace window (1, 5 or 15 minutes, audited) is open for the application.
- Test send: publishes a test push through the gateway in this process; audited.
Metrics on the metrics listener: the module’s fw_push_* series (not yet labelled by application)
and fc_push_ingest_items_total{application,result} and
fc_push_ingest_rejected_total{application,code}. GET /health/push answers 200 once the hub
follows the log. See the metrics reference.
Deployment
Section titled “Deployment”- Beside the platform:
FC_PUSH_ENABLED=truein the same process as the API. It uses the platform’s token validators directly. - As its own service from the same image, with
FC_PLATFORM_ENABLED=false: route/api/push/*to it at the load balancer. It validates tokens the platform minted, so it needs the platform’s keys. With the keyring (the default whenFLOWCATALYST_APP_KEYis set) it reads them from the platform’s database, so give it the same database and the same application key andFC_JWT_ISSUER; it never rotates keys, it only follows them. Without the keyring (FC_JWT_KEY_STORE=config, or no application key) it must have the platform’s JWT signing key (FLOWCATALYST_JWT_PRIVATE_KEY,FC_JWT_SIGNING_KEY_PEMorFC_JWT_SIGNING_KEY_PATH) and the sameFC_JWT_ISSUER. A standalone gateway with neither refuses to start (only a development process may generate a key). - Every task needs the same
FC_PUSH_STREAM_SECRET(at least 32 characters, from the secret store). The load balancer’s idle timeout must exceed the 25-second heartbeat. - Shutdown: when a task begins to stop it ends all its streams and answers new subscribes
503, before the HTTP server’s own drain; clients reconnect to another task and resume from the log.
Choosing the log. Start with postgres: it adds no service, at the cost of one insert, one move
and a retention delete per push on the platform database. Switch to redis when the sustained publish
rate passes about 1,000 a second, when you run more than two gateway tasks, or when push work shows up
noticeably in database CPU. The switch resets every client once, because log ids change.
Tunables
Section titled “Tunables”| Variable | Default | Effect |
|---|---|---|
FC_PUSH_ENABLED |
false |
Run the gateway in this process |
FC_PUSH_STREAM_SECRET |
required | Signs stream tokens; the same on every task |
FC_PUSH_DRIVER |
postgres |
postgres or redis |
FC_PUSH_RETENTION |
24h |
How long pushes are kept for resuming clients (10 minutes to 24 hours) |
FC_PUSH_MAX_STREAMS, _PER_PRINCIPAL, FC_PUSH_MAX_TOPICS, FC_PUSH_MAX_DATA_BYTES |
50,000, 20, 100, 16,384 | Host-wide limits |
FC_PUSH_STREAM_MAX_LIFETIME, FC_PUSH_STREAM_BUFFER, FC_PUSH_RECENT |
1h, 256, 10,000 |
Stream token life, per-stream buffer, pushes each task keeps for replays |
FC_PUSH_RELAY_BATCH, FC_PUSH_RELAY_INTERVAL, FC_PUSH_RELAY_LEASE |
500, 1s, 5s |
The relay |
FC_PUSH_DB_POOL_MAX |
10 | The module’s own connection pool |
FC_REDIS_URL |
none | The Redis log, when the driver is redis |
See the environment reference.
Failure behaviour
Section titled “Failure behaviour”| Situation | What happens |
|---|---|
| A gateway task dies | Its clients reconnect to another task and resume from the log; the relay lock passes to another task within its lease |
| The log is behind or a client was away longer than the retention | The client is told to reset and reloads its state (a push is a signal, not state) |
| An application is paused or over its rate | Its pushes wait in its own outbox, in order, until it is resumed or the rate allows |
| An application syncs an invalid rule or key | The whole sync is refused before anything is written |
| No signing key is available to a standalone gateway (no keyring and no configured key) | It refuses to start |
| A user signs out or a device is revoked | Their streams end on every task |