server-survival

Tower defense game that teaches cloud architecture. Build infrastructure, survive traffic, learn scaling.

aws · cloud · devops · education · game
中级
GitHub在线演示
Stars:3,724
License:MIT License
更新:2025/12/27

README

Server Survival

Gameplay Demo

Server Survival is an interactive 3D simulation game where you play as a Cloud Architect. Your mission is to build and scale a resilient cloud infrastructure to handle increasing traffic loads while fighting off DDoS attacks, managing your budget, and keeping your services healthy.

PLAY NOW

How to Play

Objective

Survive as long as possible! Manage your Budget ($), Reputation (%), and Service Health.

  • Earn Money by successfully processing legitimate traffic requests.
  • Lose Reputation if requests fail or if malicious traffic slips through.
  • Maintain Health - Services degrade under load and need repairs.
  • Game Over if Reputation hits 0% or you go bankrupt ($-1000).

Traffic Types

TrafficColorDestinationRewardDescription
STATICGreenCDN / Storage$0.50Static file requests (images, CSS, JS)
READBlueSQL DB$0.80Database read operations

Infrastructure & Services

Build your architecture using the toolbar. Each service has a cost, capacity, and upkeep:

ServiceCostCapacityUpkeepFunction
Firewall$4030LowSecurity. First line of defense. Blocks malicious traffic.
Queue$40Queue:200LowBuffer. Buffers requests during spikes. Prevents drops.
Load Balancer$5020MediumDistribution. Distributes traffic to multiple instances.
Compute$604HighProcessing. Processes requests. Upgradeable T1→T3.
CDN$6050LowDelivery. Caches STATIC content at edge (95% hit rate).
Cache$6030MediumCaching. Caches responses to reduce DB load.
SQL DB$1508Very HighDatabase. Destination for READ/WRITE/SEARCH. Upgradeable T1→T3.
Storage$2525LowFile System. Destination for STATIC/UPLOAD traffic.

Scoring & Economy

ActionMoneyScoreReputation
Static Request+$0.50+3+0.1
DB Read+$0.80+5+0.1
DB Write+$1.20+8+0.1
File Upload+$1.50+10+0.1
Search Query+$0.80+5+0.1
Attack Blocked+$0.50+10-
Request Failed--half-1
Attack Leaked---5

Upkeep & Cost Scaling

  • Base Upkeep: Each service has per-minute upkeep costs
  • Upkeep Scaling: Costs increase 1x to 2x over 10 minutes
  • Repair Costs: 15% of service cost to manually repair
  • Auto-Repair: +10% upkeep overhead when enabled

Game Modes

Survival Mode

The core experience - survive as long as possible against escalating traffic with constant intervention required:

Dynamic Challenges:

  • RPS Acceleration - Traffic multiplies at time milestones (×1.3 at 1min → ×4.0 at 10min)
  • Random Events - Cost spikes, capacity drops, traffic bursts every 15-45 seconds
  • Traffic Shifts - Traffic patterns change every 40 seconds
  • DDoS Spikes - 50% malicious traffic waves every 45 seconds
  • Service Degradation - Services lose health under load, require repairs

New UI Features:

  • Health bars on all services
  • Active event indicator bar at top
  • Detailed finances panel (income/expenses breakdown)
  • Service health panel with repair costs
  • Auto-repair toggle
  • Game over analysis with tips

Sandbox Mode

A fully customizable testing environment for experimenting with any architecture:

ControlDescription
BudgetSet any starting budget (slider 0-10K, or type any amount)
RPSControl traffic rate (0 = stopped, or type 100+ for stress tests)
Traffic MixAdjust all 6 traffic type percentages independently
BurstSpawn instant bursts of specific traffic types
Upkeep ToggleEnable/disable service costs
Clear AllReset all services and restore budget

No game over in Sandbox - experiment freely!

Recent Features (v2.1)

  • Constant Intervention Mechanics - Game requires active management throughout
  • Service Health System - Visual health bars, manual/auto repair options
  • RPS Milestones - Traffic surge warnings with multiplier display
  • Active Event Bar - Shows current random event with countdown timer
  • Detailed Finances - Income by request type, expenses by service with counts
  • Game Over Analysis - Failure reason, description, and contextual tips
  • Retry Same Setup - Restart with same architecture after game over
  • Interactive Tutorial - Guided walkthrough for new players

Controls

  • Left Click: Select tools, place services, and connect nodes.
  • Right Click + Drag: Pan the camera.
  • Scroll: Zoom in and out.
  • WASD / Arrows: Move camera (pan) when zoomed in.
  • ESC: Open main menu and pause game. Press again or click Resume to close menu (stays paused).
  • Camera Reset: Press R to reset the camera position.
  • Birds-Eye View: Press T to switch between isometric and top-down view.
  • Hide HUD: Press H to toggle UI panels.
  • Connect Tool: Click two nodes to create a connection (flow direction matters!).
    • Valid Flows: Internet -> (Firewall/CDN) -> Load Balancer -> Queue -> Compute -> Cache -> (SQL DB/Storage)
  • Delete Tool: Remove services to recover 50% of the cost.
  • Time Controls: Pause, Play (1x), and Fast Forward (3x).

Strategy Tips

  1. Block Attacks First: Always place a Firewall immediately connected to the Internet. Malicious leaks destroy reputation fast (-5 per leak).
  2. Use CDN for Static Content: Connect Internet -> CDN -> Storage. The CDN handles 95% of static traffic cheaply!
  3. Watch Service Health: Damaged services have reduced capacity. Click to repair or enable Auto-Repair.
  4. Scale for Traffic Surges: RPS multiplies at milestones - prepare before ×2.0 at 3 minutes!
  5. Balance Income vs Upkeep: Start lean, scale as income grows. Over-provisioning leads to bankruptcy.
  6. Use Cache Wisely: Reduces database load significantly for READ requests.
  7. Buffer with Queue: Queue helps survive traffic burst events without dropping requests.
  8. React to Events: Watch the event bar - cost spikes mean hold off on purchases, traffic bursts mean ensure capacity.

Tech Stack

  • Core: Vanilla JavaScript (ES6+)
  • Rendering: Three.js for 3D visualization.
  • Styling: Tailwind CSS for the glassmorphism UI.
  • Build: No build step required! Just standard HTML/CSS/JS.

Getting Started

  1. Clone the repository.
  2. Open index.html in your modern web browser.
  3. Start building your cloud empire!

Community

Join our Discord server to discuss strategies and share your high scores: Join Discord


Built with code and chaos.