Skip to main content

๐—ง๐˜‚๐—ฟ๐—ป๐—ถ๐—ป๐—ด ๐—ฎ ๐—™๐˜‚๐—ป ๐—œ๐—ฑ๐—ฒ๐—ฎ ๐—ถ๐—ป๐˜๐—ผ ๐—ฎ ๐—ฃ๐—ฟ๐—ผ๐—ฑ๐˜‚๐—ฐ๐˜๐—ถ๐—ผ๐—ป-๐—ฅ๐—ฒ๐—ฎ๐—ฑ๐˜† ๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฐ๐—ฒ

๐—ช๐—ต๐—ฎ๐˜ ๐—œ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป๐—ฒ๐—ฑ ๐—•๐˜‚๐—ถ๐—น๐—ฑ๐—ถ๐—ป๐—ด ๐— ๐˜† ๐—™๐—ถ๐—ฟ๐˜€๐˜ ๐—”๐—ฃ๐—œ

Updated 2 min readMarkdown
๐—ง๐˜‚๐—ฟ๐—ป๐—ถ๐—ป๐—ด ๐—ฎ ๐—™๐˜‚๐—ป ๐—œ๐—ฑ๐—ฒ๐—ฎ ๐—ถ๐—ป๐˜๐—ผ ๐—ฎ ๐—ฃ๐—ฟ๐—ผ๐—ฑ๐˜‚๐—ฐ๐˜๐—ถ๐—ผ๐—ป-๐—ฅ๐—ฒ๐—ฎ๐—ฑ๐˜† ๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฐ๐—ฒ

Iโ€™ve recently been diving into Go, and after a few weeks of exploration, I decided to move beyond tutorials and build a functional sandbox project:

๐——๐—ฒ๐—ป๐˜†-๐—•๐˜†-๐——๐—ฒ๐—ณ๐—ฎ๐˜‚๐—น๐˜-๐—ฎ๐˜€-๐—ฎ-๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฐ๐—ฒ (๐——๐—•๐——๐—ฎ๐—ฎ๐—ฆ)

๐Ÿš€ API: https://dbdaas.rajathjaiprakash.com/
๐Ÿ’ป GitHub: rajathjn/deny-by-default-as-a-service: deny-by-default-as-a-service

Inspired by the "No-as-a-Service" concept, the API returns creative and sometimes sassy reasons to say "No," with an optional "Yes" toggle for balance. While the concept is lighthearted,ย I approached the implementation with the technical rigor expected of a production system.

I strongly believe even hobby projects are opportunities to apply sound engineering principles.

Here are the key choices I focused on:

๐Ÿ”น๐—ก๐—ฒ๐˜๐˜„๐—ผ๐—ฟ๐—ธ ๐—ฅ๐—ฒ๐˜€๐—ถ๐—น๐—ถ๐—ฒ๐—ป๐—ฐ๐—ฒ & ๐—–๐—ผ๐—ป๐—ป๐—ฒ๐—ฐ๐˜๐—ถ๐—ผ๐—ป ๐—›๐—ฎ๐—ป๐—ฑ๐—น๐—ถ๐—ป๐—ด

To protect against resource exhaustion and Slowloris-style attacks, I moved beyond default server settings. I had to implement specific read, write, and idle timeout values to ensure the service remains resilient under connection pressure.

๐Ÿ”น๐—ฅ๐—ฎ๐˜๐—ฒ ๐—Ÿ๐—ถ๐—บ๐—ถ๐˜๐—ถ๐—ป๐—ด & ๐—ฃ๐—ฟ๐—ผ๐˜…๐˜† ๐—”๐˜„๐—ฎ๐—ฟ๐—ฒ๐—ป๐—ฒ๐˜€๐˜€

For a publicly accessible API, abuse prevention is essential. I had to implement a custom middleware and configure trusted proxy settings to ensure accurate client IP resolution behind load balancers, all to enforce a steady limit of 30 requests per minute per IP, ensuring fair usage while maintaining a stateless design.

๐Ÿ”น๐— ๐—ถ๐—ป๐—ถ๐—บ๐—ฎ๐—น๐—ถ๐˜€๐˜ & ๐—ฆ๐—ฒ๐—ฐ๐˜‚๐—ฟ๐—ฒ ๐—–๐—ผ๐—ป๐˜๐—ฎ๐—ถ๐—ป๐—ฒ๐—ฟ๐—ถ๐˜‡๐—ฎ๐˜๐—ถ๐—ผ๐—ป

Security and efficiency were top priorities. I utilized a multi-stage Docker build to produce a final image based on scratch. This resulted in a hyper-lean container, which has a minimal runtime footprint and significantly reduces the attack surface by including only the compiled binary.

๐Ÿ”น๐—˜๐—บ๐—ฏ๐—ฒ๐—ฑ๐—ฑ๐—ฒ๐—ฑ ๐—›๐—ฒ๐—ฎ๐—น๐˜๐—ต ๐—ฆ๐—ถ๐—ด๐—ป๐—ฎ๐—น๐—ถ๐—ป๐—ด

Since scratch images lack standard debugging utilities, I embedded a health flag directly into the binary. This allows the container to self-report health status via Docker health checks without external dependencies.

๐Ÿ”น๐—š๐—ฟ๐—ฎ๐—ฐ๐—ฒ๐—ณ๐˜‚๐—น ๐—ง๐—ฒ๐—ฟ๐—บ๐—ถ๐—ป๐—ฎ๐˜๐—ถ๐—ผ๐—ป

Implemented signal handling to enable controlled shutdowns, allowing in-flight requests to complete while preventing new ones. This is critical for reliability during deployments and scaling events.

Key Takeaway:
The most rewarding part of this exercise was realizing how naturally Go supports building reliable, concurrent, and production-ready systems.
This project reinforced the importance of treating every system, no matter the scale, as an opportunity to practice production-grade engineering.

Iโ€™d love to hear your thoughts or feedback!

#Golang #CloudNative #BackendDevelopment #GoProgramming #SoftwareEngineering #Docker #API #SoftwareArchitecture #LearningInPublic

No comments yet. Be the first to comment.