Samarth Jain

Samarth Jain

Staff Software Engineer · Distributed Systems & Backend Architecture

I design and scale distributed backend systems: consensus, concurrency, and high-throughput services. Here I write about the trade-offs behind building software that holds up in production.

Featured writing

All posts

Designing Concurrent Rate Limiters in Go

Token buckets in Go, HTTP middleware, per-client and per-tenant limits, and why production systems eventually need a distributed limiter backed by Redis.

The Go Memory Model

How one goroutine’s writes become visible to another: happens-before, mutexes vs channels, atomics, safe publication, and catching data races in practice.

Building High-Throughput Worker Pools in Go

Bounding concurrency with worker pools: bounded queues and backpressure, cancellation, error handling, graceful shutdown, and sizing the pool.

Understanding Go Scheduler

What happens after go f(): the G-M-P model, run queues, work stealing, blocking syscalls, preemption, GOMAXPROCS, and how to observe it all with runtime tracing.

Concurrency in Go: Beyond Goroutines and Channels

Goroutines and channels are only the start. Concurrency vs parallelism, the scheduler, channels vs shared memory and the memory model: what it takes to build concurrent Go services that hold up in production.

Two Phase Commit Protocol

How 2PC coordinates atomic commits across nodes, a working Go implementation, the failure modes that make it a blocking protocol, and when it is the right tool.

Vertical vs Horizontal Scaling: Choosing Where the Next 10x Comes From

Scaling decisions start with finding the bottleneck, not choosing a pattern. When a bigger machine is the right answer, what it takes to make a service horizontally scalable, why stateful tiers are the hard part (with...

SOA vs Microservices: What Actually Differs, and How to Choose

The real difference between SOA and microservices isn’t service size. It’s where the logic lives and who owns the data. A side-by-side comparison, the hidden costs of a network boundary (with Go code), and a practical...

What Is Distributed Consensus, and Why Is It So Hard?

Why getting a handful of servers to agree on one value is one of the hardest problems in distributed systems: failure and timing models, FLP impossibility, why majority quorums work, and what consensus costs you in pr...