Skip to main content
Architecting Software in 2026 · 6 of 7 partsEngineering18 min read

The Market Open: Where the Work Waits

At the market open, a backlog that built all night is released at once. At a peak every request runs now, waits for capacity, or degrades, and architecture is choosing which before the peak does. In Part 5, Bullpen queues orders for the open in Postgres instead of a queue service, streams prices with SSE, separates read and order pools, and decides its degradation order in advance. I wrote the predictions down first, ran the open under load locally, and graded them, including the one that was wrong.

← All Posts
2/4

At the market open, 9:30 in the morning New York time, a backlog that has been building all night is let go at once. Orders placed while the market was closed are released together, and every player opens the app to watch them fill. Nothing arrives gradually.

At a peak like that, every request has three possible outcomes. It runs now, because capacity is free. It waits for capacity, stored somewhere durable or retried by the caller. Or it degrades: the system returns something less fresh, switches a feature off, or refuses safely. Architecture at a peak is choosing where the work waits before the peak chooses for you.

This is Part 5 of the Bullpen build. It follows the Part 4 saga and the bonus on a requirement that arrived mid-plan. Week one predicted that this part would need a "Market Open Queue" and a workflow engine to drive orders. I wrote down what I expected to break before running anything, then built the open, ran it, and graded the predictions.

Peak load at the market open is a released backlog, not a ramp

Load at the open has a shape, and the shape decides the architecture.

  • The backlog is real. An American retail broker queues a market order placed out of hours "for the start of regular market hours" (Robinhood's market order page). Every one of them becomes eligible at the same moment.
  • The first half hour is dense. NYSE measured the 9:30–10:00 window at 11.0% to 12.6% of the day's U.S. equity volume, not counting the opening auction itself (NYSE data insights, December 2021). That is about 8% of the session carrying 11% to 13% of its trading.
  • The open isn't one instant, even on the exchange. On NYSE each stock opens when its market maker opens it, over seconds to minutes after 9:30 (NYSE opening process fact sheet). The exchange spreads its own burst.

The failures that make the news share a pattern. In May 2021, during a sharp crypto drop, Coinbase's nginx hit its connection cap, its GraphQL tier "autoscaled too slowly", and its payments queue backed up. Their fixes were spike load tests and kill switches for client features (Coinbase post-mortem). A year earlier, a Coinbase rollback had to fight a thundering herd during recovery, as everything restarted at once (Coinbase, November 2020). In both, load arrived faster than the system could absorb it, and the system had no decided place for the extra work to go.

So Bullpen now has a real backlog. A stock market order placed while the market is closed is accepted, its buying power is reserved under Part 4's rule, and it waits in a new state, queued_for_open, until 9:30 ET on the next trading day. The market calendar knows weekends, NYSE holidays and daylight-saving changes.

Predictions first, and what this test can and can't say

I committed the predictions file on its own, on November 12 at 19:12 UTC, before any load script existed. The commit time is the proof. Three ideas shaped how the test was built, and they're worth more to a reader than the results.

Test with traffic that doesn't wait. Most load testing tools are closed-loop: each simulated user sends a request, waits for the reply, then sends the next. When the system slows down, the tool slows down with it and sends less, which hides exactly the failure you're testing for.

Gil Tene calls this coordinated omission. A crowd at the open is the opposite: a thousand players, short sessions, nobody waiting politely. Schroeder, Wierman and Harchol-Balter showed that at the same load, an open system's response time can be an order of magnitude worse than a closed one's (NSDI 2006).

So every scenario used k6's arrival-rate executors, which send at a fixed rate whatever the replies do (k6 docs on open and closed models). Each run also has a threshold on dropped iterations: requests the tool should have sent but couldn't.

Size with Little's Law, and look for step limits. In flight = arrival rate × time in the system. Smooth curves don't break systems; steps do. The steps I listed were Vercel's 1,000 concurrent executions per 10 seconds per region, then a 503 (Vercel concurrency scaling); 1,024 file descriptors per function instance (Vercel limits); and Neon's 112 connections at 0.25 CU (Neon connection pooling).

Say what the numbers are. Every load number in this post comes from one machine, and the raw results are in the repo under post-facts/part-05-runs/. On it ran k6, a stand-in for the trading app, the real sweeper and Postgres, together on four cores. The stand-in shares everything below the route handlers with the deployed app (pools, lifecycle, sweep, price stream, leaderboard read) but not Next.js, sign-in or Vercel's limits. "Quarter core" means the database processes were throttled to a quarter of one core, an approximation of Neon's 0.25 CU.

Every run started from a league with history: 1,000 players, 20,000 past orders. The runs used Postgres 16; I reran the 9:30 step and the multixact race on Postgres 18, and the results matched (order p95 29 ms, drain about 56 seconds, no errors). This is application capacity under simulated constraints. No number here is a claim about 1,000 users on the hosted app, because I haven't run that.

Decision 1: where queued orders wait

Conditions. Part 4 decided the order lifecycle lives in Postgres: the order row is the state, and each step is a conditional update in one transaction (ADR-0017). The open adds a different question. It isn't where an order's state lives; it's how a burst of eligible orders gets admitted without swamping the capacity behind them. Lifecycle and admission are separate architectural problems, and the second doesn't reopen the first.

Options.

  • A queue service. What week one predicted. Vercel Queues is still in beta in November 2026: at-least-once delivery, approximate ordering, no built-in dead-letter queue (Vercel Queues concepts). The order would then live in two places, the row and the message, with a handoff between them.
  • The order row as the queue. queued_for_open is a state. At the open, the sweeper admits the oldest queued orders in fixed batches, and each admission is the same kind of conditional update every other step uses.
  • Admission control at the door. Refuse new orders above a rate. It protects capacity but turns waiting into refusing, which is the wrong outcome for an order a player placed on purpose.

Choice. The row is the queue. The sweeper wakes for the open even after its idle back-off, then admits 100 orders per pass, oldest first, one pass every 5 seconds.

Why. The order already exists durably the moment it's accepted, so a second store adds a handoff and nothing else. The word "queue" also covers very different jobs. The bonus's review queue holds under 10 handles a week until a person looks; it exists for human latency. This backlog exists for throughput: a thousand orders that are all ready and need pacing. Neither needed a queue service.

What it measured. On a full core, after the index fix described in the next section, with 1,000 orders queued, plus 50 new orders a second and 1,000 screens polling every 3 seconds from the open:

MeasureValue
Sweeper wake after the open506 ms
Backlog drained1,000 of 1,000 in 55.9 s
New-order latency p50 / p95 / p9914 / 29 / 46 ms (orders alone: 13 / 18 / 32 ms)
Goodput400 requests a second offered, 400 answered within 1 s, 0 dropped, 0 errors
Part 4's invariants afterwardsAll hold

Prices that move while orders wait. A queued order reserved buying power against the close the player saw, with a 5% ceiling. Stock prices in Bullpen are end-of-day closes, so normally nothing changes overnight. But a new close can land between submission and the open, so the release rule had to be written down.

If the price is above the reserved ceiling, the order tops up its reservation from buying power. If that isn't enough, it's rejected and the full reservation comes back. In a run where a new close landed 20% higher on half the symbols, 495 orders topped up and 50 low-cash orders were rejected and fully refunded, and every invariant from Part 4 held. 27 integration tests pin the edge cases to the cent, including a top-up of exactly the remaining buying power (admitted) and one cent short (rejected).

What would flip it. Admission work that no longer fits in a sweep pass, or a second consumer of "order became eligible" events. Either would make a real queue earn its place.

What broke first was a query, not a limit

My prediction was that the shared database compute would give out first, at 200 to 300 mixed requests a second. The resource was right. The cause was wrong.

As the build stood, the 9:30 step failed at 400 requests a second because of the account poll, which every open screen sends every 3 seconds. Running EXPLAIN on it showed three sequential scans, over orders, fills and reservations, on every single poll. At 1,000 screens, account polls hit a p95 of 8.2 seconds and 13,958 iterations were dropped. Four indexes fixed it. After them, the same step held at 29 ms p95 on a full core, and the knee moved to between 450 and 500 requests a second on that machine. Even 450 was borderline: 12 dropped iterations against a threshold of 10, and I didn't repeat runs enough to give a spread.

At the quarter-core approximation, the step didn't hold: order p95 15.2 seconds and the backlog took 148 seconds to drain. That's the limit of my quarter-core approximation, which is harsher than Neon's 0.25 CU in one way: a paused backend keeps its locks. It is a warning, not a measurement of Neon, and it is the reason the hosted run matters.

The general lesson: the first thing to break at a peak is usually the cheapest thing nobody looked at. Here it was a read every screen sends constantly, not the order path that got all the design attention.

Decision 2: how live prices reach every screen

Conditions. Prices have one owner, the market-data service, which spends one shared provider budget recorded in Postgres: at most 9,000 CoinGecko calls a month and 20 Alpha Vantage calls a day, under the providers' own 10,000 and 25. Live can't mean fresher than that budget allows, and no viewer may ever cause a provider call. The question is only how a price, once stored, reaches a thousand open screens.

Options.

OptionWhat it means on Vercel Hobby, November 2026
PollingEvery screen asks; the database answers every screen
Server-Sent EventsOne response streams to each screen; closes at the function's 300 s limit
WebSocketsGA since October 20; each socket is pinned to one instance and also closes at 300 s
Redis pub/sub or a hosted service (Ably, Pusher)Fan-out across instances, plus a new dependency and its account
A Vercel Daemon holding the streamShares the Hobby daemon quota with Part 4's sweeper; at the quota all daemons stop until the 1st (daemon limits)

Choice. Server-Sent Events. Each function instance reads the stored prices once per interval and pushes them to every screen connected to that instance. Streams end themselves before 300 seconds; the browser reconnects and resumes with Last-Event-ID; polling is the fallback.

Why. Prices flow one way, so a two-way socket buys nothing. Postgres LISTEN/NOTIFY was out, because Neon's pooler runs in transaction mode, where it doesn't work. The design moves the fan-out cost from the database to the instance:

ViewersDatabase reads a second, polling every 10 sDatabase reads a second, SSE
250250.17
1,0001000.33

The polling figures are the offered rate, screens divided by the interval; the SSE figures are the hub's own read counter. The 1,000 row held 990 streams.

Provider calls stayed at zero at every viewer count. One instance held 990 streams with 1,131 open file descriptors, so Vercel's 1,024 limit puts the ceiling near 880 viewers per instance; my prediction was 900. Real streams ended at 246, 252 and 270 seconds, each with a goodbye event, and a reconnect resumed with no repeated prices.

The screen now says which state it's in. Live, Reconnecting and Stale are freshness contracts, not decoration: a player looking at a stale price should know it before placing an order.

What would flip it. A need for prices pushed across instances within a second, or two-way messages. Either one makes Redis or a hosted service worth its dependency.

Decision 3: keeping reads from starving orders

Conditions. Every route used one connection pool. A thousand screens reading prices, accounts and the leaderboard could take every connection from the order path. Part 3 already warned that separate pools still share one Neon compute.

Choice. The order path has its own pool, and a new architecture rule fails the build if a read route imports it. I then measured what isolation that actually bought, instead of assuming it.

What it measured. Orders at 100 a second, then the same orders beside a read stampede four times larger than the compute could serve:

PoolsOrders served (of 3,001)Order p95 under the stampede
One shared pool29.1 s
Separate pools2,998144 ms

That's the part of the coupling a pool removes: connections. It doesn't remove the rest. Orders still slowed from 19 ms to 144 ms, because reads and orders spend the same CPU. And at the quarter-core approximation, once the compute itself was the limit, both designs collapsed together. Pools are a bulkhead for connections, not for CPU, and a post that claimed otherwise would be selling isolation it didn't measure.

The leaderboard needed nothing new. Part 3 chose a materialized view and rejected a queue-fed read model; under a stampede of up to 2,000 requests a second on a full core, the view served about 1,500 a second at a p95 of 2.0 to 2.3 ms with no errors (600 a second at 19 ms on the quarter core). That decision stands. Why a stampede is a capacity budget rather than a locking problem is in my notes on cache stampedes.

Decision 4: what degrades first, decided before the peak

Degradation chosen in the middle of an incident is improvisation. So the order is written down in ADR-0031, with a switch for each step: moderation calls stop first and new handles go to review, then the leaderboard refresh goes off, then the live stream falls back to polling. Order entry has no switch; it goes last, and only as a safe refusal.

The switches are an environment variable, so flipping one is a redeploy: they're for a peak I can see coming. In the first second of a spike, the pools' bounded waits and the stale-price rule do the work.

Then I broke things under a steady 300 requests a second, while a probe placed an order every 100 ms:

FailureWhat the player sawOrder entryRecovery
Stock feed downPrices flagged stale; orders on a stale symbol refused with nothing reservedSurvived309 ms
Provider quota exhaustedThe same; the budget refused 15 calls before any leftSurvived321 ms
Moderation provider hungHandle saves took 2 s and went to review; nothing else changedSurvived, p95 22 ms against 21 ms261 ms
Leaderboard stampede (+1,500 a second)Slower pollsSurvived, p95 35 msNone needed
Database stopped for 3 s27 of 312 probes got a 503 and "nothing was reserved"Refused safely, then survived2.5 s

The moderation row is the bonus post's design proving itself. Moderation was kept off the money path, so a hung model costs a handle its own two seconds and nothing more.

The cold-database row hides the most useful finding. In its first run, stopping the database didn't cause three seconds of errors. It ended the process, and nothing answered for the rest of the test. A pool emits an error event when the database closes an idle connection, and with no listener Node exits. That bug was in production code that predates this part. It's fixed now in all three pools, with a test each. A stress test earns its keep by breaking what you thought was settled.

Part 1's promises, graded

Part 1 made two promises this part had to answer.

A dead market-data feed can't stop order entry: kept. With every price stale, order entry stayed up. Orders on stale symbols were refused safely, with nothing reserved, and everything else kept working.

One deployment can serve 1,000 players within the free tiers: not answered yet, and I won't pretend otherwise. Locally, on a full core, with the indexes, 1,000 queued orders, 50 new orders a second and 1,000 polling screens held a new-order p95 of 29 ms. At a quarter core, they didn't. The hosted answer depends on two step limits a local run can't reach. One is Vercel's concurrency burst. The other is Active CPU: Hobby includes 4 hours a month, and my prediction, which assumed 25 ms of CPU per request and screens polling every 5 seconds, says a full crowd would spend that in about 16 minutes, so a burst fits and a whole trading day doesn't. On Hobby, running out doesn't send a bill. It pauses the project with a 503, so on a free tier the cost question is an availability question.

The streaming design exists partly to move that line. A bounded run on a Hobby preview against a separate database branch is still to come, and the next post reports it.

Production answered part of that question before the hosted run did, and not where I was looking. On November 15 the sweeper, the daemon that admits queued orders at the open, stopped. Its log says why: this team used its Hobby Daemons quota of 420 GB-hours of provisioned memory. I had tracked its Active CPU, about 0.3 hours a month against a quota of 5. I hadn't tracked its memory, which is charged for every hour it's reserved, used or not. At 2 GiB around the clock it needs 1,440 GB-hours a month against Hobby's 420, and at the quota every daemon on the account stays stopped until the 1st (Vercel daemon limits).

Nothing was lost. Orders that stopped moving pick up where they were on the next sweep, which Part 4 tested. Until December 1, a scheduled GitHub Actions workflow ran the same sweeper code against production (ADR-0033). My first version ran every 5 minutes and would have spent about 1,400 runner-minutes a day, so the fallback nearly became the next quota problem. I cut it to the work that needed doing: one run before the 9:30 open, a short pass every 30 minutes in market hours and one every 6 hours, each stopping as soon as there was nothing to sweep. That's about 300 minutes for the rest of the month. GitHub doesn't promise its schedule to the minute, so a queued order could be admitted a few minutes after 9:30 instead of at it.

The daemon came back with the quota on December 1. In production it peaks at about 230 MB of the 2 GiB it reserves, so the lasting fix is to reserve a size close to what it uses. It's this post's lesson on my own system: the step limit that broke was the one nobody looked at.

Two smaller findings belong here. The unexplained multixact error from Part 4's CI didn't reproduce: zero errors in 566,272 operations, 264,888 on Postgres 16 and 301,384 on Postgres 18, but CI saw it once on Postgres 17, which I haven't run, so it isn't closed. And Bullpen's records disagreed with themselves about the Hobby daemon quota, 10 Active CPU-hours in three content files and one decision record, against Vercel's current 5. ADR-0032 corrected them.

What week one got right and wrong

Week one predicted a Market Open Queue and an Order Saga workflow. Both are marked predicted and not built in the architecture model. The prediction got one thing right: a burst needs somewhere decided to wait. It got the place wrong. The wait lives in a row the system already owned, admitted by a process that already ran.

That's the habit this part leaves me with. Before a peak, list every kind of request and give each one its outcome in advance: runs now, waits in a named place, or degrades in a named way. Then test with traffic that doesn't wait for you, and expect the first thing to break to be something nobody designed at all.

A step back before the next part

This post was ready in mid-November, and I held it. Building in public at a part a week, I was moving faster than I was noticing. The quota above is one example: I had read the limits page, and I still tracked the number I expected to matter instead of the one that did. The fallback that nearly spent my GitHub minutes is another. Each was small, and each was a shift I only saw once I stopped adding features and watched the system run.

So before Part 6, I'm taking time to step back and reflect on what this build has taught me so far: which decisions held, which I'd make differently, and which shifts I missed while going fast. That's what the next post covers.

Read next

Still here? You might enjoy this.

Nothing close enough — try a different angle?

Architecting Software in 2026 · 6 of 7

Part 7 is in progress.

New parts land on Mondays, 9am Pacific — leave an address and I'll send each one the day it ships. Nothing else.

Was this helpful?

Leave a rating or a quick note — it helps me improve.

Related Posts

Engineering

The Saga Pattern Is About Time, Not Services

The saga pattern started as a fix for transactions that last too long. An order that outlives a transaction needs one, but not another service. In Part 4, Bullpen starts taking orders: reserve buying power, receive partial fills, race a cancel, settle and release what is left. This is the decision history of where that lifecycle runs, how a fill that arrives after a cancel gets booked, and what I broke on purpose to prove the ledger stays right.

Engineering

Database per Service Is Free Now. That Is Not a Reason to Use It

A free tier that doubles changes the inputs to a decision, not the decision. In week one I predicted Bullpen would split prices and history into two services with two databases. Then Neon made database per service look free, and I had to decide whether that changed anything. This is the decision history: five data and deployment decisions, each with its conditions, the options I weighed, why one won, and what would make me reverse it.

Engineering

When to Use Microservices in 2026: Scaling Alone Is No Longer the Reason

On the day the Dow posted a then-record gain, Robinhood's customers could not trade from the open to the close. Splitting out the hot part so it scales alone was the old answer; a serverless platform now does that per function. I open this series with Bullpen, a paper-trading league on live market data, and argue when to use microservices in 2026: only for a reason I can name, with a check, a measurement or a bill behind it.