Upstash Realtime 1.2 cuts emit latency nearly in half
Brief
Realtime 1.2 combines event storage and publishing in one Redis script, reducing latency and adding fixes for ordering, reconnects, and duplicate events.
Performance changes
- Median emit() time fell from 2.6 ms in 1.1.1 to 1.4 ms in 1.2.1; time from emit() to a subscriber fell from 2.7 ms to 1.5 ms.
- A sample AI answer streamed in 2.2 seconds with the new version, versus 4.0 seconds with the old version.
- Browsers connected to one server now share one Redis subscription per channel. In a 1,000-client test, delivering the same events used 19x less CPU.
Upgrade details
- The API is unchanged. Upgrade with npm install @upstash/realtime@latest @upstash/redis@latest; @upstash/redis 1.36.1 or newer is required.
- emit() throws an error for events above 1,000,000 characters. From 1.2.1, it requires an Upstash database because stock Redis rejects the script flag.
- On Cloudflare Workers and Vercel Edge, connections still cannot share a subscription.
Generated by AI from the original article. Check the source for full details.