跳到正文
DEV Community· Kevin Wang·· 34 分鐘前AI 評分43

我如何以每月低於 $1 的成本,在 AWS + Cloudflare 上提供 80 款 HTML5 遊戲、身份驗證和每週排行榜

How I Serve 80 HTML5 Games, Auth, and Weekly Leaderboards for Under $1/Month on AWS + Cloudflare

AI 導讀

Agentic Arcade 以 AWS + Cloudflare 架構提供 80 款 HTML5 遊戲、身份驗證及每週排行榜,每月成本低於 $1。遊戲和 102 個預先生成的 SEO/GEO 頁面託管於 S3,訪客無須登入即可遊玩;選擇跨裝置同步或每款遊戲每週 Top 50 排名的用戶可透過 AWS Cognito 登記。

正文

Cover image for How I Serve 80 HTML5 Games, Auth, and Weekly Leaderboards for Under $1/Month on AWS + Cloudflare

Kevin Wang

Most browser game portals either drown players in heavy SDKs and third-party trackers or burn money on always-on servers. When I built Agentic Arcade — 80 instant-play HTML5 games under 1 MB each — I wanted three things: sub-second boot times, 0 Cumulative Layout Shift (3/3 on Google PageSpeed Agentic Browsing), and near-$0 idle cost.

Here is the exact architecture running in production today.

1. Zero-Tracker Static Edge (CloudFront Free + Cloudflare Free Worker)

All 80 games (79 single-file 11–20 KB HTML5 games + an 820 KB Three.js roguelite, NOVA DRIFT 3D) and 102 pre-rendered SEO/GEO pages sit in S3 behind AWS CloudFront, fronted by a lightweight Cloudflare Free Worker at adsaiagentic.com.

  • Static routes (GET/HEAD) go straight to CloudFront with a 3.7 KB CloudFront Function handling clean URL rewrites (/play/*, /genre/*, /collections/*, /atlas).
  • Allowlisted API paths (/api/auth/*, /api/me/*, /api/leaderboard/*, /api/vote, /api/geo-telemetry) proxy to an AWS Singapore HTTP API + Node 22 Lambda.
  • Staff moderation & analytics endpoints stay isolated on a separate origin and return 403/405 at the edge.

2. Progressive Identity (Zero Login Wall)

Casual web gamers bounce if you force registration before play. Instead, identity upgrades progressively:

  1. Guest Arcade Pass (Default): Every visitor immediately gets a localStorage pass tracking a deterministic UTC Daily Challenge, daily streak, favorites, personal bests, and an 80-game Passport with 6 mastery badges — plus direct ?beat=Handle:Score friend challenge links.
  2. Optional Cloud Member Sync: Players who want cross-device sync or per-game Weekly Top-50 rankings sign up via AWS Cognito (Free Tier: 10,000 MAU), and their local guest pass merges idempotently into DynamoDB.

3. Single-Partition-Key DynamoDB With Zero Table Scans

Everything lives in one pay-per-request DynamoDB table (pk only + expiresAt TTL):

  • member:v1:profile#<subId> — Cloud member profile & per-game personal bests (1 RCU read)
  • member:v1:lb#<YYYY-Www>#<gameId> — Per-game Weekly Top 50 stored as a compact sorted JSON array with optimistic-concurrency ver CAS and a 35-day TTL
  • member:v1:metrics#day#<YYYY-MM-DD> — Atomic UpdateItem ADD daily rollups (95-day TTL) so the founder dashboard loads 30-day trends across all 80 games using two BatchGetItem calls and zero scans.

4. Hitting 3/3 on PageSpeed Insights Agentic Browsing (0 CLS, 100 SEO)

While auditing mobile performance on PageSpeed Insights, two subtle SPA traps showed up:

  • 0.269 Mobile CLS: Replacing server-prerendered HTML with a short "Loading..." box during JS boot caused the footer to jump into the mobile viewport and get pushed back out 300 ms later. Preserving the SSR markup during boot, reserving min-height: 100svh on <main>, locking mobile genre chips to a single horizontally scrollable row, and switching Google Fonts to display=optional dropped mobile CLS straight to 0.
  • ARIA Tree Conformance: Swapping <article role="button" tabindex="0"> game cards to native semantic <a href="/play/..."> links fixed the accessibility tree audit and boosted crawlable internal links simultaneously.

5. Automated QA Across 32 Touch-First Games

For the 32 original games in the Arcade Atlas collection, every build runs through an automated test suite that verifies puzzles (Sudoku, Nonogram, Box Pusher, Car Unblock, Tile Pairs) are solvable without guessing and simulates 60 seconds of random touch input per game to catch uncaught errors before deploy.

If you want to poke at the live site or test a 2-minute game on mobile, try Agentic Arcade (or jump straight into NOVA DRIFT 3D / 2-Minute Break Games) — I'd love feedback on both the games and the serverless architecture!

來源:DEV Community · dev.to