Day 11 of building an API Gateway in Go
Added request IDs and request tracing.
Now every request gets a unique ID that flows through the middleware and is passed to the backend using X Request ID, making it much easier to trace requests across services.
Also learned how to use context for request scoped data.
#backend #golang #buildinpublic
Day 10 of building an API Gateway in Go
Added graceful shutdown today.
The gateway now handles shutdown signals, stops background health monitors using context cancellation, and gracefully shuts down the HTTP server while allowing ongoing requests to finish.
Also learned more about Go concurrency, especially select, channel receive syntax <-, ctx.Done(), and how goroutines can be cleanly stopped.
#Go #Golang #Backend #APIGateway #BuildInPublic
Day 9 of building an API Gateway in Go
gh-https://t.co/4jKwW5iLRQ
Added periodic concurrent health checks using goroutines, channels and time.Ticker.
Now the load balancer checks backend health every 5 seconds and automatically updates its server list when a backend goes down or comes back up.
Also added Mutex protected shared state, panic recovery and ReverseProxy reuse using a Go map.
#backend #APIGateway #buildinpublic #Go #Golang
Day 8 of building an API Gateway in Go.
Today I made the backend health checks concurrent instead of checking each server sequentially.
Used goroutines to check multiple backend instances at the same time and channels to collect the health check results safely.
Also got a better understanding of how goroutines, channels, and shared state fit together in Go.
#golang #backend #buildinpublic
Day 7 of building an API Gateway in Go from scratch
Today I added health checks for backend services. The gateway now pings each service before adding it to the load balancer and only routes traffic to healthy instances.
Slowly making the gateway smarter.
#golang#backend #buildinpublic
@devXritesh one of my friend gave an interview for a full stack developer position the first round actualy invovled the use of AI to hunt and remove bugs from the code.
Day 6 of building an API Gateway from scratch in Go.
Today I implemented a Round Robin Load Balancer.
Until now, every request was being forwarded to a single backend instance. I changed the routing logic so the gateway now cycles through multiple backend servers, distributing traffic in a round robin fashion.
While implementing it, I also learned why concurrency matters. Since multiple requests can arrive at the same time, the server index is shared state. Without synchronization, two requests could pick the same backend or corrupt the index. Using sync.Mutex ensures only one goroutine updates the index at a time, making the load balancer thread safe.
Building these features from scratch has been helping me understand how API gateways actually work under the hood.
#golang #backend #buildinpublic #apigateway #fromscratch
Day 5 of building an API Gateway in Go.
Implemented a fixed window Rate Limiter from scratch using Go maps. Each client IP is limited to 5 requests every 30 seconds, after which the gateway responds with 429 Too Many Requests.
#golang#backend