Skip to content

Background: the later Lightsail plan (Doc 55)

Superseded. This is the original plan written on 16 Nov 2026, converted from Drive doc 55 on 29 Nov 2026. The current reference is the migration guide. The two-hostname design, PostgreSQL for everything and Cloudflare Tunnel in the guide replace the SQLite and proxied-A-record design below.

Status: later plan, recorded 16 Nov 2026 at Frank’s request. Not part of the current build (earlier build phases and the defence layers come first).

Update 29 Nov 2026 (Frank): this plan is now carried out as the Lightsail migration guide, “Migration to AWS Lightsail behind Cloudflare Tunnel”. The migration guide replaces the plan below: the receiver and dashboard move to the Lightsail 2 GB server in Malaysia, Cloudflare stays in front through a Cloudflare Tunnel (two hostnames: app.bideward.com for the dashboard and api.bideward.com for bots and loaders), and PostgreSQL holds everything. The trigger was the Durable Object rows_written limit on the free plan. Read this page as background only; the migration guide is the reference.

Today the Bideward dashboard, the receiver, the loader and release endpoints, and the crash history run on a Cloudflare Worker with a Durable Object (titan-stats.tyrol4all.workers.dev). A second receiver (the Node one) also existed; it has since been retired.

Cloudflare Workers Paid plan, as published by Cloudflare on 16 Nov 2026:

  • Workers: 10 million requests a month included, then $0.30 per additional million. Going over is billed; it is not stopped unless a spending limit has been set in the Cloudflare account.
  • Durable Objects: 1 million requests a month included, then $0.15 per additional million. WebSocket messages into a Durable Object are billed at 20 to 1.
  • Durable Objects also bill duration (memory time) beyond the included amount.

Measured on 16 Nov 2026: 7.28 million requests used since 24 Oct. With 48 bots the pace was 17.4 million a month; with 3 bots about 50–76 requests a minute (about 2–3 million a month) before the request fixes in the current build.

AWS Lightsail: a fixed monthly price for the instance, with 2 TB of data transfer a month on Frank’s instance and no charge per request. Bideward’s traffic is small messages: even 20 million requests a month at about 3 KB each is about 60 GB, about 3% of 2 TB.

Cloudflare Worker + Durable Object (now) AWS Lightsail instance
Cost model Base plan + per request + duration above the included amounts Fixed monthly price; transfer allowance 2 TB
Many bots (48+) Cost grows with every bot No change until the server’s CPU or memory is the limit
Storage Durable Object storage (strongly consistent per object) Disk on the server (SQLite file), snapshots
Loaders and releases Worker only (the second receiver’s disk was not persistent) Possible: the disk is persistent
Maintenance None (Cloudflare runs it) Frank’s: operating system updates, the Node process, backups, monitoring
Availability Cloudflare’s network, many locations One server in one region; a restart or outage stops reporting until it is back
Security Cloudflare’s edge Firewall, SSH keys, updates; Cloudflare kept in front as a proxy
WebSockets Supported (billed as above) Supported, also through the Cloudflare proxy

Note: the current setup is a Worker, not Cloudflare Pages. Pages Functions are billed as Workers, so moving to Pages would not change the request cost.

Yes, for Bideward’s load (a steady stream of small messages from a few dozen bots, long-lived sockets), a server with a flat price is the better fit once the bot count grows. Do it after the current build, with these conditions:

  1. Keep Cloudflare in front: DNS stays on Cloudflare and the Bideward host is proxied (orange cloud) to the Lightsail static IP. Proxied traffic is not billed as Worker requests, and Cloudflare still gives TLS, caching of static files and attack protection.
  2. Keep the Worker as a standby receiver for a few weeks. The scripts already post to more than one receiver, so the Worker can keep receiving while the server proves itself. It can also serve loader start-up if the server is down.
  3. Retire the second receiver once the server is the main receiver.
  • Recommended: go straight to app.bideward.com. Every change of the dashboard address means a new bootstrap and loader paste on every betting platform (Bustabit, Coinscrash, bcgame) and a new sign-in, so moving once is better than moving twice.
  • DNS: an A record (proxied) to the Lightsail static IP. SSL/TLS mode Full (strict), with a Cloudflare Origin Certificate installed on the server.
  • Node.js LTS running the receiver (the existing Node receiver code base plus the shared core modules in cloudflare/core: auth, releases).
  • A storage layer with the same interface the Durable Object uses today, backed by SQLite on disk: bots, round logs, saved sessions, loaders, releases, users and sessions, crash history, settings, the audit log.
  • Caddy or nginx in front of Node, a systemd service (or pm2) that restarts it, logs rotated.
  • Firewall: ports 80 and 443 open only to Cloudflare’s IP ranges; SSH by key only, from Frank’s addresses.
  • Secrets (DASHBOARD_KEY, CONTROL_PASSWORD, GITHUB_TOKEN, Telegram token, owner sign-in) in an environment file readable only by the service user.
  • Backups: a daily Lightsail snapshot plus a nightly copy of the SQLite file; a restore tested once.
  • Monitoring: an outside uptime check and a Telegram alert when the receiver stops answering.
  • If the same instance also hosts other sites, Bideward runs as its own system user with a memory limit, so neither can starve the other. Check the instance size before the move (2 GB of memory or more recommended).

6. Migration steps (each its own pull request)

Section titled “6. Migration steps (each its own pull request)”
  • M1. Inventory every Worker route, storage key and scheduled alarm.
  • M2. The storage adapter (SQLite) and the Node server running the same routes; the existing receiver tests run against both.
  • M3. Deploy on Lightsail at the chosen subdomain and add it as an extra receiver; bots post to it beside the Worker. Compare the two dashboards for a few days.
  • M4. Copy the data from the Worker: users, loaders, releases, bots and instance numbers, saved sessions, round logs, crash history, settings.
  • M5. Switch the dashboard and the loaders to the server: new bootstrap and loader pasted once per platform; the Worker stays as standby.
  • M6. Watch for a week: requests, memory, disk, socket count, restore from backup once.
  • M7. Retire the second receiver; keep or remove the Worker (Frank’s choice).
  • One server is a single point of failure: bots keep betting while it is down (the loader runs the script from memory), only reporting, control and updates pause; the standby Worker covers start-up.
  • Maintenance is Frank’s: operating system updates monthly, Node updates, certificate renewal (automatic with an Origin Certificate valid for years).
  • Exposure: the server is reachable only through Cloudflare; no open database port.

The request reductions in the current build (longer loader polls in savings, one request per loader for all its bots, online status from the bot socket, the bcgame crash handed straight to the loader) go ahead now on Cloudflare. They lower the cost there and make the server’s load smaller later.

  • D55-1: app.bideward.com directly, or app.bideward.com first.
  • D55-2: keep the Worker as a permanent fallback or remove it after M6.
  • D55-3: the Lightsail region and whether Bideward shares the instance with other sites.

Bideward docs index