← Notes

· Working it out

What madtown.today actually costs, and the plan to cut it

In Cheap enough to give away I wrote that madtown.today's bill is almost entirely a “who's here” heartbeat. That came from the README, which I wrote when the heartbeat was the only live thing on the page. Then I opened the actual bill. The heartbeat is a small part of it. This note is what I found, and the plan to make madtown.today cost about as much as Dungeon Garden does, written before I start, so I can check it against what really happens.

The bill

What madtown.today costs to run is the $15 Upstash Redis database, for about 376 visitors a day. The site itself is on Vercel Pro, which is my own choice: I upgraded when my build and test runners went past the free plan's CPU time, and nobody using the site pays for it. Pro is a $20 fee that includes $20 of usage, so anything past $20 of usage is extra. Counting it all, I pay about $45 a month. One Vercel billing cycle, 24 October to 21 November, looked like this:

Vercel lineUsageCharge
Observability Plus events13.97 million events$13.45
Functions (CPU, invocations, memory, transfer)4.56 million invocations, 22 hours of CPU$7.05
Builds26 hours of build CPU$5.25
Function and deployment storage22 GB-months$2.24
Web Analytics38,300 events$1.15
CDN requests and transfer2.78 million requests, 14 GB$0.15
Total usage$29.29

The site's own stats count 10,914 visitor-days in the same 29 days, between 285 and 575 a day. So Vercel alone came to about 0.27¢ per visitor per day, and almost all of that grows with traffic. It isn't a flat fee that more people could share for free.

What I got wrong

I'd guessed the build and test runners were the expensive part. They're part of it, but three other things matter more.

GitHub Actions turned out to be the cheap part. The $15 is a budget, not usage: the repository runs well inside the 2,000 minutes a month that a private repository gets for free.

The plan

The rule I took from Dungeon Garden is that the bill should grow with what people do, not with how long they keep a tab open. madtown.today breaks it in the most literal way: a tab open on a quiet afternoon costs money every 4 seconds.

Dungeon Garden fixed the same problem with a Cloudflare Durable Object: one small server-side object that browsers keep a WebSocket open to. Being connected is being here, so there's no heartbeat. When someone waves or paints, the object tells everyone. When nothing happens, it sleeps and isn't billed. Only the connection counts as a request, messages from browsers count as one request per 20, and messages to browsers are free. At madtown.today's size, that's a couple of thousand billed requests a day, against a free allowance of 100,000.

StepWhat changesWhat I pay a monthEffort
TodayNext.js on Vercel Pro, Upstash Redisabout $45
1. SettingsObservability Plus off, previews only for pull requests, shorter retentionabout $35an evening
2. Durable ObjectWho’s here, presence and live tallies over WebSockets; Upstash droppedabout $20about a week
3. Off VercelThe Next.js site on Cloudflare Workers, beside the Durable Objectabout $5two to three more weeks

Step 2 alone stops at about $20 because that's Vercel Pro's minimum, however little the site uses. Step 3 moves the site itself to Cloudflare Workers. Next.js runs there through an adapter, so the pages stay Next.js. I tried a test build with the OpenNext adapter before writing this. It built, and the homepage, the Gazette and the embeds rendered. Three things didn't work yet: the puzzles and share-image fonts are read from disk, which a Worker can't do, so they have to be bundled into the build; the adapter needs a slightly newer Next.js; and its support for the request middleware is still experimental.

The $5 is Cloudflare's paid Workers plan. The free plan allows 10 ms of CPU per request, and on Vercel madtown.today averaged about 17 ms per call, so I'm planning on paying it.

How many people the free plan would carry

A rough guess, until there are real numbers to check it against. Once the 4-second polling is gone, a visit is mostly loading the page, starting and finishing a few puzzles, voting on the day's question and staying connected to the room. I count that as about 20 to 50 requests a person a day that reach a Worker. Static files like scripts, fonts and images don't count, because Cloudflare serves those for free.

Today's traffic is about 376 a day, so either plan has plenty of headroom. I'll replace these guesses with the real request counts after the move.

What stays the same

Nobody should notice any of this. The puzzles, the streaks and the Who's here room work the same way. Streaks live in each person's browser, so a new server can't lose them. The count of people here now should update faster, because it's pushed instead of polled.

What I'll check afterwards

Every number above about the future is an estimate. When each step ships, I'll come back with the next full billing cycle and the request counts, and update this note with what it actually cost.

Prices used

Checked on 22 November 2026.