Moving Roamies off Neon in one night
The friend server for my desktop pet app used up its free hosting allowance. I found why, moved it to Cloudflare, and shipped the fix the same night.
Roamies is a desktop pet app I built in Electron. Pets visit their friends' pets through a relay server that every copy of the app stays connected to. On October 21 the relay, sign-in, and the admin console all went down at once.
The cause
The backend ran on Neon Functions, and Neon was refusing every request because the account had used its free monthly Functions allowance. It would not reset until November 1.
Nothing in the code was broken. The design was the problem. Neon bills a function for as long as any connection is open, and every copy of Roamies holds one open all day, so the server never shut off. The relay also checked Postgres every second for new messages, which kept the database awake too. Only 11 players were online that week, and that was enough to use up both allowances. A paid plan would have covered the bill without fixing the cause.
The fix
I moved the backend to a Cloudflare Worker, with one Durable Object holding every player's connection.
- Connections stay open while the object hibernates, so idle players cost nothing.
- The app pings every 30 seconds, and Cloudflare answers without waking the server.
- Who is online and the messages between friends live in the Durable Object, so the database polling is gone. Postgres only wakes when something happens, like a friend request or a gift.
- The message format stayed the same, so the app only needed a new address and the ping.
Fast, but not blind
The backend suite's 398 checks ran against the new setup and caught one bug. A copy that went silent, like a closed laptop, was never dropped. I fixed it, ran the scripted app test from source and as a packaged build, and checked the live server end to end.
Roamies 1.5.0 went out less than four hours after the first report. Copies installed from the website update themselves onto the new server with their friends, sign-ins, and saves intact, and Microsoft Store copies follow once Microsoft certifies the update. The cost now follows what players do, not how long they leave the app open.