Day 38: Static concurrency limits cause queue collapse.
Replaced static semaphores with an AIMD adaptive load shedder tracking latency EMA. Combined with a lock-free sync/atomic circuit breaker, it shreds spikes in 0ms if Postgres drops.
#GoLang
Day 37: Load testing my Go RAG pipeline revealed some hard truths.
Built a bounded LRU cache with Singleflight, tuned my Postgres pool, and fixed a context leak. The result? 13,600+ requests with 0% failure. P99 latency dropped to 2.24ms. System is officially hardened.
#GoLang
Day 35: Re-architected my Go RAG pipeline
A.Bounded errgroup for massive batching
B.SHA-256 DB keys moved to Domain Model
C.Proved zero data dupes on DB failure #Golang#SystemDesign
4️⃣ Fixed Goroutine leaks by passing strict context cancellations to tear down worker pools on failure.
5️⃣ Added Postgres UPSERTs to prevent duplicate vectors on retries.
I tested it all live against the Gemini API & pgvector. It survives every edge case flawlessly.
#AI
Day 34: I audited my RAG ingestion pipeline in Go. It worked perfectly on the "happy path," but under heavy load, I found major flaws. Today, I stripped out the junior-level code and rebuilt it into a production-hardened system. Here is what changed. #Golang#Architecture
1️⃣ Scrapped my custom rate-limiter for https://t.co/Hj3tkvFC46 to fix context-cancellation bugs.
2️⃣ Shifted to Continuous Batch Ingestion (O(1) Streaming), keeping memory perfectly flat instead of hoarding vectors in RAM.
3️⃣ Used batch[:0] for zero-allocation memory reuse
Instead, I built a mathematical reservation system. It calculates the exact microsecond a token will be ready, reserves it, and sleeps exactly once. O(1) complexity, zero busypolling, and handles context cancellations with automatic token refunds. Write once, reuse everywhere
#AI
Day 33: When your concurrent RAG pipeline is too fast, you get hit with 429 Too Many Requests from OpenAI/Gemini.
Today, I reused the Token Bucket algorithm from my AI Gateway project to throttle my ingestion worker pool—but I completely avoided inefficient polling loops.
#Golang
Day 32: Massive distributed systems refactor
1. Built a "Shield & Sweep" pattern to safely hot-swap embedding models without index bloat.
2. Added a 24-hour delayed sweep to guarantee free API rollbacks if a new model flops.
3. Built a clean Pipeline Orchestrator
#Golang#AI
@moveToMoonlight You're so right🫡 ..i think decoupling the sweep into a 24hr delayed background job is nice move....btw appreciate the masterclass today man🙏
Day 31: Hardened my Go RAG pipeline against silent rate-limit data drops:
🔒 Atomic Postgres locks for idempotency
📥 Dead-letter queue for zero chunk loss
Engineering for failure > happy paths. Deployment next
#Golang#BuildInPublic#AI
@moveToMoonlight Ahh btw i forgot to appriciate your deep thinking before..yeah i got it,so i think the best way is using both ideas.that means use filter to hide the old vectors from the users and use the sweep just to delete them to save database space
@moveToMoonlight That's great point .. okay what about this i mean instead of deleting the old vectors first, what if we save the new vectors,verify the succeeded and only then delete the old ones?..then there are no silent holes
@moveToMoonlight Yeah i got you,you're right..but if we just filter, it still holds up our database so instead of filter, i just made it delete the old vectors before passing in the new ones..so it keeps db space free..is this nice?
@moveToMoonlight Yeah it is nice catch.i hadnot even thought about vector space collisions if the model swaps...updating the indempotency key to include provide + model is a must so we dont quitely poison the index with noise..thank you man
@MarcosRGjr@LeoOliemans91 I think it is nice about the dead man's switch analogy here. Failing safe and pausing the pipeline is way better than risking duplicate data.i'll check it out
@LeoOliemans91 That's a really good edge case to test. If the ack drops,the retry has to check the DB state before attempting to reinsert.i'm adding a specific test for this today..thank you
Day 30: RAG Pipeline Architecture Review
Stepped back today to review my Go RAG pipeline:
:-Overlapping chunking
:-Decoupled Embedders (OpenAI/Gemini)
:-Go Worker Pools
:-pgvector (1536d) & Cosine Search
:- gRPC API w/ graceful shutdown
#golang#backendengineering