Skip to main content
Developer & Creator Documentation

High-Concurrency Performance, Throughput (TPS/RPS) & Scalability Benchmark Report

An isolated, apples-to-apples load benchmark (C = 30–100 concurrent workers over HTTP keep-alive against a dedicated single-process server instance backed by an isolated temporary copy

Open AI Studio Direct-Answer FAQ Hub Machine-Readable Corpus (/llms-full.txt)

High-Concurrency Performance, Throughput (TPS/RPS) & Scalability Benchmark Report

Platform: YourPlayground.games (https://www.yourplayground.games, local runtime :9033)

Audit Date: 2026-11-23 | Runtime: Node.js v24.22.2 (win32 isolated single-process benchmark server)

Scope: Pre-launch high-concurrency throughput (RPS/TPS), tail latency (p50/p95/p99), wire bandwidth (gzip), Zero-SQL storage contention, GCS object write-quota protection, and GCP Global External HTTPS Load Balancer keep-alive hardening for public GCP Cloud Run + 121.games launch.


1. Executive Summary

An isolated, apples-to-apples load benchmark (C = 30–100 concurrent workers over HTTP keep-alive against a dedicated single-process server instance backed by an isolated temporary copy of storage/) exposed six primary scalability bottlenecks in the pre-launch codebase:

  1. Read-Path Mutex Convoy (src/storage/atomicJson.mjs): readJsonFile() previously acquired withFileLock(filePath), serializing every concurrent GET request behind a single FIFO lock AND stalling all catalog reads behind every disk fsync() + NTFS rename write. On GET /games/:slug (which performs two catalog lookups per view), concurrency collapsed to 32.3 RPS with p95 = 3,055.16 ms.
  2. Per-Request Recursive Docs Tree Walk (src/seo/growthCatalog.mjs & src/views/docsView.mjs): Every GET /docs, GET /docs/:section, and GET /sitemap.xml request walked docs/ sequentially and read/parsed all 16 Markdown files (247 KB), generating 8,800 filesystem syscalls and 147.4 MB heap spikes across just 200 requests.
  3. Unbatched Per-Play & Per-Score Full-File fsync() Storms (src/storage/gameRepository.mjs): Every GET /runtime/:slug/index.html triggered an unbatched incrementPlays() full-catalog fsync() + rename; 150 rapid game launches queued a 1-second background disk-write tail that starved subsequent GET /api/auth/me, static bundles, and POST /api/games/:slug/scores (102.4 TPS, p95 = 946.41 ms).
  4. Uncoalesced GCS Object Upload Queue (src/storage/cloudStorageSync.mjs): 100 rapid play updates queued 100 sequential HTTP POST uploads to gs://yourplaygroundgames-state/catalog.json, directly violating Google Cloud Storage's 1 write/sec per single object sustained rate limit (429 Too Many Requests).
  5. Uncompressed Wire Payloads (src/app.mjs & src/routes/runtimeRouter.mjs): three.min.js (670,062 B), phaser.min.js (1,196,122 B), sandboxed game HTML (173,761 B), and SSR HTML (83,980 B) shipped raw (identity), inflating Cloud CDN/egress bandwidth by 3.5x–10x.
  6. GCP Load Balancer Keep-Alive Race (server.mjs): Default Node.js keepAliveTimeout (5,000 ms) was far below the Google Cloud Global External HTTPS Load Balancer 600,000 ms (600 s) backend idle timeout, creating an intermittent 502 Bad Gateway TCP FIN race under pooled traffic.

Headline Before -> After Results (Single Node.js Process, Isolated Storage)

  • SSR Game Permalink (GET /games/neon-odyssey, C=50): 32.3 RPS -> 1,293.9 RPS (40.1x), p95 3,055.16 ms -> 45.00 ms (-98.5%).
  • SSR Home (GET /, C=50): 124.4 RPS -> 925.1 RPS (7.4x), p95 687.87 ms -> 65.45 ms (-90.5%), wire size 83.98 KB -> 17.86 KB (-78.7%).
  • REST Catalog (GET /api/games, C=50): 954.4 RPS -> 3,795.9 RPS (4.0x), p95 57.33 ms -> 15.43 ms (-73.1%).
  • 121.games Syndication (GET /api/syndication/121games, C=50): 661.5 RPS -> 1,964.0 RPS (3.0x), wire size 23.62 KB -> 4.06 KB (-82.8%).
  • Dynamic Sitemap (GET /sitemap.xml, C=50): 279.3 RPS -> 1,571.6 RPS (5.6x), 3,400 disk reads + 2,200 directory walks -> 0 reads / 0 walks, heap 147.41 MB -> 37.82 MB (-74.3%).
  • Authenticated Session Check (GET /api/auth/me with ypg_sid, C=50): 1,425.7 RPS -> 6,061.1 RPS (4.3x), p95 39.96 ms -> 10.76 ms (-73.1%).
  • Vendor Bundles (three.min.js / phaser.min.js, C=30): 902.2 -> 3,948.9 RPS (4.4x, -75.0% bytes) and 522.9 -> 2,433.2 RPS (4.7x, -73.4% bytes).
  • Concurrent Score Submissions (POST /api/games/neon-odyssey/scores, 100 concurrent): 102.4 TPS -> 1,865.6 TPS (18.2x), p95 946.41 ms -> 51.01 ms (-94.6%), disk commits 161 -> 2 (-98.8%).
  • Mixed Read+Write Contention (200 GET /api/games + 50 POST /scores): Read throughput 419.1 -> 2,963.0 RPS (7.1x), Read p95 324.93 ms -> 21.33 ms (-93.4%); Write throughput 154.2 -> 1,133.1 TPS (7.3x).
  • Direct Play Counter Burst (200 concurrent incrementPlays): 206.6 TPS -> 27,632.3 TPS (133.7x), p95 920.99 ms -> 6.89 ms (-99.3%), 200/200 plays durably persisted (0 lost).
  • GCS State Sync Burst (100 rapid plays + flushPendingSyncs()): 100 GCS PUTs (1,317.26 ms) -> 1 coalesced GCS PUT (34.24 ms, -99% PUTs, 38.5x faster) with exact final playsDelta = 100.
  • GCP LB Socket Timeouts (server.mjs): keepAliveTimeout 5,000 ms -> 620,000 ms, headersTimeout 60,000 ms -> 625,000 ms.

2. Concurrency & Caching Architecture

flowchart LR
    LB["GCP Global External HTTPS LB (600s idle)"] -->|"keepAliveTimeout 620s / headersTimeout 625s"| Srv["server.mjs + Express 5"]
    Srv --> Comp["Native node:zlib Gzip Middleware (>= 1024 B, Vary: Accept-Encoding)"]
    Comp --> StaticLRU["Static Gzip LRU Cache (<= 16 MB, stat-validated: three.min.js, phaser.min.js)"]
    Comp --> RuntimeLRU["Runtime Asset LRU Cache (<= 16 MB, post-realpath symlink check)"]
    Comp --> Routes["SSR / REST / Discovery / Auth Routers"]
    Routes -->|"Lock-Free Single-Flight stat(bigint)"| JsonCache["Write-Through JSON LRU Cache (atomicJson.mjs, WeakMap O(1) indexes)"]
    Routes -->|"Single-Flight Tree Stat"| DocsCache["Docs Tree & Rendered HTML Cache (growthCatalog.mjs + docsView.mjs)"]
    Routes -->|"Group-Commit Batching"| Lock["withFileLock + Atomic Write + fsync + NTFS Rename"]
    Lock -->|"Write-Through Update"| JsonCache
    Lock -->|"Coalesced Debounce Queue (1000 ms default)"| GCS["gs://yourplaygroundgames-state (<= 1 PUT/sec/object)"]

3. Detailed Before vs. After Benchmark Tables

3.1 HTTP Read Hot Paths (Accept-Encoding: gzip, Isolated Server Process)

EndpointConcurrency / RequestsBefore RPSAfter RPSSpeedupBefore p50 / p95 / p99 (ms)After p50 / p95 / p99 (ms)Wire Size (Before -> After)Disk readFile (Before -> After)
GET /50 / 300124.4925.17.4x240.7 / 687.9 / 973.853.4 / 65.5 / 66.383,980 B -> 17,860 B (-78.7%)300 -> 0
GET /games/neon-odyssey50 / 30032.31,293.940.1x1175.6 / 3055.2 / 3844.838.7 / 45.0 / 46.647,029 B -> 11,141 B (-76.3%)600 -> 0
GET /showcase50 / 300200.21,425.47.1x158.1 / 578.7 / 636.033.2 / 42.2 / 48.652,920 B -> 10,909 B (-79.4%)300 -> 0
GET /api/games50 / 400954.43,795.94.0x52.7 / 57.3 / 60.212.7 / 15.4 / 15.720,322 B -> 5,222 B (-74.3%)400 -> 0
GET /api/syndication/121games50 / 400661.51,964.03.0x75.2 / 88.7 / 90.423.6 / 30.3 / 34.123,624 B -> 4,058 B (-82.8%)400 -> 0
GET /sitemap.xml50 / 200279.31,571.65.6x183.9 / 221.9 / 259.831.0 / 32.7 / 33.018,457 B -> 1,837 B (-90.0%)3,400 -> 0 (readdir: 2,200 -> 0)
GET /docs50 / 200323.21,915.55.9x147.8 / 169.7 / 173.421.9 / 29.1 / 32.251,201 B -> 14,580 B (-71.5%)3,200 -> 0 (readdir: 2,200 -> 0)
GET /runtime/neon-odyssey/index.html50 / 1502,002.84,737.22.4x23.0 / 27.2 / 28.28.9 / 12.5 / 13.0173,761 B -> 41,595 B (-76.1%)153 -> 0
GET /api/auth/me (ypg_sid)50 / 4001,425.76,061.14.3x35.1 / 40.0 / 41.77.6 / 10.8 / 12.7413 B -> 413 B (<1 KB identity)846 -> 0
GET /vendor/three.min.js30 / 120902.23,948.94.4x28.1 / 43.1 / 47.26.3 / 9.7 / 9.8670,062 B -> 167,770 B (-75.0%)16 -> 0
GET /vendor/phaser.min.js30 / 100522.92,433.24.7x51.9 / 67.8 / 70.39.7 / 17.0 / 17.21,196,122 B -> 318,115 B (-73.4%)26 -> 0

3.2 Concurrent Write, Mixed Contention & GCS State Sync Benchmarks

WorkloadBefore TPS / RPSAfter TPS / RPSSpeedupBefore p50 / p95 / p99 (ms)After p50 / p95 / p99 (ms)Integrity & I/O Proof
POST /api/games/neon-odyssey/scores (100 concurrent)102.4 TPS1,865.6 TPS18.2x673.5 / 946.4 / 965.948.9 / 51.0 / 51.1100/100 HTTP 201; open/rename 161/162 -> 2/2 (-98.8%)
Mixed Contention — 200 GET /api/games419.1 RPS2,963.0 RPS7.1x52.9 / 324.9 / 332.315.4 / 21.3 / 22.0200/200 HTTP 200; readFile 250 -> 0
Mixed Contention — 50 POST /scores (parallel)154.2 TPS1,133.1 TPS7.3x190.8 / 312.5 / 323.343.0 / 43.4 / 43.450/50 HTTP 201; open/rename 50/50 -> 1/1 (-98.0%)
Direct incrementPlays (200 concurrent)206.6 TPS27,632.3 TPS133.7x496.9 / 921.0 / 958.06.2 / 6.9 / 7.0Exact playsDelta = 200 (0 lost updates, 0 .tmp leftovers)
GCS State Sync Burst (100 rapid plays + flush)100 PUTs (1,317.3 ms)1 PUT (34.2 ms)38.5x——-99.0% GCS writes; exact remote playsDelta = 100; zero 429 risk

3.3 Server Socket & Heap Efficiency

MetricBeforeAfterOperational Impact
server.keepAliveTimeout5,000 ms620,000 ms (620 s)Exceeds GCP Global External HTTPS LB 600 s idle keep-alive pool
server.headersTimeout60,000 ms625,000 ms (625 s)Strictly >= keepAliveTimeout + 5,000 ms per Node.js HTTP contract
SIGTERM Graceful DrainWaited on idle socketsserver.closeIdleConnections()Immediate idle socket teardown + flushPendingSyncs({ timeoutMs: 3000 })
Peak Heap on GET /sitemap.xml147.41 MB37.82 MB (-74.3%)Eliminates 49 MB transient markdown string churn per 200 requests
Peak RSS across full suite412.02 MB182.50 MB (-55.7%)Comfortably fits within 512 MiB–1 GiB Cloud Run memory budgets

4. Engineering Upgrades Implemented (File Traceability)

  1. Lock-Free Single-Flight Stat-Validated Write-Through JSON Cache (src/storage/atomicJson.mjs):
  • readJsonFile() no longer enters withFileLock(), eliminating read-read serialization and read-behind-write lock convoys.
  • Uses single-flight coalesced fs.stat(path, { bigint: true }) (mtimeNs, ctimeNs, size, ino) against a bounded 128-entry LRU cache with monotonic writeGenerations guards, ensuring 0 ms staleness on both in-process mutations and external disk writes (including writeBinaryAtomic() invalidation during GCS boot hydration).
  • Supports { clone: false } for internal read-only repository indexing and { skipWrite: true } in updateJsonAtomic() to avoid no-op disk fsync() writes.
  1. Pre-Indexed Catalog & Group-Commit Batching (src/storage/gameRepository.mjs):
  • Attaches a WeakMap catalog index (sortedGames, bySlug Map, pre-lowercased search strings) to each committed catalog snapshot and replaces V8 structuredClone() on catalog reads with a fast deep record cloner (cloneGameRecord).
  • Implements strict linearizable Group-Commit Lock-Coalesced Batching for incrementPlays() and recordScore(): concurrent mutations arriving while a file lock is held coalesce into a single atomic fsync() + rename while preserving exact per-caller linearizable return values, GAME_NOT_FOUND isolation, and immediate read-after-write durability.
  1. O(1) Indexed Auth & Session Cache (src/storage/authRepository.mjs):
  • Adds WeakMap indexes (usersById, usersByEmail, sessionsById with pre-parsed expiresMs) over write-through cached users.json and sessions.json, eliminating 2x locked disk reads per authenticated HTTP request and skipping redundant disk writes on idempotent deleteSession().
  1. Single-Flight Parallel Docs Tree & Markdown HTML Cache (src/seo/growthCatalog.mjs, src/views/docsView.mjs):
  • Replaces sequential directory walking and per-request reading of all 16 .md files (247 KB) with single-flight mtimeNs/ctimeNs/size tree validation and incremental per-file re-parsing on disk edits.
  • Adds a bounded 64-entry LRU cache for renderMarkdownToSafeHtml() keyed by section content and cross-link topology.
  1. Coalesced / Debounced GCS Object Upload Queue (src/storage/cloudStorageSync.mjs):
  • Coalesces rapid background scheduleMirrorFile() / scheduleMirrorGame() writes per (bucket, objectName) key using a configurable GCS_SYNC_COALESCE_MS window (DEFAULT_GCS_COALESCE_MS = 1000 ms, enforcing <= 1 PUT/sec/object per GCS limits).
  • flushPendingSyncs() cancels active debounce timers, immediately dispatches all dirty slots, awaits active game directory walks, and drains tail mutations arriving mid-flight before SIGTERM exit or test completion.
  1. Native node:zlib Gzip Compression, Static Asset LRU & Runtime Asset Cache (src/middleware/compressionMiddleware.mjs, src/app.mjs, src/routes/runtimeRouter.mjs):
  • Zero external dependencies: compresses compressible responses (text/*, application/json, application/javascript, application/xml, application/rss+xml, application/atom+xml, application/feed+json, application/manifest+json, image/svg+xml) >= 1,024 B when Accept-Encoding allows gzip (q > 0), emitting Vary: Accept-Encoding and weak ETag (W/"...") while preserving every security header (SSR_CSP_HEADER, RUNTIME_CSP_HEADER, X-Robots-Tag, Cache-Control, Service-Worker-Allowed).
  • Pre-compresses static compressible public/ assets (three.min.js, phaser.min.js, CSS/JS/SVG) into a stat-validated <= 16 MB LRU cache with If-None-Match 304 Not Modified support.
  • Caches runtime game payloads in a stat-validated <= 16 MB LRU cache strictly after fs.stat + fs.realpath symlink containment validation.
  1. GCP Global Load Balancer Keep-Alive Tuning (server.mjs):
  • Exports GCP_LB_KEEP_ALIVE_TIMEOUT_MS = 620_000 and GCP_LB_HEADERS_TIMEOUT_MS = 625_000, applies them to http.Server, and calls server.closeIdleConnections?.() during clean SIGINT/SIGTERM shutdown.

5. Production Capacity Sizing (GCP Cloud Run + 121.games)

Traffic TierExpected Peak RPSRecommended Cloud Run Config (yourplayground-games)Effective Capacity Notes
Launch Baseline50–250 RPSmin-instances=1, max-instances=10, concurrency=80, 1 vCPU / 512 MiBSingle instance handles 925+ RPS SSR, 1,964+ RPS 121.games JSON, 3,795+ RPS /api/games, 1,865+ TPS scores; Cloud CDN absorbs static /vendor/*, /creatives/*, and /api/syndication/121games (max-age=60).
Viral Spike (121.games Feature)1,000–5,000 RPSmin-instances=2, max-instances=25, concurrency=100, 2 vCPU / 1 GiBWith Cloud CDN hit ratio >= 80% on static assets + syndication feeds and gzip bandwidth cuts of 73–90%, origin load stays under 1,000 RPS (< 2 active instances).
Zero-SQL GCS Ceiling Notice> 10 concurrent writers across multiple instancesSingle-writer affinity or Firestore/Memorystore migration if multi-instance write fan-out exceeds 1 PUT/sec/objectBecause GCS_STATE_BUCKET stores consolidated JSON blobs (catalog.json, users.json, sessions.json), a single instance coalesces all writes cleanly to <= 1 PUT/sec/object. For multi-instance horizontal write scaling (max-instances > 1 with heavy concurrent scores/signups), shard per-game score/play deltas or migrate hot counters to Firestore/Redis before removing single-writer coordination.

6. Deterministic Verification Suite (tests/unit/perf-concurrency.test.mjs)

All upgrades are permanently gated in npm run test:unit and node .agents/scripts/agent-ctl.cjs verify --full-gate via tests/unit/perf-concurrency.test.mjs:

  • GCP LB Timeout Contract: Verifies keepAliveTimeout === 620_000, headersTimeout === 625_000, and sub-2s clean drain with active keep-alive agents.
  • Native Gzip & Header Preservation: Verifies raw wire gzip compression (>60% reduction on SSR HTML, <250 KB on three.min.js with byte-exact SHA-256 gunzip parity + 304 If-None-Match), exact SSR_CSP_HEADER / RUNTIME_CSP_HEADER / Cache-Control / Service-Worker-Allowed preservation, <1024 B identity passthrough, gzip;q=0 compliance, HEAD safety, and zero compression on binary PNGs.
  • Zero-Staleness Cache Coherence: Proves immediate visibility of write-through mutations, raw external fs.writeFile edits, writeBinaryAtomic hydration overwrites, and live docs/ additions/edits across gameRepository, authRepository, and loadDocumentationSections().
  • High-Concurrency Stress: Proves 200 concurrent plays + 100 concurrent scores + 10 invalid sibling rejections + 100 concurrent reads complete with 0 lost updates, exact top-25 leaderboard ordering, and 0 .tmp leftovers.
  • GCS Coalescing & Flush Drain: Proves 120 rapid catalog mutations coalesce into <= 3 GCS HTTP PUT calls with exact remote final state and zero dropped mid-flight tail writes.