Scalability Workflow
System Dataflows, Queues & Scale-Out Architecture
Security Mandate
This document blueprints the performance dataflow, caching matrix, asynchronous background processing architecture, and memory optimization layers for the Level 4 HMIS.
1. High-Throughput Concurrent Dataflow Architecture
The system optimizes for the highly asynchronous nature of a busy Kenyan Level 4 facility. During peak mid-morning hours, registration, triage, labs, and pharmacies generate complex read/write operations that must be handled smoothly without freezing the primary UI threads.
2. Multi-Tiered Redis Caching Framework
To reduce database roundtrips, the system implements a strict caching design. Read-heavy, static, or slow-changing domain data maps directly to multi-layered Redis cache stores.
2.1 Cache Retention & Invalidation Strategy
| Cache Key Pattern | Stored Data Objects | Eviction Strategy | TTL | Invalidation Triggers |
|---|---|---|---|---|
keml:drugs:v1 | Complete Kenya Essential Medicines List reference array | volatile-lru | 72 Hours | Procurement updates or KEML version updates. |
bed:occupancy:global | Active bed maps, ward counts, availability metrics | noeviction | 5 Minutes | Dynamic bed allocations, ward transfers, patient discharges. |
patient:session:auth:* | Active encrypted RBAC access tokens, session vectors | allkeys-lru | 15 Minutes | Explicit logout event or security termination block. |
tariff:nhif_sha:prices | Approved SHA procedures compensation values matrix | volatile-lru | 24 Hours | Statutory adjustment updates from the Ministry of Health. |
2.2 Defensive Cache Lookaside Implementation
The system wraps query reads in a declarative lookaside pattern to prevent database traffic spikes during sudden power restorations or system reboots:
3. Asynchronous Queue Processing via Huey
Background tasks, heavy analytics calculation engines, and downstream integrations are completely separated from the HTTP request-response thread lifecycle using Huey.
3.1 Production Worker Ingestion Configuration
The Huey queue infrastructure is tuned to run efficiently on our dual physical server setup. It uses task prioritization to ensure that patient-facing services (like printing prescriptions) are processed ahead of backend tasks (like running accounting reports).
4. Front-End Performance Optimization Layers
The Nuxt 4 frontend application minimizes local memory consumption and stays responsive even on older clinical client terminals (such as thin clients or refurbished core-i3 desktops common in regional facilities).
4.1 Real-Time Dashboard Updates via Server-Sent Events (SSE)
Rather than overloading the network with constant HTTP polling loops for queue status updates, the system uses lightweight, unidirectional Server-Sent Events (SSE). This approach maintains real-time active patient lists with minimal CPU overhead.
4.2 Local Storage Strategy for Client-Side Resiliency
- State Management Security: All user states are managed using lightweight, reactive Pinia stores inside Nuxt 4.
Document Verification Block
Author: Ian Wataka - Backend DeveloperTarget Scope: Level 4 Hospital Production Infrastructure