Cosmo Streams | Real-Time GraphQL Subscriptions by WunderGraph - WunderGraph

Real-time GraphQL that scales to any load

Five subscription protocols with connection multiplexing, plus event-driven subscriptions via Kafka, NATS, and Redis.

Protocol-based subscriptions and event-driven EDFS. Choose what your architecture needs.

Two approaches to real-time GraphQL

Cosmo Router provides subscription support out of the box. GraphQL Subscriptions handles multiple protocols and connection multiplexing. Cosmo Streams (EDFS) connects the Router directly to message brokers, making subgraphs completely stateless.

Both approaches work within the same federated graph. Use protocol subscriptions for existing WebSocket subgraphs. Use Cosmo Streams when moving to serverless, working with Kafka or NATS, or reducing connection overhead at scale.

Why GraphQL subscriptions at scale are hard

Real-time features should not require stateful subgraphs, three WebSocket connections per client, or weeks of custom infrastructure work.

Four problems that arise with traditional GraphQL subscriptions.

WebSocket subscriptions require stateful subgraphs.

Every active subscription lives in subgraph memory. Serverless deployments become impossible because Lambda and Cloud Run cannot maintain long-lived connections.

Three connections per client adds up fast.

Client to Router, Router to Subgraph, internal subgraph state. At 10,000 clients, connection overhead alone can consume substantial memory resources.

Protocol mismatches block real-time features.

Legacy mobile apps, modern web clients, and Elixir backends all use different protocols. Without a translator, each protocol requires a separate implementation.

Federated subscriptions require inter-subgraph coordination.

When entity fields come from multiple subgraphs, no single subgraph owns the subscription root. Coordinating updates across subgraphs is a hard problem with no standard solution.

Cosmo Router handles all four. Protocol translation, multiplexing, and event-driven stateless subscriptions.

Cosmo Streams capabilities

01 Protocol subscriptions
02 Event-driven (EDFS)

Five subscription protocols supported between clients and the Router, and between the Router and each subgraph. Connection multiplexing groups subscriptions with matching authentication into single upstream connections, reducing backend connection count significantly.

Streams use cases

Real-time dashboard

Live dashboards with multiplexed WebSocket connections

Scenario

A fintech application displays real-time prices and portfolio values to thousands of concurrent users.

How Cosmo handles it

Clients connect via graphql-ws. The Router multiplexes all subscriptions for the same data through shared connections to the pricing subgraph. Header-based authentication groups connections.

Outcome

10,000 connected clients consume connection resources of far fewer upstream connections.

Serverless real-time

Serverless subgraphs with real-time subscription support

Scenario

An engineering team wants to deploy subgraphs on AWS Lambda or Cloud Run but cannot because subscriptions require persistent connections.

How Cosmo handles it

Subgraphs publish events to NATS when data changes. The Router subscribes to topics and fetches current state via HTTP when events arrive. Lambda handles only stateless HTTP requests.

Outcome

Full serverless deployment with real-time subscription support.

High-scale notifications

Push updates to large numbers of concurrent users

Scenario

A platform needs to push updates to many concurrent users without overwhelming infrastructure.

How Cosmo handles it

Backend services publish notifications to Redis Pub/Sub. The Router handles all client connections with efficient I/O. Subscription deduplication ensures each unique notification is fetched once regardless of subscriber count.

Outcome

Subscriptions scale without linear growth in backend connection count or resource usage.

Which capability do you need?

If you are… Start here
Needing WebSocket support with multiple protocol options GraphQL Subscriptions
Moving subgraphs to serverless deployments Cosmo Streams (EDFS)
Integrating Kafka, NATS, or Redis as the event source Cosmo Streams (EDFS)
Supporting legacy clients alongside modern clients GraphQL Subscriptions
Reducing memory and connections at high client counts Cosmo Streams (EDFS)

How Cosmo Streams compares

Cosmo Streams Traditional GraphQL Subscriptions Custom Event Gateway
Subgraph state Stateless (HTTP only) Stateful (WebSockets) Varies
Serverless compatible Yes No Requires custom work
Message broker integration Native (Kafka, NATS, Redis) None DIY
Subscription deduplication Automatic Manual DIY
Protocol options 5 protocols Varies by framework Custom

Why teams use Cosmo Streams

Add real-time to your federated graph

SOC 2 Type II

HIPAA

ISO 27001