What we learn along the way

Notes on engineering, research and building a company.

← All articles

A tiny internet in a browser tab

jsflow builds a dynamic mesh network over WebRTC, letting browsers carry one another's messages. Its tests show why routing, sleeping phones and returning participants need different kinds of recovery.

Chapters

Could the browsers in a shared session carry more of the network themselves? That is the question behind jsflow, a dynamic mesh network over WebRTC data channels. Each browser connects to a few others and can forward messages for the rest. Link-state routing finds paths through the room, flooding spreads broadcasts, and end-to-end sealing protects messages addressed to one peer from the browsers that relay them.

Imagine a browser-based real-time strategy game. A fresh snapshot of unit positions might replace an older one, while an order to build or attack needs reliable delivery. The game is hypothetical, not one we have built. It would still need rules for authority and consistent ordering of players' actions.

The intended scale is rooms of roughly 10–50 browsers. jsflow is now a service with a stable 1.0 SDK. Most measurements here were made on the earlier research build, SDK 0.1.2 and a single-region service, which today's service has replaced: 30-browser rooms, repeated departures and returns, and restarting an entire room at once. This is what building and testing that network has taught us.1

Start with the ordinary server

The initial motivation was a cost estimate for relaying game traffic through a service that billed per message. Looking at an ordinary virtual machine changed the comparison: a central relay could be inexpensive. A mesh would have to earn its complexity through something more interesting than that first bill.2

The attraction was giving the room more of its own transport. Nearby devices could use local links, and the application server would not have to distribute every live update. The work shifts to participants, who contribute upload bandwidth and relay processing. That tradeoff matters especially on phones.

There is still a service. It introduces newcomers, authorizes room membership and helps disconnected groups find each other. Some network connections also need a server relay. An application still needs to decide who is allowed to change its state and how conflicting actions are resolved. Moving messages through a mesh does not settle those responsibilities.

WebRTC data channels let browsers exchange application data over an encrypted connection. Underneath, SCTP (Stream Control Transmission Protocol) supplies message transport, and DTLS (Datagram Transport Layer Security) protects the link.3 jsflow adds the machinery for a whole room: membership, a network map, forwarding and delivery between peers that may never connect directly.

Each peer advertises its neighbours and the measured round-trip time of each link. These link-state advertisements, or LSAs, spread through the room. A browser can then run Dijkstra's shortest-path algorithm on its map and decide which neighbour should receive a packet next. The route calculation uses links reported by both ends. The core also supports a penalty for lower relay willingness, but the product client currently gives every peer the same value. Phones have fewer target links; they are not assigned a separate routing penalty, and fewer links do not guarantee less forwarding work.4

Broadcasts use a different rule: pass a packet to neighbouring peers, then suppress copies already seen. This flooding costs extra traffic, but it gives updates several ways through a changing room.

The routing core runs in a dedicated worker, with data channels transferred from the page. This keeps ordinary application work on the main thread out of the forwarding loop.

Three browsers drawn as layer stacks: application, delivery, routing and WebRTC link, with a topology manager beside routing and the link. An update leaves the sender's app as a datagram, is flooded by routing and crosses a direct link to a peer that delivers a copy to its own app and forwards the update over a link relayed by TURN to a receiver. Delivery, routing and topology run in a dedicated worker; the page holds the WebRTC connection. The signalling service connects only to the topology managers, beside the update path. Below, one small map of seven peers twice: a broadcast is flooded, 14 copies across 10 links for 6 deliveries, while a message to one peer follows a single shortest path, one copy per hop.

One update through three browsers. A forwarding peer handles the update at the routing layer, delivers a copy and passes it on. TURN carries data on a relayed link; the signalling service only introduces peers. Below: a broadcast is flooded, while a message to one peer follows one shortest path. A conceptual diagram: the Internet column is an analogy, not a claim of conformance.

The first introduction comes from outside

A browser joining a room initially has nobody to ask for directions. It contacts the signalling service, which checks the application's key and allowed origin and, if the application requires one, a join ticket: a short-lived token the application's backend signs for one user and one room. The service assigns a room address and a signed membership token. The token binds the browser's two public keys, one for key agreement and one for signatures, and a ticket's user id. It also identifies this start of the peer, its incarnation. A fresh page start can therefore be distinguished from an old instance still remembered by other browsers. Waking an existing page preserves its identity.5

One existing member, the room's pool holder, keeps one to four connection offers waiting at the service, more when people have joined recently. The newcomer can take one and answer, getting its first link without starting the offer exchange from scratch. If that path stalls, it races a conventional offer-and-answer exchange with a member supplied by the service.

Once the first link opens, the newcomer receives the room's map. Offers for additional connections can now travel through the mesh itself. The room helps build more of the room.

Finding a usable network path is WebRTC's job. ICE (Interactive Connectivity Establishment) tests candidate paths across network address translators, the routers that sit between private networks and the wider Internet. When a direct path cannot be established, TURN (Traversal Using Relays around NAT) supplies a relay.6

That relay really does carry data. jsflow's signalling service is outside the ordinary message path; TURN is inside it whenever a connection needs it. The service runs signalling and TURN relays in two regions, Stockholm and Ohio, with TURN over UDP and TCP on port 3478 and TLS on port 443. signal.jsflow.com sends each browser to the nearer region. A room has one home; a join that reaches the other region is redirected there, while each browser keeps using its own region's relays.7

A sequence diagram with four lifelines: newcomer, signalling service, pool holder and other members. One: the pool holder keeps one to four offers parked at the service. The newcomer asks to join with its app key, its X25519 and Ed25519 public keys and, if the app requires one, a join ticket; if the room's home is elsewhere, the service redirects the join there. The newcomer receives a room address, an incarnation, a membership token signed over both keys and relay credentials, then opens an inbox for signals. Two: the newcomer takes a parked offer and posts its answer; the pool holder collects it on its next poll, about once a second, and the first link opens after ICE, DTLS and SCTP. If no link is up 0.5 s after asking, the newcomer also races an offer and answer with a live member through the service, at room start one of the three oldest; in the 30-peer lab runs it started in 75 to 87% of joins, and the median from join to first link was 1.1 to 1.6 seconds. Three: the peer the first link reached sends every recent link-state advertisement, each carrying its origin's signed token, so the newcomer has the map and every member's public key, and it floods its own. Four: further offers and answers travel as sealed packets through the room, without the service, until the newcomer has six links, or four on a phone.

The order of a join, from the code. Only the first introduction needs the service; every later offer travels through the room, sealed with keys learned from the map. The 0.5 s race delay and the holder's one-second poll are settings, not measured join times; the one measured line comes from the 30-peer lab runs on the research build.

A room has to keep finding its shape

Connecting everyone to everyone would make routing simple, but every browser would maintain a connection to every other participant. jsflow instead targets six links per desktop peer and four per phone, with a configured cap of eight. It favours nearby peers while making some random choices, so short local links do not leave distant parts of the room poorly connected.8

Even a connected mesh can have a fragile shape. A cut point is a peer whose removal would split the network. In our static graph simulation, about 21–28% of the tested degree-three graphs already had such a point before any failure.9

The live protocol looks for cut points in its map. If one peer is holding two sides together, a designated member on the smaller side adds a link across. The designation matters: asking every peer to repair the same weakness would create another problem.

There was a subtler failure during simultaneous joins. Two groups could form, each well connected internally, with no link between them. Each group's map looked complete because it contained everyone that group knew about. More careful routing over either map could not reveal the missing half.

The fix uses the service's wider view. The lowest-addressed peer in each connected group periodically asks for a member it cannot currently reach. One new bridge lets the maps spread across the gap. Repairing a weak bridge and discovering a separate island are different jobs.8

That discovery mechanism also had a startup blind spot. It originally ignored members younger than ten seconds. During dry runs, some initial receivers waited 11–13 seconds for their first update, even though a link had opened. The SDK now considers members after three seconds and starts retrying on a nominal 2.5-second interval, with jitter and exponential backoff.

A related server-side change addresses how islands start: when a newcomer joins and no member is old enough yet, the service introduces it to one of the three oldest members rather than any member, so two newcomers are less likely to pair up on their own.10

The subsequent 30-peer runs used the SDK change and recorded maximum initial join-to-first-update times of about 2.1–3.7 seconds. The server fallback was deployed later, so it cannot explain those measurements.

Three panels from one simulator run. Sixteen browsers, four of them phones, join an empty room within 0.3 seconds. From 3.1 seconds they form two well-connected groups of 10 and 6 with no link between them; each peer's map lists only its own group and looks complete, while the service lists all 16. At 4.1 seconds peer 0, the lowest address in its group, asks the service for a member it cannot reach and links to peer 2; by 5.95 seconds every map shows all 16, and that single link makes peers 0 and 2 cut points. The ordinary degree rule's link 0 to 4 covers one, and peer 2, the lowest address beyond the other, links to peer 15, so by 7.2 seconds no single peer holds the halves together. Peer 2, the lowest address in the other group, had asked the service too, at 5.4 seconds; its answer adds link 2 to 13 at 7.5 seconds, a second bridge. A timeline below marks each new link by the rule that made it, and both questions to the service.

One simulator run of jsflow's own core with the product client's timers and degree targets (seed 62). Times are simulated; the simulator omits SCTP, queues and bandwidth, and its service introduces newcomers only to members that already have links, which is kinder at room start than the real service. Each group's lowest address asks on its own, so this split gets two bridges.

An animated replay of the same simulator run, ending on its last frame. Sixteen browsers join an empty room and links appear in the order they opened, coloured by the rule that made them: service introductions, cut-point repairs and the degree rule. Two groups of 10 and 6 stay apart until peer 0 asks the service and links to peer 2 at 5.8 simulated seconds; links 0 to 4 and 2 to 15 then cover the cut points. A cursor moves along a 10-second timeline, and a list beside the room highlights each phase as it happens. The still frame shows the room at 10 seconds.

The same simulated run, shown at its final frame.

Two panels. A, simulated: for 200 seeds each, the time until every peer's map lists the whole room after a burst of joiners, at 16 and 30 peers, before and after the island fix. Before it, most rooms were whole in about 3 to 4 seconds, but 55 of 200 rooms of 16 and 73 of 200 rooms of 30 took 11 to 16 seconds. With it, the slow group moves to 5 to 7 seconds: no room of 16 took more than 6.9 seconds, and one room of 30 took 10.8. B, measured in the lab: the slowest first update after an initial join in each run. Before the SDK's half of the fix, six of eight dry runs with 8 or 12 peers were at most 2.51 seconds and two were 11.30 and 12.73 seconds; with it, four 30-peer runs were 2.05 to 3.66 seconds.

Before and after the island fix. Top: 200 simulated rooms per row, in the same scenario as above, at the commits before and after the fix. Bottom: the slowest first update after an initial join in each lab run, before and after the SDK's half of the fix. The lab runs differ in size, browser and app, so they are not a controlled comparison.

Detect fast, close slow

A quiet neighbour creates two questions. Should messages still travel through it? And should its connection be destroyed? Those questions need different timers.

jsflow sends a heartbeat every 250 ms. After two missed heartbeats, it treats the peer as suspect and routes around it. It keeps the connection for up to 20 seconds of silence before closing it. A brief interruption can therefore stop attracting traffic without immediately forcing a new connection setup. Suspect neighbours also stop counting toward the link target. The topology manager can seek replacements on its next cycle, roughly once a second, while the old connection is still being retained. These are settings, not measured recovery times: browser scheduling and connection setup can delay recovery beyond them.

Phones offered a better case than silent disappearance. In two test sessions on one iPhone and one software configuration, all 29 hides with an open data channel delivered a goodbye before the page froze. App switches, tab switches and screen locks could become announced departures.11

The old link sometimes survived a short sleep. Around 17 seconds of silence, the observing desktop browser gave up on it. A returning phone then needed a fresh connection. This browser-level timeout could arrive before our own close timer.

One rejoin failure was particularly instructive. The phone sent a new offer, the other peer answered, and one side even reported that connectivity checks had succeeded. Yet the connection never finished opening. The answer had gone into the phone's old signalling stream, which had died during the lock while the server still held it.

The recovery rule distinguishes browsers that announced a departure from those that may have kept working. Phones and desktop Safari send goodbye on hide and reopen signalling on every return. Other browsers trigger wake recovery after more than 15 seconds hidden. Reopening signalling is part of waking the existing peer, not a fresh join with a new identity.12

Wake keeps still-open links and rebuilds browser-closed ones. It drops all links only after at least 20 seconds away. Here, “away” means hidden time after an announced departure; otherwise it uses the worker's measured pause, since a hidden desktop tab may have kept forwarding. The connection used to reconnect needs recovery too, but a short absence need not discard every surviving link.

Browser behaviour also changes who should relay. Phones relay while the page is in the foreground. Desktop Safari leaves on hide because its background worker can freeze; the tested desktop Chrome configuration could continue forwarding. A worker solves contention with the application, but it does not override the browser's lifecycle.

Two timelines on an axis whose first second is magnified. Silent loss: heartbeats are due every 250 ms; after two are missed, neighbours mark the peer suspect and route around it while keeping the link. A suspect no longer counts toward the degree target, so a replacement link is sought within about a second; the old link is closed after 20 seconds of silence. Announced hide: a phone or desktop Safari sends a goodbye on every link before its page freezes, so neighbours route around it at once. In the phone sessions the observing desktop Chrome gave up on the old link about 17 seconds after the last packet. On every return the phone reopens signalling first. Returns after up to 14.4 seconds found the old links alive and resumed them, one after 17.4 seconds just did; after 18 seconds or more they were gone and were rebuilt through the room, as every link is after 20 seconds away. The peer keeps its address; there is no new join.

Diamonds are settings in the product client; circles are observations from one iPhone and one desktop Chrome observer across two sessions.

Reliability belongs at the ends

Return to the hypothetical strategy game. A unit-position snapshot can supersede an older snapshot; an incremental change cannot necessarily be dropped that way. An order to build or attack needs reliable delivery. jsflow exposes send() for datagrams to one peer, broadcast() for the room and sendReliable() for reliable messages between a pair of peers.13

There is no reliable broadcast: an application that needs to deliver an order to several peers must send it separately to each. Ordering is per pair, with no global order across senders. A game would need its own lockstep or other ordering and conflict-handling rules above the transport.

A reference card for jsflow 1.0, from its code. Join resolves once the service admits the page; a refusal is a JoinError with an HTTP status and a code, such as 403 unknown_app or origin, 409 room_full (retry every 2 to 3 seconds), 429 rate, or ticket_required. A state diagram: joining until a link is live, then connected; away while a hidden phone or Safari page has said goodbye; suspended while the account's spend cap is reached, with links kept; left, superseded or evicted, all final, from any state. A table compares broadcast, send and sendReliable: recipients, best effort or retransmitted, order, 1,052 or 65,536 bytes. Broadcasts are signed but not sealed; send and sendReliable are sealed end to end; sendReliable resolves when queued, not processed. In the hypothetical strategy game, positions go by broadcast, orders by sendReliable to each peer.

jsflow's public API at 1.0, from the SDK's types, page module and worker, with retry advice from the developer guide; 1.1, now a release candidate, adds room.path(). The strategy-game row is the article's hypothetical example. There is no unsealed mode: a browser without the Web Crypto keys the SDK needs is refused before it joins.

Reliability on each individual link is insufficient. A relay can acknowledge receiving a packet and then disappear before passing it on. The source still needs to know whether the destination received the message.

The reliable layer therefore keeps retransmission state at the endpoints. The receiver acknowledges received packets, including ranges beyond a gap, so the sender can retry missing data. This draws on the selective-acknowledgement idea used in TCP.14 Large messages are fragmented and reassembled for ordered delivery; intermediate peers only forward packets.

The contract has limits. A peer that restarts is a new incarnation, so old traffic must not be delivered to it as if nothing happened. A sender reports failure after 30 seconds without progress. The mesh-level sender uses a fixed window without its own congestion controller, which limits how far to generalize from small application messages. And sendReliable() reports whether a message was queued, not whether the other application has processed it.13

A sequence diagram checked against jsflow's reliable layer, with a sender, relays R1 and R2 and a receiver. The sender queues message A, four fragments numbered 6 to 9, through R1. R1 forwards 6 and 7 and vanishes with 8 and 9; the receiver's acknowledgement and the sender's timed resend of 6 are lost with it. Both ends then route through R2. Message B, fragments 10 and 11, arrives; the receiver acknowledges at once, next 6 with selective ranges 6 to 7 and 10 to 11. The sender counts 8 and 9 as lost and resends them through R2, and the receiver delivers A whole, then B. Notes: relays keep no copies; after 30 seconds without progress, or when the receiver restarts, the sender gives up and reports undelivered messages; sendReliable() resolves when a message is queued, not when it has been processed.

A scripted run of jsflow's reliable layer on a simulated clock, with 10 ms per hop and the route change placed at 520 ms. The packets, acknowledgement fields and deliveries are the code's own; the timing is illustrative. Unlike TCP's, the acknowledgement's next moves only past whole messages, so the pieces of an unfinished message appear as selective ranges.

Encryption has a boundary too

WebRTC encrypts a link, but a browser forwarding between links sits inside that protection. jsflow adds end-to-end sealing for unicast messages and in-mesh signalling. Signed membership tokens bind each member's public keys to it. Each pair derives a shared key and uses authenticated encryption to seal its messages. A forwarding peer sees the routing header and ciphertext, rather than the unicast payload.15

Signalling needs that protection too. It carries the information used to establish a new connection. Allowing a relay to alter it would undermine the link being introduced.

Broadcasts and routing advertisements cannot be sealed, because every member must read them. They are signed instead: each carries its origin's Ed25519 signature over header and body, and every peer checks it before delivering, storing or forwarding. A forgery in another member's name stops at the first peer it reaches; in browser tests in Chromium and Firefox, forged broadcasts were delivered nowhere.16

A signature proves who sent a packet, not that it is true. A member can still read every broadcast and the routing header of what it forwards, so it learns who talks to whom. In the strategy game, a player could broadcast false positions for its own units. A member can also drop or delay what it relays, draw routes toward itself by misreporting its links' round-trip times, and load the room with valid broadcasts. Join tickets tell peers which user is behind each member, and the application's backend can evict one. This is still not a basis for rooms of mutually hostile participants; game authority stays with the application.

Direct connections can also expose network addresses to other peers. Forcing TURN relay mode changes that privacy tradeoff at the cost of relay bandwidth and an additional network path. Encryption, membership and address privacy are separate properties.

Three parts. A two-hop path where each WebRTC link is encrypted by DTLS while unicast is also sealed end to end: the forwarding peer sees the routing header and ciphertext, not the payload, and the header with its TTL zeroed is authenticated. The signalling service signs each member's token over its X25519 and Ed25519 public keys; tokens travel in link-state advertisements, members check them, and each pair derives a 128-bit AES-GCM key with X25519 and HKDF, with a new epoch after 2 to the 31st packets or two hours; private keys never leave the worker. A table: unicast data, reliable messages and in-mesh signalling are readable only by the two ends and cannot be forged or replayed by another member; the routing header is readable by forwarding peers, who learn who talks to whom; broadcasts and routing advertisements are readable by every member and signed by their origin with Ed25519, checked before delivery or forwarding, so no member can forge them in another's name, though a member can send false content as itself. Heartbeats and goodbyes are not signed, but they act only for the link they arrive on. A box lists what an admitted member can still do: read broadcasts and forwarded headers, send false content as itself, draw routes by misreporting its own links but not invent one, drop or delay packets, since sealing and signing give privacy and integrity, not delivery, and load the room with valid broadcasts.

Link encryption protects each hop from outsiders; sealing protects unicast from the peers that forward it; signatures stop a member forging broadcasts or routing advertisements in another's name. Any member on a path can still drop or delay packets. The service is trusted to bind keys to members. Drawn from the code.

The packet counter that outlived the demo

A short demo can hide a clock inside a protocol. Our early header used a 16-bit sequence counter shared by packet types. When it wrapped, the duplicate-suppression logic could mistake new packets for old ones. That affected both broadcasts and the routing updates needed to maintain the room. Review exposed the flaw.17

The header grew from eight to ten bytes, with a 32-bit sequence number. Duplicate suppression now uses a sliding window and wrap-aware comparisons, and state distinguishes peer incarnations. Making the counter wider was only part of the repair; the protocol still had to define what happened at the boundary. Today's wire version 2 keeps that layout and puts a signature block at the start of every flooded packet.

The soak tests now start counters near that boundary so they cross it during the run. Waiting for a naturally occurring wrap would make a poor regression test. A packet diagram is also a map of the assumptions that have to survive a long session.

A bit diagram of one header packed by jsflow's code: an update broadcast by peer 7. Byte 0 holds version 2, type DATA and incarnation tag 5, the low three bits of incarnation 13; byte 1 holds TTL 14 and channel 2. Bytes 2 and 3 are the source, 4 and 5 the destination 0xFFFF for everyone, and 6 to 9 one 32-bit sequence number six below the wrap. Below: a broadcast carries a 65-byte signature block, a scheme byte and a 64-byte Ed25519 signature, then up to 1,052 bytes of app data; a sealed unicast adds an epoch byte and a 16-byte tag around its app data; a reliable-message piece carries its own prefix and ACK and DATA blocks inside the ciphertext. Then the duplicate window's answers across the wrap: newer packets accepted, including 0 after 2 to the 32nd minus 1; repeats dropped; a late packet inside the window accepted; one more than 1,024 behind dropped.

A header packed by jsflow's header code for wire version 2, and the duplicate window's answers across the 32-bit wrap. The layout is the implementation, not a published wire specification.

Test the room, then test getting back into it

The same core protocol code runs in a discrete-event simulator and in browsers. That makes the simulator useful for topology and failure scenarios. It still omits important transport behaviour, including SCTP, queues and bandwidth limits. We check its ideas against real browsers, controlled network delay and loss, and phone sessions.

The longer tests repeatedly kill peers, bring them back, announce departures and introduce bursts of newcomers. Delivery averages alone are insufficient: the test also checks the worst peer, recovery, joining and whether state remains bounded.

Table 1 collects results from distinct tests, all on the research build. The 30-peer soak ran for three hours in Chrome on one Mac mini, with sealing and churn. The earlier product-client and service tests used Linux Chromium peers on one host; the later 30-peer service tests used Chrome on one Mac mini. Direct traffic stayed on the host; TURN traffic went to the Stockholm relay and back. These desktop timings describe those paths, not players spread across the Internet. Here, p95 is the 95th percentile.

The broadcast measurements use one sender at 10 updates per second. The product tests send 150-byte updates and add light reliable traffic. They do not measure a room in which every player broadcasts at once.

First, one copy of a 150-byte update drawn to scale on the wire: the 10-byte header and the 65-byte signature block from jsflow's code, then assumed SCTP, DTLS and UDP/IPv4 overhead, 321 bytes in all. Second, on a log scale, the copies one peer sends each second in a 30-peer room. With one sender at 10 updates a second: 30, 50 or 70 with 4, 6 or 8 links, at most 180 kbit/s. With all 30 sending: 910, 1,510 or 2,110, up to 5.4 Mbit/s. Beside them, measured relay rates from the research: desktop Chrome forwarded at least 32,000 messages a second; an iPhone relayed 7,979 of 8,000 small ones.

Computed, not measured: the copies of each update a browser passes on under flooding, from jsflow's header and signature sizes plus stated assumptions for SCTP, DTLS and UDP/IPv4. The relay rates beside them were measured in the research on a single relay path, not in a room. The degree-eight case uses the configured cap, which a connection change can briefly exceed.

TestHeadline observationOverall gate
30-peer soak99.94% broadcast deliveryPass18
Eight-peer client1,847/1,847 reliable messages owedPass19
12-peer direct, after slot fix8 ms update p95Pass20
16-peer TURN, before slot fix17 ms update p95Join failure20
30-peer direct, with churn100% delivery; 7 ms update p95Pass21
30-peer TURN, with churn99.66% delivery; 16 ms update p95Pass21

The soak's worst peer received 99.69% of eligible broadcasts, and the maximum measured healing time was one second. The client test recorded no duplicate or out-of-order reliable deliveries; seven give-ups to departed peers were accounted for separately. In the earlier service tests, whole-window update delivery was 100% for the 12-peer direct run and 99.96% for the 16-peer TURN run. Good delivery figures did not make the latter run pass.

Two panels from separate lab tests. A: three hours with 30 desktop Chrome tabs, sealing on and scripted churn; broadcast delivery per minute stays between 99.68 and 100 percent, above a 99 percent gate, through 160 silent kills, 125 leaves, 248 goodbyes and 105 forced counter wraps marked below the line; overall 99.94 percent, worst peer 99.69 percent, every gate passed. B: five research-service churn runs; each dot is one restarted browser's wait from its first join attempt to its first update, on a log scale. Before the slot fix, 16 peers direct: p95 90.9 seconds and four never got in; through TURN: p95 61.0 seconds and seven never got in. After the fix, 16 peers at the room's cap: p95 8.47 seconds, none stalled, but 78 refused joins still fail the join gate. A separate 12-peer run with headroom: p95 1.83 seconds, no refusals, pass. 30 peers in a room capped at 50, on another host: p95 1.76 seconds, no refusals, pass. Update delivery was 99.96 to 100 percent in every run.

Two lab tests on the research build that should not be read as one. A: 30 Chrome tabs on one Mac mini; delivery counts peers present when each update was sent. B: browsers on one host per run against the research service, with one sender at 10 updates a second.

The service tests found a gap between a healthy message path and a usable room. When a browser disappeared, the service held its place for 60 seconds. A replacement could find the room full even though a player had left. In the 16-peer direct-link run, the p95 wait from a respawn's first join attempt to its first update was 90.9 seconds; four returning browser instances never got in.20

The fix shortened the hold to 15 seconds after the stream closes and added an explicit leave, including a beacon when the page unloads. In the repeated 16-peer test, the p95 fell to 8.47 seconds and every returning instance eventually joined. It still failed the strict gate because join attempts were rejected while the room sat at its capacity. The 12-peer test with headroom passed, with a return-to-first-update p95 of 1.83 seconds. Since then, a page that has said goodbye on hide holds no slot at all, and a full room answers with an explicit room_full code.

The later 30-peer churn tests also had headroom: the room's cap was 50. Both the direct and forced-TURN runs lasted 15 minutes and passed without join refusals. All reliable messages counted as owed were delivered: 4,751 in the direct run and 4,752 through TURN.21

The TURN run's 99.66% delivery and 16 ms p95 coexisted with loss bursts and a maximum received-update latency of 894 ms. The relayed path crosses the lab's uplink as well as TURN, and probes in the same campaign found stalls to the service and to an outside address, so the test does not isolate relay quality.

A heatmap of 29 receivers against the 15 minutes of a lab run in which every link went through TURN. Missed updates form vertical columns: in 27 seconds, 20 or more receivers missed an update at once; 983 of 247,190 owed updates were missed. Links that were suspected and recovered, 1,047 in the run, often spike in the same seconds. Folded onto the wall-clock minute, 813 of the missed updates were sent in the seconds :19, :20, :49 and :50, where latency p99 rose to 267 to 533 ms against 15 to 26 ms otherwise. The same churn with direct links missed nothing and stayed at 3 to 10 ms.

Measured in the lab on the research build: one 15-minute run with every link relayed through TURN, beside the same run with direct links. Relayed traffic crosses the lab's uplink, so this measures that uplink as much as TURN. Why the stalls fall around :20 and :50 is not known.

We also tested restarting the whole room. In one run, all 30 browser processes were killed. In another, all 30 pages reloaded, allowing the normal leave path to run. Both returned after a scripted delay of five to ten seconds. After the process kills, the whole room was back in 18.68 seconds, with 20 temporary “room full” refusals. Reloading took 12.20 seconds, with none. Recovery measures from the mass departure until the sender had joined and every other peer had received its first update, including the scripted downtime.22

Swimlanes, one per browser, from two lab runs in which all 30 browsers of a room dropped at once and came back after a scripted 5 to 10 seconds. A, every process killed: the service still held all 30 old slots, so 20 browsers joined at their first try and 10, the sender among them, were refused twice with 409 room full until the slots expired at 15 seconds. The sender joined at 16.18 seconds, 26 receivers got their first update together at 17.78, and the whole room was back at 18.68 seconds. B, every page reloaded: no slot held, no refusals, whole room back at 12.20 seconds.

Measured in the lab on the research build: 30 Chrome browsers on one Mac mini with direct links and one sender; these are process kills and page reloads, not a network outage. Times run from the drop and include each browser's scripted downtime. A killed browser's slot stays held for 15 seconds, so the kill run waited on refusals and on its sender; on reload, the leave each page sends freed its slot at once.

Both passed their declared recovery gate of 30 seconds. The crash test allowed temporary capacity refusals while old slots expired; the reload test required none. That is a different gate from the earlier strict churn test, where any refusal failed the run.

Delivery was 100% in the measured windows before and after both mass restarts. Those windows exclude the outage and a one-second guard at each boundary, so the figure does not mean uninterrupted delivery.

What the room taught us

The work has produced a network that can form a room, route messages, recover from tested failures and give applications a choice of delivery rules. The most useful lesson has been to separate the lifetimes involved: a route can stop using a peer before its connection is closed, and its place in the room has another lifetime again. Each decision needs evidence of its own.

Since the research build, jsflow has become a service with a stable API. It runs in two regions, can admit users by the application's own join tickets, and signs everything that floods, so no member can speak for another. Desktop Firefox has been tested beside Chromium, including with signed broadcasts.23

The same design might suit collaborative editing: transient cursors and presence could use broadcasts, while edits travel reliably to each relevant peer. The application would still supply conflict resolution. The question that started it remains concrete: how much of a shared experience can the devices in the room carry together?

Try it in the live demo. Open a room on up to four devices and chat between them, directly where the network allows. Nothing is kept.

Open a room and chat across your devices in the browser: try the live jsflow demo at jsflow.com/try. Up to 4 devices, direct first, 10-minute rooms, nothing kept.

Footnotes

  1. The results cover the stated lab configurations, on desktop browsers unless a phone is named. They are not measurements of a deployed game or of a room of phones. ↩

  2. The cost comparison was an estimate for the proposed workload. This article makes no current pricing or zero-cost claim. ↩

  3. RFC 8831: WebRTC Data Channels describes the SCTP-over-DTLS data transport. Those protections apply to a WebRTC connection, not automatically to a multi-hop application overlay. ↩

  4. The product worker leaves the core’s default willingness of 7 unchanged for all peers. ↩

  5. The first-link paths race after 0.5 s. Attempts are separately identified so a late answer cannot be applied to a newer offer. ↩

  6. RFC 8445: Interactive Connectivity Establishment and RFC 8656: TURN describe candidate-path checking and relay operation. Relay use depends on the network pair and policy; the lab does not establish a population-wide relay rate. ↩

  7. TURN on port 443 does not promise passage through every restrictive network. A join follows a room's home at most twice. The measurements in this article ran against the earlier single-region research service in Stockholm, not the two-region service. ↩

  8. The candidate-selection policy chooses nearby peers 70% of the time and random peers 30%, subject to compatibility and the available map. ↩ ↩2

  9. The degree-capped random generator used 200 trials per cell, with room sizes 10, 20, 30, 50 and 100. This static experiment does not model latency or ongoing repair. ↩

  10. November 1 results. The nominal 2.5 s retry doubles up to 60 s, with a 0.8–1.2 jitter multiplier. The server fallback applies to a newcomer joining when there are no age-eligible candidates and no exclusions in the request. Island-discovery checks always send an exclusion list, so this fallback does not apply to them. The four 30-peer runs used SDK code from 6acc238 with service 16432fa; they include the SDK timing fix but precede the server fallback's deployment at ec4ce62. Their maximum initial join-to-first-update times were 3,657, 2,659, 2,108 and 2,050 ms. ↩

  11. The 29/29 denominator is hides with an open channel on one phone across two sessions; hides without an open channel are excluded. ↩

  12. The worker requests signalling reopen as part of wake; it does not await a fully opened stream before all other wake actions. The full-link reset threshold uses hidden time after goodbye, otherwise measured worker timer gaps. Neither wake nor reopening signalling assigns a new peer ID or incarnation. ↩

  13. The API allows 1,052 bytes per datagram (1,099 in 0.1; the difference makes room for the broadcast signature) and 65,536 bytes per reliable message. sendReliable() resolves to a queue-admission boolean; an undelivered event reports later failure. This is not durable application-level exactly-once processing. ↩ ↩2

  14. RFC 2018: TCP Selective Acknowledgment Options explains acknowledging received ranges beyond a gap. jsflow borrows the idea, not TCP itself. ↩

  15. The implementation uses X25519 key agreement, HKDF key derivation and AES-GCM authenticated encryption for sealing, and Ed25519 for signatures. The service is trusted to issue membership tokens. Heartbeats and goodbyes are not signed, but a peer acts on them only for the neighbour whose own link carried them. ↩

  16. Six- and eight-peer rooms in headless Chromium 155 and Firefox 153 ESR, on wire version 2 before the 1.0 release. Median latency was 0.7–1.1 ms at one hop and 4–5 ms at two, signature checks included. ↩

  17. The header's three-bit incarnation tag is distinct from the full incarnation used elsewhere. ↩

  18. Chrome 155 on one M5 Pro Mac mini; sealing and offer pool enabled, churn and forced counter wraps. Broadcast delivery counts eligible connected peers, excluding absence and a three-second recovery grace period. Healing is the analyzer's post-kill unicast-loss measure for surviving pairs. ↩

  19. Eight Chromium 155 peers on one Linux host in a capped container, four minutes, reliable traffic at two messages per second per peer. The product service ran through the harness. Delivery accounting excludes the reported give-ups to peers removed by churn. ↩

  20. The cited churn runs last ten minutes, send 150-byte updates from one broadcaster at 10 Hz, kill two peers every 30 s and restart them after 10 s, and kill the broadcaster once. Direct data paths are host-to-host on one Linux machine; relay paths travel to the Stockholm TURN service and back. Latency uses the shared host clock. Whole-window delivery counts receivers present throughout the measurement window. The return timing runs from the respawn's first join attempt, including retries, to its first received update, excluding the scripted downtime. l-n16-churn reports 90,873 ms, l-n16-churn-2 8,467 ms and l-n12-churn-2 1,831 ms at p95. Reliable delivery figures also exclude give-ups to the deliberately killed broadcaster. ↩ ↩2 ↩3

  21. Thirty independent Chrome 156.0.8078.79 instances on one M5 Pro Mac mini, one outbound network, room cap 50, SDK v0.1.2 code copied locally from 6acc238, service 16432fa. Both 15-minute runs used the same 150-byte, single-broadcaster 10 Hz workload and churn schedule as the earlier tests. Delivery here counts receivers present throughout the window: ten direct and five relay receivers. Delivery across churned lifetimes is a separate 100% and 99.59%. Reliable delivery counts messages owed; it does not include give-ups to departed peers. The uplink probes were taken during the later mass-drop test. ↩ ↩2 ↩3

  22. Same 30-peer Chrome host, cap and builds as the churn tests; direct links, eight-minute runs, mass departure at 180 s. Return delay is 5 s plus 0–5 s jitter. Whole-room recovery is 18,678 ms after kill and 12,203 ms after reload, including downtime: sender joined, all 29 receivers have a first update. There were 20 capacity refusals and retries after kill, none after reload, with no missing peers. Delivery windows stop 1 s before the drop and start 1 s after whole-room recovery; both report 100% across 29 receivers. Reliable messages owed were 2,563/2,563 and 2,599/2,599. ↩

  23. Firefox 153 ESR passed the join, relay-candidate, sealed-message and broadcast checks on SDK 0.1.3, alone and in a room with Chromium, and the signed-broadcast forgery test on wire version 2. ↩

Keep readingTrained 4-bit versus rounded 4-bit on a MacWe asked an AI to write weights. Writing code worked better. ← All articles
100%