Mitigating WireGuard VPN Latency Overhead on Sequential ORM Queries Using Redis Caching - Juri Pebrianto; Ridhwan Dery Iradat (Universitas Suryakancana Cianjur, 2026)
The transition to distributed cloud architectures relies heavily on Virtual Private Networks (VPNs) like WireGuard for secure communication, and Object-Relational Mapping (ORM) frameworks for rapid application development. However, the sequential query generation (N+1 query problem) inherent in ORMs creates a severe latency bottleneck when traversing encrypted network tunnels. Objective: This study aims to quantitatively evaluate the performance degradation caused by WireGuard VPN latency on ORM-driven relational databases and measure the effectiveness of Redis in-memory caching as an architectural mitigation strategy. Methods: A quantitative experimental approach was conducted using a containerized multi-VM topology to isolate environment variables. We compared the execution latency of PostgreSQL and Redis under a local baseline scenario against a remote WireGuard VPN environment, utilizing mathematical modeling to analyze the bottleneck shift from disk I/O to network Round Trip Time (RTT). Results: Experimental results reveal that PostgreSQL latency spiked exponentially by 52,400% (from 0.04 ms to 21.00 ms) when forced through the VPN due to accumulated RTT. Conversely, implementing Redis caching bypassed the synchronous relational overhead, restricting the latency spike to 5,860% (13.13 ms) and yielding a 1.43x system speedup. In a simulated extreme N+1 scenario (500 sequential queries), Redis caching saved approximately 4 seconds of execution time. Conclusion: Shifting the computational load from relational disk to asynchronous memory is not merely an optional performance enhancement but an architectural necessity for ORM-based applications deployed over encrypted networks. Future research should explore AI-driven automated caching strategies to address dynamic workloads.