Scaling and Resilience

Goal: Understand when to go beyond a single instance.

Single instance is fine

A single svelte-adapter-uws instance handles tens of thousands of concurrent connections. All the patterns you’ve learned so far work with in-memory state. For most apps, one server is enough.

When you outgrow it

You need extensions when:

  • Multiple instances - load balancer + multiple replicas. In-memory pub/sub only reaches local subscribers.
  • Persistence - replay buffers vanish on restart. Redis persists them.
  • Cross-instance presence - in-memory presence only sees local connections.
  • Rate limiting at scale - per-instance limits don’t work when users hit different instances.

What extensions do

Drop-in replacements. Same API, distributed state.

In-memoryExtension
platform.publish()Redis pub/sub - reaches all instances
Replay bufferRedis sorted sets - survives restarts
PresenceRedis - aggregates across fleet
Rate limitingRedis Lua script - atomic across instances

Was this page helpful?