Skip to main content

Command Palette

Search for a command to run...

Why I Built My Own Caching Proxy Server in Go

Simple yet powerful proxy server for caching purposes.

Updated
2 min read
D
Revolves around AI & Distributed Systems

I recently built a proxy server specifically for caching purposes, and I am going to use it for a side project that I will be hosting soon. The reason behind it is simple: not all internet requests need to be fetched directly from the database if the data is static and rarely changes.

Proxy Sever  Architecture

The working mechanism of this server is quite straightforward. It points to the origin backend API responsible for the data, and it caches that data in memory for super-fast retrieval with a customizable TTL (Time-To-Live).

Under the hood, I am using an LRU cache implemented with a hash map and a doubly linked list to keep our server RAM predictable while maintaining the best possible performance. However, as we know, this implementation is good for textbooks but not ideal for highly scalable systems. The primary reason behind building this was simply to test my boundaries and learn something new.

In this proxy server implementation, I have added several features like session-based authentication, manual deployment, and a forwarding server list to ensure that every request is predictable and monitored by us. I know we can make it even better, but to be frank, this project was solely built to learn Go and explore some of its built-in libraries, like sync, to understand concurrency.

If you loved my article, I am sure you will love my code too! Please star the repo and follow me on GitHub :)