Home / Insights / Web and SaaS Development

Web and SaaS Development

Real-Time Features in Web Apps: Choosing Between WebSockets, Server-Sent Events and Managed Services

Live dashboards, notifications, chat and collaborative editing all need the server to push data to the browser. This guide compares WebSockets, server-sent events and managed real-time services so you can pick the simplest option that meets your requirements and budget.

TopicsWeb and SaaS DevelopmentArchitecture and Modernization

Key takeaways

  • Most ‘real-time’ requirements are one-way: the server updates the browser. Server-sent events over HTTP/2 cover those cases with far less infrastructure than WebSockets.
  • Choose WebSockets when clients must send frequent messages back (chat, collaboration, games), and plan for connection state, scaling and reconnection from the start.
  • Managed services (API Gateway WebSocket APIs, Pub/Sub providers, Firebase-style databases) remove operational work but introduce per-connection or per-message costs and platform limits.
  • Design the data flow before the transport: event naming, ordering, idempotency and replay matter more than the protocol choice.
  • Benchmark with realistic connection counts and message rates before launch, and build in graceful degradation to polling.

Product teams ask for “real-time” features more often than they used to: an operations dashboard that updates as orders arrive, a notification bell that lights up without a page refresh, a chat panel inside a customer portal, or two staff members editing the same record at once. Each of these needs the server to deliver data to the browser as events happen, rather than waiting for the browser to ask. The technical options, however, differ enormously in complexity and running cost, and the wrong choice is expensive to unwind once a product is live.

This article is for CTOs, engineering leads and product owners planning a web application or SaaS platform that needs live behaviour. It compares the three main approaches, WebSockets, server-sent events (SSE) and managed real-time services, explains the trade-offs that matter in production, and gives a decision path and implementation checklist. It also covers the data design questions that cause more real-time bugs than the transport layer ever does.

At PoliteTech we build custom web applications, customer portals and multi-tenant SaaS platforms with React, Next.js, Angular and Node.js, .NET or Python backends on AWS, Azure or Google Cloud. Real-time features appear in many of those projects, from clinical operations dashboards to a secure team messaging product. Our web development services page describes the broader work; this article focuses on one recurring architectural decision.

What ‘real-time’ actually means for your product

The first step is to translate a feature request into measurable requirements. “Real-time” can mean anything from a few seconds of latency on a reporting dashboard to sub-100-millisecond round trips in a collaborative editor. Four questions sort most cases.

1. Which direction does data flow?

If the server pushes updates and the client only occasionally sends actions through ordinary HTTP requests, you have a one-way requirement. If the client must stream frequent messages to the server as well (typing indicators, cursor positions, voice or game input), you have a two-way requirement. This single distinction rules out or in whole categories of technology.

2. How fresh must the data be?

A finance dashboard that refreshes within five seconds feels live to most users. A chat message that arrives five seconds late feels broken. Write the acceptable latency down.

3. How many concurrent connections?

Fifty internal staff on a back-office tool and fifty thousand customers on a public app have completely different scaling profiles. Estimate peak concurrency, not average.

4. What happens when the connection drops?

Mobile networks, laptop sleep and corporate proxies all interrupt long-lived connections. Decide whether missed events must be replayed exactly, approximately, or can simply be refetched.

FeatureDirectionTypical latency needMissed-event handling
Live dashboard or order boardOne-waySecondsRefetch current state on reconnect
In-app notificationsOne-waySecondsReplay from last seen ID
Progress of a long job (import, AI generation)One-waySub-second to secondsRefetch job status
Chat and messagingTwo-waySub-secondExact replay, ordering matters
Collaborative editingTwo-way, high frequencyTens of millisecondsConflict resolution (CRDT or OT)
Location tracking, telemetryOne-way from device, one-way to viewersSecondsLatest value wins

Action: for each live feature, record direction, latency target, peak concurrency and reconnection behaviour. This table is your requirements document for the rest of the decision.

The three options and how they work

Server-sent events (SSE)

SSE is a simple, standardised way for a server to stream text events to the browser over a normal HTTP response. The browser opens the stream with the EventSource API, the server responds with the text/event-stream content type and writes events as they occur. According to MDN’s guide to server-sent events, the browser reconnects automatically if the connection drops, the server can set the retry delay, and each event can carry an id. The HTML Living Standard specifies that on reconnection the browser sends a Last-Event-ID header, which lets the server resume from where the client left off. The specification also notes that legacy proxies may drop idle HTTP connections, and recommends sending a comment line roughly every 15 seconds to keep the stream alive.

SSE is one-way only: the client sends nothing over the stream. Client actions go through ordinary HTTP requests, which is often exactly what you want. One important limit: MDN warns that without HTTP/2, browsers cap open connections at six per domain across all tabs, so several tabs of an SSE-based app can exhaust the limit. Over HTTP/2 the limit is negotiated and defaults to 100 streams, which removes the problem in practice.

WebSockets

The WebSocket protocol, defined in RFC 6455 (December 2011), opens a persistent two-way channel. The client starts with an HTTP request carrying an Upgrade: websocket header; if the server agrees, it responds with status 101 and the connection switches to WebSocket framing. The protocol defines ping and pong control frames for keep-alive and a close handshake. MDN’s WebSocket API documentation notes that the API has been widely available across browsers since 2015, but also warns that it does not support backpressure: if messages arrive faster than the application can process them, memory and CPU can be exhausted. For backpressure-sensitive cases MDN points to the newer WebTransport API, which is less widely supported.

WebSockets are the right tool for genuinely interactive features. The cost is operational: every connection is stateful, so you must handle load balancing of sticky connections, horizontal scaling with a shared message bus, authentication on upgrade, heartbeats and reconnection logic on the client. Libraries such as Socket.IO, SignalR and ws, which MDN also lists, handle some of this, but the architecture decisions remain yours.

Managed real-time services

Cloud providers and specialist vendors offer services that terminate connections for you. On AWS, for example, API Gateway WebSocket APIs let you route messages to Lambda functions or HTTP backends and push messages to clients through a callback endpoint, without running socket servers. Other models include hosted Pub/Sub channels and real-time databases that sync documents to clients. These remove most operational work but bring their own constraints. AWS’s published quotas for WebSocket APIs include a two-hour maximum connection duration, a ten-minute idle timeout, a 128 KB message payload limit and a 32 KB frame size, with a default of 500 new connections per second per account per Region. Your client code must therefore expect and handle reconnection as a normal event, and your pricing model must account for per-connection-minute and per-message charges.

Action: map each feature from the previous section to the simplest option that satisfies it. Expect most one-way features to land on SSE or a managed push channel, and only the two-way ones on WebSockets.

Comparison: trade-offs that matter in production

CriterionServer-sent eventsSelf-hosted WebSocketsManaged real-time service
DirectionServer to client onlyTwo-wayTwo-way (varies by product)
Browser supportBroad; native EventSourceBroad since 2015Depends on SDK; usually broad
InfrastructureOrdinary HTTP servers, works with most load balancers; needs HTTP/2 for many tabsStateful servers, sticky sessions or shared bus (Redis, Kafka, NATS), heartbeatsProvider-managed; you write handlers and client code
Reconnection and replayBuilt into the browser; Last-Event-ID enables resumeYou implement reconnect, backoff and replaySDKs often include reconnect; replay depends on service
ScalingScale like HTTP; fan-out via a message busHorizontal scaling needs connection routing and pub/subScales with provider limits (connections per second, payload sizes)
Cost profileCompute and bandwidth onlyCompute, bus, engineering time, on-callPer connection-minute and per message, plus backend compute
Lock-inNone; open standardNone; open standardModerate to high; APIs and SDKs are proprietary
Best forDashboards, notifications, job progress, streaming AI responsesChat, collaboration, games, trading UIsTeams without ops capacity, spiky or unpredictable load

Hidden costs to compare honestly

  • Engineering time: self-hosted WebSockets look free but consume senior engineering effort for scaling and reliability work that managed services absorb.
  • Idle connections: a tab left open all day costs money on a managed service and holds server resources on a self-hosted one. Decide whether to close idle streams.
  • Observability: you need metrics on connection counts, message rates, delivery latency and reconnect storms whichever route you choose.
  • Corporate networks: some enterprise proxies interfere with WebSockets or buffer streaming responses. SSE over HTTPS and a polling fallback protect you here.

Action: estimate three-year cost for your top two options using projected peak connections and message volumes, and include engineering and on-call time, not only cloud bills.

How to decide: a short decision path

  1. Is the feature one-way from server to client? If yes, start with SSE (over HTTP/2) or a managed push channel. Only continue if the answer is no.
  2. Do clients send many small messages per second? If yes, you need WebSockets (self-hosted or managed). If client messages are occasional, SSE plus ordinary HTTP POSTs is simpler.
  3. Do you have, or want, the operations capacity to run stateful servers? If not, choose a managed WebSocket or Pub/Sub service and design around its limits (connection duration, payload size, connection rate).
  4. Are message volumes high and predictable? Per-message pricing can exceed the cost of a small self-hosted cluster at steady high volume. Spiky or low volumes favour managed services.
  5. Is portability a requirement? If you must avoid vendor lock-in (for example, for on-premise deployments or data residency), prefer open protocols and keep provider-specific code behind an adapter.

Illustrative examples

For example, a 30-person logistics firm that wants a live dispatch board might use SSE from its existing Node.js API, with Redis pub/sub fanning out order events to all API instances. Nothing new to operate, and reconnection is handled by the browser.

A B2B SaaS product adding in-app chat between customers and support agents might choose a managed WebSocket service, since chat is two-way, usage is spiky across time zones and the small team does not want to run socket servers. The team designs clients to reconnect transparently within the provider’s connection limits.

A product building collaborative document editing for thousands of concurrent users would likely run its own WebSocket layer with a conflict-free replicated data type library, because latency, ordering and cost at volume justify the operational investment.

These are illustrative scenarios, not client case studies; the right answer depends on your own requirements table.

Action: walk each live feature through the five questions and record the choice and the reason. Revisit when volumes change by an order of magnitude.

Designing the data flow: events, ordering and replay

In our experience, most production problems in real-time features come from data design rather than transport. Agree these points before writing socket code.

Event model

  • Name events by business meaning (order.created, shipment.status_changed), not by UI component. The same event can then feed dashboards, notifications and audit logs.
  • Send compact deltas with identifiers, and let clients fetch full records when needed. This keeps payloads under provider limits and reduces bandwidth.
  • Include a monotonically increasing ID or version on each event so clients can detect gaps and request replay.

Ordering and idempotency

Events can arrive out of order or more than once, particularly after reconnection. Clients should apply updates idempotently (applying the same event twice has no extra effect) and resolve ordering with versions or timestamps from the server. For collaborative editing, use a proven CRDT or operational transformation library rather than inventing conflict resolution.

Reconnection and state recovery

  • On reconnect, either replay events since the last ID (SSE does this almost for free via Last-Event-ID) or refetch current state through a normal API call.
  • Use exponential backoff with jitter so thousands of clients do not reconnect at the same instant after an outage.
  • Design for the connection limits of managed services: a two-hour maximum duration, for instance, means every client will reconnect at least a few times a day.

Authorisation and tenancy

Authenticate at connection time and re-check authorisation on every subscription. In multi-tenant SaaS, channel names must be scoped by tenant and server-side checks must prevent a client subscribing to another tenant’s channel. Expire tokens and handle re-authentication without forcing a page reload.

Scaling fan-out

When you run more than one server instance, an event produced on one instance must reach clients connected to another. Use a message bus (Redis pub/sub or streams, Kafka, NATS or a cloud equivalent) between the producers and the connection-holding servers. This is the same architectural step whether you use SSE or WebSockets. Our article on event streams in core banking modernisation covers event design in more depth, and ticketing and event platforms shows how peak-load thinking applies to live seat maps.

Action: write a one-page event catalogue with names, payload fields, version strategy and replay behaviour, and have both frontend and backend leads sign it off.

Implementation checklist and testing

Before build

  • Requirements table completed: direction, latency, concurrency, reconnection behaviour per feature.
  • Transport chosen per feature with written rationale.
  • Event catalogue agreed; tenant scoping and authorisation designed.
  • Fallback to polling defined for restrictive networks.

During build

  • HTTP/2 enabled end to end for SSE; keep-alive comments every 15 seconds or so.
  • Heartbeats (ping/pong) and idle handling for WebSockets.
  • Reconnection with exponential backoff and jitter; replay or state refetch implemented and tested.
  • Payload sizes checked against provider limits; large data delivered by reference.
  • Message bus in place for multi-instance fan-out; connection routing tested across instances.
  • Metrics: active connections, connect and disconnect rates, message throughput, end-to-end latency, error rates.

Testing

  1. Load test connections at two to three times projected peak concurrency, holding connections open for realistic durations.
  2. Simulate network interruptions: kill connections mid-stream, suspend the browser tab, switch networks, and verify no events are lost or duplicated.
  3. Test fan-out with multiple server instances to confirm every client receives events produced anywhere.
  4. Test authorisation by attempting cross-tenant subscriptions and expired tokens.
  5. Observe cost on managed services during the load test and extrapolate to monthly figures before launch.

Realistic load profiles matter more than raw throughput numbers; our guide to performance testing from real usage patterns explains how to build them.

Action: treat the real-time layer as a product component with its own tests and dashboards, not as a library you switch on.

When to revisit the decision

Real-time architecture is not permanent. Three signals suggest it is time to re-evaluate.

  • Cost curve bends: managed service bills grow faster than revenue as connection counts rise, or self-hosted on-call load outgrows the team.
  • Feature shift: a one-way dashboard product adds chat or collaboration, moving from SSE territory into two-way requirements.
  • Platform limits bite: payload caps, connection rates or duration limits start to shape product decisions rather than serve them.

Keeping transport-specific code behind a thin adapter, with the event catalogue as the stable contract, makes such a migration a contained project rather than a rewrite. That discipline costs little at the start and is the single best hedge against choosing wrongly.

Action: schedule a yearly review of connection volumes, costs and incident history for the real-time layer alongside your other architecture reviews.

Frequently asked questions

Are WebSockets always better than server-sent events?

No. WebSockets are two-way and more flexible, but they are stateful and harder to scale and operate. For one-way updates such as dashboards, notifications and job progress, server-sent events over HTTP/2 are simpler, reconnect automatically and work through ordinary HTTP infrastructure.

Can we use polling instead of a real-time connection?

For modest freshness needs, polling every few seconds is a legitimate choice and is also the natural fallback when networks block long-lived connections. It becomes wasteful at high client counts or when sub-second latency is required.

What limits should we expect from managed WebSocket services?

Expect maximum connection durations, idle timeouts, payload and frame size caps, and limits on new connections per second. For example, AWS publishes a two-hour connection duration, ten-minute idle timeout and 128 KB payload limit for API Gateway WebSocket APIs. Design clients to reconnect transparently and keep payloads small.

How do we scale real-time features across several servers?

Place a message bus such as Redis pub/sub, Kafka or NATS between event producers and the servers that hold client connections, so an event produced anywhere reaches every subscribed client. This applies equally to SSE and WebSockets.

How do we handle users on restrictive corporate networks?

Serve everything over HTTPS, prefer SSE where possible, send keep-alive comments to defeat proxy timeouts and implement a polling fallback that activates automatically when the primary connection repeatedly fails.

Does real-time functionality work in mobile apps as well as browsers?

Yes. Native and cross-platform mobile apps can use WebSockets and HTTP streaming, and managed services provide mobile SDKs. Mobile networks interrupt connections more often, so reconnection and replay design is even more important there.

Sources and methodology

Guidance reflects PoliteTech delivery experience. The external references below informed specific points in this article.

  1. MDN Web Docs: Using server-sent events — accessed 10 November 2026. EventSource behaviour, automatic reconnection, retry field, and the six-connection-per-domain limit without HTTP/2 (100 streams by default with HTTP/2).
  2. WHATWG HTML Living Standard: Server-sent events — accessed 10 November 2026. Last-Event-ID header on reconnection and the recommendation to send a comment line about every 15 seconds to prevent legacy proxies dropping connections.
  3. MDN Web Docs: The WebSocket API — accessed 10 November 2026. Two-way communication model, broad browser availability since 2015, lack of backpressure support and the WebTransport alternative.
  4. IETF RFC 6455: The WebSocket Protocol (December 2011) — accessed 10 November 2026. HTTP Upgrade handshake, ping and pong control frames, and the close handshake.
  5. AWS: Working with WebSocket APIs in Amazon API Gateway — accessed 10 November 2026. Managed WebSocket routing to Lambda and HTTP backends with server-initiated pushes to clients.
  6. AWS: Amazon API Gateway quotas for WebSocket APIs — accessed 10 November 2026. Two-hour connection duration, ten-minute idle timeout, 128 KB payload, 32 KB frame size and 500 new connections per second default.

Which real-time approach fits your product and budget?

Share your live features, expected user numbers and current stack, and we will help you choose and design the right real-time layer before you commit engineering time.