Every year when national high school (Baccalaureate) exam results are released, we witness the same technical tragedy: servers crash, CDNs throw 522/525 origin errors, and hundreds of thousands of anxious students and parents are left staring at timed-out screens.Analyzing why traditional architectures fall under sudden traffic spikes is helpful, but I wanted to go a step further.
I decided to build and prove the solution.I created exam-results-edge, a full, open-source reference implementation designed to solve this exact problem using an Edge-Native architecture.Here is a live demo handling over 360,000 real-world scale records:👉 Live Demo: exams.walrashed.sy(Note: This is a private, non-official demo populated entirely with randomly generated dummy data for testing purposes).The Root Cause: Why Traditional Systems CrashThe typical government or enterprise stack for exam results looks like this:$$\text{User / Mobile App} \longrightarrow \text{CDN} \longrightarrow \text{API Gateway} \longrightarrow \text{Monolithic Server} \longrightarrow \text{SQL Database}$$When 300,000+ students open the app at the exact same minute and continuously refresh, this architecture breaks down for three reasons:Unnecessary Computations: The data is 100% read-only. The grades are finalized hours or days before the announcement. Running relational joins or application logic per request is wasted CPU time.Database Bottlenecks: Standard SQL databases struggle with tens of thousands of simultaneous concurrent connections trying to execute query hits.Expensive Scaling: Scaling a traditional monolithic backend to handle short-lived, extreme traffic spikes requires massive server provisioning, which is both complex and cost-prohibitive.When Cloudflare reports errors like 522 (Connection Timed Out) or 525 (SSL Handshake Failed), it means Cloudflare’s CDN is fine—your origin server is the one drowning underneath.The Edge-Native Solution: Instant Reads at $O(1)$If the data is static at the time of release, we don't need an origin server at all. We can precompute the dataset and push it directly to global edge nodes.Here is how exam-results-edge works under the hood:
[ Student Request ] │ ▼ ┌───────────────┐ │ Browser Cache │ ──(Hit: Instant load) └───────┬───────┘ │ Miss ▼ ┌───────────────┐ │ Workers Cache │ ──(Hit: Served at Edge in < 10ms) └───────┬───────┘ │ Miss ▼ ┌───────────────┐ │ Edge KV Store│ ──(Hit: O(1) Key Lookup) └───────────────┘ Key Architecture Highlights:No Traditional Database: Powered exclusively by Cloudflare Workers + Workers KV. No SQL, no relational engines, and no origin server.$O(1)$ Complexity: Every request translates to a single key-value lookup (e.g., student_id -> result_json). Zero loops, zero joins, zero query parsing
.3-Tier Aggressive Caching Strategy:Browser Cache: Prevents duplicate network requests from fast-clicking users.Workers Cache API: Serves popular requests directly from Edge memory.KV Edge Cache: Ultra-low latency fallback distributed across global data centers. In the majority of hits, the Worker script execution is completely bypassed!Real-World Scale: Seeded with 350,000+ synthetic student records (mirroring actual national exam volume) to test true real-world scaling, not just a trivial "Hello World" mock.Battle-Tested Load Testing: Pre-configured with k6 scripts to simulate millions of concurrent hits.Cost Breakdown: How is it $5?Traditional cloud setups (load balancers, autoscaling groups, managed databases) to handle a surge of tens of millions of hits in a few hours can easily cost hundreds or thousands of dollars.With an Edge KV architecture:Cloudflare Workers Paid Plan: $5 / month (includes 10 Million requests/month + generous KV reads).KV Read Pricing: $0.50 per 10 Million additional reads.Because aggressive edge caching absorbs over 80–90% of repeated requests, 100 Million hits can easily be served for roughly $5 to $10 total, with zero risk of server downtime or crashes.Summary & Source CodeBuilding systems capable of handling an entire nation’s traffic in a single second is a complex challenge, and the teams behind public infrastructure work under tough constraints.This project isn't a critique—it's a practical demonstration of how modern serverless, edge-native paradigms can eliminate server crashes while keeping operating costs virtually at zero.
📦 GitHub Repository: github.com/WaleedAlrashed/exam-results-edge🌐 Interactive Demo: exams.walrashed.syCheck out the repository README.md for full engineering notes, including why KV was chosen over SQL, cache configuration headers, cost estimation math, and k6 load test results!