1. The Problem
During orientation week, over 2,000 freshmen arrived within a 48-hour window for credential verification, hostel inventory assignment, and access card provisioning. The legacy system was an unindexed single-table PHP script running on shared hosting. Under peak load, concurrent queries caused severe database row locks, resulting in page timeouts (504 Gateway Timeout), unrecorded inventory distributions, and physical queues stretching over 3 hours with each student taking ~15 minutes to verify.
2. What I Built
I redesigned the platform from the ground up using a normalized 12-table relational schema with indexed foreign keys and composite indexes on student admission numbers and barcode hashes. To eliminate database write lock contention during mass ingress, I engineered an asynchronous JSON cache layer (`cache_stats.json`) that buffered high-frequency read lookups and write tallies in memory before flushing in batches. I developed a lightweight RESTful barcode verification API delivering sub-50ms scans for staff handheld devices, and implemented a Role-Based Access Control (RBAC) matrix that allowed 18 intake stations to operate simultaneously with strict privilege separation.
3. Architecture & Technology Stack
| PHP 8.1 API | Lightweight REST verification endpoints with token authorization |
| MySQL / MariaDB | 12-table normalized schema with B-Tree composite indexing on admission numbers |
| JSON Cache Layer | In-memory / file-buffered async cache (cache_stats.json) preventing write locks |
| NGINX | HTTP rate limiting, Gzip compression, and IP restriction on admin routes |
| Ubuntu VPS | Systemd service units and memory swap tuning for traffic bursts |
| CI/CD Pipeline | GitHub Actions with scheduled off-peak deployment hooks |
4. Results & Measurable Metrics
- Processed 2,400+ student intake sessions smoothly across a 48-hour peak orientation window.
- Average query response time dropped from ~420ms down to 18ms via the async JSON cache layer.
- Barcode verification API maintained sub-50ms acknowledgement latency across 18 concurrent scanner stations.
- Average verification and inventory allocation time per student decreased from 15 minutes to under 30 seconds.
- Zero server crashes or database timeout errors recorded during the entire intake cycle.
5. What I'd Do Differently
While the asynchronous JSON buffer solved our row locking problem reliably for 2,400 students, file-based JSON caching requires file lock management (`LOCK_EX`) that wouldn't scale gracefully to tens of thousands of concurrent writes. Today, I would use Redis with pub/sub or an in-memory queue to handle the caching layer, and introduce structured JSON logging (e.g. Monolog into Loki or Elasticsearch) for richer real-time diagnostics.