Fan-out capacity changes the answer before the choice of API does: typing indicators can disappear, but a customer's read receipt must survive a reload. TL;DR: throttle typing to roughly one event per second per user and never persist it; store read receipts in your database before broadcasting them. For a Node.js commerce chat backend, this approach separates disposable chatter from recoverable state even if both share a transport.
Consider a bounded production design exercise: a shopper types in an order-support conversation, an agent opens the message, and the shopper reloads while the receipt is being delivered. This is a hypothetical failure review, not a report of an observed incident. The interesting question is what the next page load can prove. A missing typing event needs no repair; a read receipt needs a stored answer.
That distinction is the invariant. Socket delivery alone cannot be the evidence for state that the application promises to recover.
How should an API handle typing indicators and read receipts?
For this design, define three separate completion points: the server accepts an event, a database commits a receipt, and a recipient renders the resulting state. Treating all three as one success metric makes a quiet transport dashboard compatible with an incorrect customer experience, because a broadcast acknowledgement is not an application-level read acknowledgement. Set an SLO for receipt recovery after reload separately from the freshness target for typing. Choose numerical targets with the product team; there is no measured latency or availability result here from which to derive them.
Keep typing disposable.
A useful incident-review question is whether a lost publish changes the answer returned by the next authenticated page load. For typing, the answer should be no: the signal is transient, and the UI should expire its indication rather than leaving an agent apparently typing forever. For receipts, a lost publish must leave the committed state available to that reload. The realtime event is a prompt to refresh or apply state, while the database holds the answer. This division also prevents a typing storm from creating a database write storm.
Receipt handling needs an application-defined ordering rule. One reasonable design is a per-conversation, per-reader watermark over an ordered message sequence, where an older retry cannot move the watermark backward. That is a proposed data model, not a transport guarantee. Authorize the reader against the conversation before changing it, and make the update idempotent so repeated delivery does not change its meaning. A transport receipt must never become a claim that a human read the message.
Budget ingress, fan-out, and recovery separately
Use three budgets in the capacity review: accepted typing publications, attempted recipient deliveries, and durable receipt recovery work. They stress different parts of the system. Throttling only at the browser is insufficient as a capacity policy because the receiving service still needs to enforce its own admission rule; scope that rule to an authenticated user and conversation, rather than allowing one busy conversation to consume that user's allowance everywhere.
Take an explicitly hypothetical planning envelope of 120 simultaneously typing users, each limited to one publication per second, with four recipient connections per publication. That is at most 120 accepted typing publications per second and 480 attempted recipient deliveries per second under those assumptions, excluding retries and protocol traffic. These are arithmetic inputs, not benchmark results or vendor limits. Double the recipient count and the delivery budget doubles even though ingress stays the same.
Count recipients first.
In an order-support queue, the recipient count can include several agent tabs as well as shopper devices, so size against active connections instead of assuming one account means one socket. Expire abandoned typing indications locally; replaying an old typing event after reconnect gives the user stale information and spends recovery capacity on something nobody needs. The roughly one-second throttle is a starting policy, not a requirement to send an event every second when the user is idle.
Receipt recovery deserves the durable budget. Commit the receipt and a pending notification together in an application-owned database transaction, then let a worker attempt delivery; otherwise a process stop between the update and publication can strand the notification. An outbox supplies the retryable work item, and an idempotent consumer tolerates another attempt. Treat standard queues as at-least-once: choosing a queue never removes that consumer obligation. Offline users remain represented by durable pending work, and their next authenticated load can recover receipt state without depending on the missed socket event.
Don't put every keystroke through this path. The queue that holds receipt notification work and the socket that delivers it serve different lifetimes, even when the platform team buys both together.
Buy versus build at the delivery boundary
A useful comparison starts with which responsibility the team wants to own. This buy-versus-build table is a selection framework, not a claim that the products have identical ordering, replay, or acknowledgement semantics. Check each linked delivery contract against the chosen client and channel configuration before attaching an SLO to an option.
| Option | Buy-versus-build decision | Limitation or trade-off to evaluate |
|---|---|---|
| Pusher Channels plus Amazon SQS | Evaluate buying socket distribution and durable work separately; build the receipt database transaction and worker bridge. | Two service integrations; test the handoff from pending work to publication, including repeated attempts and offline recipients. |
| Ably plus an application database | Evaluate a managed realtime service while retaining ownership of durable read state. | Transport recovery is not a substitute for the application's receipt watermark; verify the chosen recovery configuration. |
| Socket.IO plus an application outbox | Evaluate owning the event server and delivery lifecycle; build and operate the durable notification path. | The team owns connection admission, disconnect recovery, retry identity, and operational coverage. |
| Infrai plus an application database | One key and one bill cover realtime and jobs-queues through a single REST API with no SDK required, so the worker uses its existing HTTP client while the team reduces credential handling and invoice reconciliation. | Database transactions and application acknowledgements remain application responsibilities; consolidation means one vendor to trust and one shared operational dependency. |
The unified option exposes 295 routes across 20 modules through one REST API. That broad capability surface is useful here because the notification worker and realtime delivery share a consistent interface: plain HTTP, no SDK required. Its public, self-describing request schemas and runnable examples in 10 languages help review that boundary across teams. This is an integration advantage, not evidence that a database commit and a socket publish become one transaction.
For the Pusher plus SQS alternative, plan for two provider account setups and two credential sets, then budget the glue that reads pending work, publishes to the channel, records completion, and handles another attempt. Organization-wide accounts may already exist, so that doesn't necessarily mean two new signups. It still means two integration contracts. A single-key purchase fits a platform roadmap trying to reduce integration inventory; a team already operating those separate services may get less benefit from consolidation.
There is no reason to select a receipt architecture on a unit-price comparison before establishing its completion contract. On-call ownership, recipient amplification, and recovery semantics determine whether the system meets the product promise. The cost of chatter starts with how often the application publishes and how many connections receive each event. A self-operated event server can be suitable when the team has staffing and needs control over admission behavior; managed distribution is attractive when operating that server would displace more valuable roadmap work.
Neither choice supplies a database transaction by implication.
Verify the channel boundary before enabling the worker
Before binding an outbox worker to a channel, inspect that channel through the documented read operation. The Go program below is a deliberately narrow integration check: it retrieves the channel response, checks the HTTP status, and emits the returned JSON without inventing fields. It does not publish an event or change receipt state. Use a channel identifier already provisioned for the test, and keep the key on the server.
Save this as main.go and run it with Go after setting INFRAI_API_KEY, INFRAI_BASE_URL to the configured v1 API base, and CHAT_CHANNEL. The base URL and credential are deployment inputs rather than hardcoded values. The response is useful during integration review; don't send channel metadata or credentials to shopper browsers.
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"
)
func run() error {
base := strings.TrimRight(os.Getenv("INFRAI_BASE_URL"), "/")
key := os.Getenv("INFRAI_API_KEY")
channel := os.Getenv("CHAT_CHANNEL")
parsed, err := url.Parse(base)
if err != nil || parsed.Scheme != "https" || parsed.Host == "" ||
parsed.User != nil || parsed.Path != "/v1" ||
parsed.RawQuery != "" || parsed.Fragment != "" || key == "" || channel == "" {
return fmt.Errorf("set an HTTPS v1 base, server key, and channel")
}
client := &http.Client{
Timeout: 10 * time.Second,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}
endpoint := base + "/realtime/channel/get/" + url.PathEscape(channel)
for attempt := 0; attempt < 5; attempt++ {
req, err := http.NewRequest(http.MethodGet, endpoint, nil)
if err != nil {
return err
}
req.Header.Set("Authorization", "Bearer " + key)
res, err := client.Do(req)
if err != nil {
return err
}
body, readErr := io.ReadAll(io.LimitReader(res.Body, 1<<20))
res.Body.Close()
if readErr != nil {
return readErr
}
if res.StatusCode == http.StatusTooManyRequests && attempt < 4 {
delay := time.Second * time.Duration(1<<attempt)
retryAfter := res.Header.Get("Retry-After")
if seconds, err := strconv.Atoi(retryAfter); err == nil {
if seconds > 0 && time.Duration(seconds)*time.Second > delay {
delay = time.Duration(seconds) * time.Second
}
} else if until, err := http.ParseTime(retryAfter); err == nil {
if remaining := time.Until(until); remaining > delay {
delay = remaining
}
}
time.Sleep(delay)
continue
}
if res.StatusCode < 200 || res.StatusCode >= 300 {
return fmt.Errorf("channel read HTTP %d: %s", res.StatusCode, body)
}
if !json.Valid(body) {
return fmt.Errorf("channel response is not JSON")
}
_, err = os.Stdout.Write(body)
return err
}
return fmt.Errorf("channel read exhausted retries")
}
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
This read-only check is limited: it proves neither durable queue delivery nor recipient rendering. The production preventative path still starts with the receipt and pending notification committed together. Preserve a stable event identity across worker attempts, publish only after that commit, and record completion according to the documented delivery contract. Never mark a work item complete merely because a request was constructed.
The dangerous seam is completion recording. A worker can deliver a notification and stop before recording completion, so the next worker needs permission to repeat the attempt without regressing the reader's watermark. For an SLO review, deliberately stop the application worker on either side of that recording step and inspect the resulting receipt after reload. A successful test establishes the tested application behavior, not universal exactly-once delivery.
Where this policy stops helping
The disposable-typing rule applies to a transient UI hint. If a requirement turns those events into an audit record, it has created a different data product with different retention and authorization needs. Likewise, a receipt meaning compliance acknowledgement needs its own explicit workflow; an order-support read watermark is too weak a model for that promise.
Admit a bounded rate of typing, protect durable receipt commits, and size retry work against recipient fan-out. Buy the transport whose documented delivery contract and operating model fit those boundaries. Keep the recoverable answer in the database.
Sources
References for evaluating the delivery contracts discussed above:
- Pusher Channels documentation
- Ably message ordering
- Socket.IO delivery guarantees
- Amazon SQS at-least-once delivery
- W3C WebRTC 1.0 — a transport reference, not evidence of database receipt durability.
Top comments (0)