<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><title>Ankit Rana | Mechanical Sympathy</title><description>Engineering logs on distributed systems, database internals, CPU and memory behaviour, and AI infrastructure by Ankit Rana, Senior Software Engineer at Walmart Global Tech.</description><link>https://ankit-rana.com/</link><language>en-us</language><managingEditor>hello@ankit-rana.com (Ankit Rana)</managingEditor><webMaster>hello@ankit-rana.com (Ankit Rana)</webMaster><copyright>© 2026 Ankit Rana</copyright><item><title>Ordering without clocks: Lamport timestamps and vector clocks in practice</title><link>https://ankit-rana.com/logs/75-ordering-without-clocks-logical-time/</link><guid isPermaLink="true">https://ankit-rana.com/logs/75-ordering-without-clocks-logical-time/</guid><description>A wall clock cannot order events across machines because clocks drift and NTP corrections can move time backwards. A Lamport timestamp is a counter incremented on every event and carried on every message, which guarantees that if one event caused another the causal one has a smaller number, giving a consistent total order without any clock. It cannot tell you whether two events were concurrent, which is exactly the question you need answered during a conflict, and that is what vector clocks provide at the cost of storing one counter per node.</description><pubDate>Mon, 16 Nov 2026 00:00:00 GMT</pubDate><category>logical-clocks</category><category>lamport-timestamps</category><category>vector-clocks</category><category>distributed-systems</category><category>causality</category><category>conflict-resolution</category><author>hello@ankit-rana.com</author></item><item><title>Tail latency amplification: why p99 of one service becomes p50 of the aggregate</title><link>https://ankit-rana.com/logs/74-tail-latency-amplification/</link><guid isPermaLink="true">https://ankit-rana.com/logs/74-tail-latency-amplification/</guid><description>A request that waits on N backends completes at the speed of the slowest one, so the probability of hitting a slow response is one minus the probability of avoiding it N times. At a hundred parallel calls to a service whose p99 is 100ms, roughly 63 percent of requests contain at least one 100ms response, which turns a rare event at the component level into the common case at the aggregate. Sending a duplicate request after a short delay collapses that tail for a few percent extra load.</description><pubDate>Thu, 12 Nov 2026 00:00:00 GMT</pubDate><category>tail-latency</category><category>performance</category><category>distributed-systems</category><category>fan-out</category><category>latency</category><category>observability</category><author>hello@ankit-rana.com</author></item><item><title>Service mesh: what it buys and the latency it charges</title><link>https://ankit-rana.com/logs/73-service-mesh-what-it-buys-and-charges/</link><guid isPermaLink="true">https://ankit-rana.com/logs/73-service-mesh-what-it-buys-and-charges/</guid><description>A sidecar proxy adds two extra network hops per call, typically half a millisecond to two milliseconds of added latency plus memory and CPU per pod. The comparison people make is against having nothing, which is wrong, because the mTLS, retries, circuit breaking and telemetry it provides were previously implemented as libraries that had their own cost and had to be upgraded across every service. A mesh is worth it when you have enough services in enough languages that library sprawl is the larger problem, and it is overhead when you do not.</description><pubDate>Mon, 09 Nov 2026 00:00:00 GMT</pubDate><category>service-mesh</category><category>istio</category><category>envoy</category><category>kubernetes</category><category>latency</category><category>platform-engineering</category><author>hello@ankit-rana.com</author></item><item><title>Retry storms: how the resilience layer became the outage</title><link>https://ankit-rana.com/logs/72-retry-storms-resilience-became-the-outage/</link><guid isPermaLink="true">https://ankit-rana.com/logs/72-retry-storms-resilience-became-the-outage/</guid><description>Retries configured independently at each hop multiply, so three layers each retrying three times means nine requests reaching the bottom for every one at the top. When a dependency degrades, that multiplier arrives exactly when it has least capacity, and the retries alone can keep it down after the original cause is gone. Per-call retry counts cannot bound this because no layer knows what the others are doing, which is why the useful control is a retry budget expressed as a fraction of total traffic.</description><pubDate>Thu, 05 Nov 2026 00:00:00 GMT</pubDate><category>retries</category><category>resilience</category><category>reliability</category><category>distributed-systems</category><category>circuit-breaker</category><category>backpressure</category><author>hello@ankit-rana.com</author></item><item><title>R plus W greater than N is the arithmetic that decides your consistency</title><link>https://ankit-rana.com/logs/71-quorum-arithmetic-r-plus-w/</link><guid isPermaLink="true">https://ankit-rana.com/logs/71-quorum-arithmetic-r-plus-w/</guid><description>In a replicated store with N copies, reading from R replicas and writing to W replicas guarantees a read sees the latest write only when R plus W exceeds N, because that forces the two sets to share at least one replica. The inequality is the entire guarantee, and it says nothing about which value wins when two writes happen concurrently, so overlap gives you recency and not conflict resolution. Tuning R and W is choosing where to spend latency, since the coordinator waits for the slowest replica in whichever set is larger.</description><pubDate>Mon, 02 Nov 2026 00:00:00 GMT</pubDate><category>quorum</category><category>replication</category><category>consistency</category><category>distributed-systems</category><category>cassandra</category><category>dynamo</category><author>hello@ankit-rana.com</author></item><item><title>Leader election is easy, failover is where systems die</title><link>https://ankit-rana.com/logs/70-leader-election-failover-fencing/</link><guid isPermaLink="true">https://ankit-rana.com/logs/70-leader-election-failover-fencing/</guid><description>Electing a leader is a solved problem that libraries handle well. The hard part is that a leader which has been declared dead often does not know it, because a garbage collection pause or a network partition is indistinguishable from being alive and idle from the inside. The old leader resumes and keeps writing, so for a window there are two. Only a monotonically increasing fencing token checked at the storage layer stops the stale writer, because every timeout-based scheme assumes a clock nobody controls.</description><pubDate>Thu, 29 Oct 2026 00:00:00 GMT</pubDate><category>leader-election</category><category>distributed-systems</category><category>fencing</category><category>consensus</category><category>reliability</category><category>zookeeper</category><author>hello@ankit-rana.com</author></item><item><title>Your trace has a gap exactly where the bug is</title><link>https://ankit-rana.com/logs/69-trace-gap-where-the-bug-is/</link><guid isPermaLink="true">https://ankit-rana.com/logs/69-trace-gap-where-the-bug-is/</guid><description>Distributed tracing works by passing a context object along the call path, and any boundary that does not carry it forward silently ends the trace. Thread pool handoffs, message queues, callbacks and library-managed retries are the usual places, which is unfortunate because those are also where the latency and the bugs live. A gap does not appear as an error, it appears as a span that seems to take four seconds while its children are simply absent.</description><pubDate>Mon, 26 Oct 2026 00:00:00 GMT</pubDate><category>observability</category><category>distributed-tracing</category><category>opentelemetry</category><category>debugging</category><category>distributed-systems</category><category>context-propagation</category><author>hello@ankit-rana.com</author></item><item><title>The saga pattern is compensating transactions with better marketing</title><link>https://ankit-rana.com/logs/68-sagas-are-compensating-transactions/</link><guid isPermaLink="true">https://ankit-rana.com/logs/68-sagas-are-compensating-transactions/</guid><description>A saga replaces one atomic transaction with a sequence of local transactions, each of which commits and becomes visible immediately, so there is no isolation and intermediate states are observable. When a later step fails, earlier ones are undone by running compensating actions, which are forward operations with their own failure modes rather than a rollback. The difficulty is not the mechanism but the steps that cannot be compensated, such as an email already sent or a payment already captured, which have to be designed around rather than reversed.</description><pubDate>Thu, 22 Oct 2026 00:00:00 GMT</pubDate><category>saga</category><category>distributed-transactions</category><category>microservices</category><category>compensating-transactions</category><category>architecture</category><category>reliability</category><author>hello@ankit-rana.com</author></item><item><title>Two-phase commit is not dead, it is just expensive and you should know the price</title><link>https://ankit-rana.com/logs/67-two-phase-commit-is-expensive-not-dead/</link><guid isPermaLink="true">https://ankit-rana.com/logs/67-two-phase-commit-is-expensive-not-dead/</guid><description>Two-phase commit gives real atomicity across independent resource managers, and it pays for it by making every participant hold locks from the moment it votes until the coordinator tells it what to do. If the coordinator dies in that window, participants are stuck holding locks with no legal way to proceed, because they promised they could commit and cannot take it back. Availability is the product of every participant&apos;s availability, so adding services makes the transaction less likely to complete rather than more.</description><pubDate>Mon, 19 Oct 2026 00:00:00 GMT</pubDate><category>two-phase-commit</category><category>distributed-transactions</category><category>consistency</category><category>distributed-systems</category><category>databases</category><category>architecture</category><author>hello@ankit-rana.com</author></item><item><title>Virtual threads changed the calculus for blocking I/O and not for CPU work</title><link>https://ankit-rana.com/logs/66-virtual-threads-blocking-io-not-cpu/</link><guid isPermaLink="true">https://ankit-rana.com/logs/66-virtual-threads-blocking-io-not-cpu/</guid><description>A virtual thread that blocks on I/O unmounts from its carrier and costs nothing while it waits, which makes thread-per-request viable at concurrency levels that would have needed reactive code. It does nothing for CPU bound work, because computation still needs a real core and the carrier pool is sized to the core count. Pooling virtual threads is an anti-pattern since they are cheap to create, and blocking inside a synchronized block pins the carrier, which can deadlock a workload that would have been fine on platform threads.</description><pubDate>Thu, 15 Oct 2026 00:00:00 GMT</pubDate><category>virtual-threads</category><category>java</category><category>concurrency</category><category>loom</category><category>performance</category><category>jvm</category><author>hello@ankit-rana.com</author></item><item><title>Idempotency keys: the API contract that makes retries safe</title><link>https://ankit-rana.com/logs/65-idempotency-keys-api-contract/</link><guid isPermaLink="true">https://ankit-rana.com/logs/65-idempotency-keys-api-contract/</guid><description>A client that times out cannot distinguish a request that failed from one that succeeded with a lost response, so it must retry, and without an idempotency key that retry duplicates the write. The key has to be reserved before the work begins, in the same transaction, so two concurrent copies of the same request cannot both pass the check. The stored response must then be replayed verbatim, because recomputing it can return a different answer than the one the first caller received.</description><pubDate>Mon, 12 Oct 2026 00:00:00 GMT</pubDate><category>idempotency</category><category>api-design</category><category>reliability</category><category>distributed-systems</category><category>postgresql</category><category>retries</category><author>hello@ankit-rana.com</author></item><item><title>Immutability is a concurrency strategy, not a style preference</title><link>https://ankit-rana.com/logs/64-immutability-is-a-concurrency-strategy/</link><guid isPermaLink="true">https://ankit-rana.com/logs/64-immutability-is-a-concurrency-strategy/</guid><description>An object that cannot change after construction is safe to share across threads with no lock, no volatile, and no reasoning about happens-before, because there is no write for a reader to miss. That removes an entire category of bug rather than mitigating it. The usual objection is allocation cost, and it is generally the wrong trade to optimise: short lived objects are cheap to collect, while a data race is invisible in testing and reproduces once a quarter in production.</description><pubDate>Thu, 08 Oct 2026 00:00:00 GMT</pubDate><category>immutability</category><category>concurrency</category><category>java</category><category>thread-safety</category><category>design</category><category>memory-model</category><author>hello@ankit-rana.com</author></item><item><title>Thread pool starvation from nested async calls</title><link>https://ankit-rana.com/logs/63-thread-pool-starvation-nested-async/</link><guid isPermaLink="true">https://ankit-rana.com/logs/63-thread-pool-starvation-nested-async/</guid><description>A task that blocks waiting for another task submitted to the same bounded pool can deadlock, because the thread it needs is the thread it is occupying. With N threads and N waiting parents, every thread is blocked on work that has no thread left to run it. Nothing detects this, there is no error and no timeout by default, so the service simply stops responding while looking healthy. Raising the pool size delays it rather than fixing it, since the failure needs only enough concurrent parents to fill the pool.</description><pubDate>Mon, 05 Oct 2026 00:00:00 GMT</pubDate><category>concurrency</category><category>thread-pool</category><category>deadlock</category><category>java</category><category>completablefuture</category><category>reliability</category><author>hello@ankit-rana.com</author></item><item><title>Optimistic vs pessimistic locking: choose by contention, not preference</title><link>https://ankit-rana.com/logs/62-optimistic-vs-pessimistic-locking/</link><guid isPermaLink="true">https://ankit-rana.com/logs/62-optimistic-vs-pessimistic-locking/</guid><description>Optimistic locking detects conflict at write time using a version column, so readers never block and the cost of a conflict is a wasted transaction plus a retry. Pessimistic locking prevents conflict by taking a lock up front, so work is never wasted and contending writers queue. The crossover is contention: below a few percent conflict rate optimistic wins clearly, above roughly ten percent the retry storm costs more than the queue would have. Both are wrong for a human editing a form, where the correct answer is to show the conflict rather than resolve it.</description><pubDate>Sat, 03 Oct 2026 00:00:00 GMT</pubDate><category>concurrency</category><category>locking</category><category>optimistic-locking</category><category>postgresql</category><category>jpa</category><category>transactions</category><author>hello@ankit-rana.com</author></item><item><title>Backpressure is not rate limiting, and treating them the same fills your queues</title><link>https://ankit-rana.com/logs/61-backpressure-is-not-rate-limiting/</link><guid isPermaLink="true">https://ankit-rana.com/logs/61-backpressure-is-not-rate-limiting/</guid><description>Rate limiting enforces a fixed ceiling chosen in advance, which protects you from a producer that sends too much and does nothing when your own capacity drops. Backpressure is a signal travelling backwards from the component that is actually struggling, so the allowed rate tracks real capacity instead of a guess. The thing that defeats both is an unbounded queue, because it absorbs the overload silently and converts a fast rejection into unbounded latency and eventually a memory failure.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>backpressure</category><category>rate-limiting</category><category>reliability</category><category>queues</category><category>distributed-systems</category><category>resilience</category><author>hello@ankit-rana.com</author></item><item><title>Heap looks fine, pod still OOM killed</title><link>https://ankit-rana.com/logs/60-heap-fine-pod-oom-killed/</link><guid isPermaLink="true">https://ankit-rana.com/logs/60-heap-fine-pod-oom-killed/</guid><description>A container limit applies to the whole process, and the Java heap is only one part of what a JVM allocates. Thread stacks, metaspace, the code cache, direct byte buffers and native allocations inside libraries all live outside the heap and outside every heap graph, so a service can be killed by the kernel while its heap chart shows plenty of headroom. The kill produces no Java exception and no stack trace, because SIGKILL gives the process no opportunity to report anything.</description><pubDate>Tue, 29 Sep 2026 00:00:00 GMT</pubDate><category>jvm</category><category>memory</category><category>kubernetes</category><category>oom</category><category>java</category><category>containers</category><author>hello@ankit-rana.com</author></item><item><title>Your p99 is a garbage collector setting</title><link>https://ankit-rana.com/logs/59-p99-is-a-garbage-collector-setting/</link><guid isPermaLink="true">https://ankit-rana.com/logs/59-p99-is-a-garbage-collector-setting/</guid><description>A p99 that is many times the median with no matching slow code path is usually a stop the world garbage collection pause, which stops every application thread regardless of what it was doing. The lever is allocation rate rather than heap size, because most collectors scale their work with the number of surviving objects and the frequency of collection follows directly from how fast you fill the young generation. Enlarging the heap reduces collection frequency and can lengthen each pause, which trades a common small delay for a rare large one.</description><pubDate>Sun, 27 Sep 2026 00:00:00 GMT</pubDate><category>jvm</category><category>garbage-collection</category><category>latency</category><category>performance</category><category>java</category><category>observability</category><author>hello@ankit-rana.com</author></item><item><title>The GIL is not why your Python is slow</title><link>https://ankit-rana.com/logs/58-the-gil-is-not-why-your-python-is-slow/</link><guid isPermaLink="true">https://ankit-rana.com/logs/58-the-gil-is-not-why-your-python-is-slow/</guid><description>The global interpreter lock only prevents two threads from executing Python bytecode simultaneously, and it is released during file and socket I/O, during most C extension work including NumPy and compression, and periodically during long computation. A typical service spends its time waiting on the network or serialising JSON, neither of which the lock affects. Before blaming it, profile: the answer is usually N+1 queries, unbatched round trips or serialisation, and none of those get faster by removing the lock.</description><pubDate>Fri, 25 Sep 2026 00:00:00 GMT</pubDate><category>python</category><category>gil</category><category>concurrency</category><category>performance</category><category>profiling</category><category>multiprocessing</category><author>hello@ankit-rana.com</author></item><item><title>Async does not mean parallel, and confusing them costs you a thread pool</title><link>https://ankit-rana.com/logs/57-async-does-not-mean-parallel/</link><guid isPermaLink="true">https://ankit-rana.com/logs/57-async-does-not-mean-parallel/</guid><description>Async is about not blocking while waiting for something else, and parallel is about doing two things at the same instant on different cores. An event loop achieves enormous concurrency with one thread because most request time is spent waiting on I/O, and that same design collapses the moment a handler does real computation, because nothing else runs until it finishes. Marking CPU bound work async does not make it faster and usually makes latency worse by moving it onto a thread other work depends on.</description><pubDate>Wed, 23 Sep 2026 00:00:00 GMT</pubDate><category>concurrency</category><category>async</category><category>event-loop</category><category>python</category><category>nodejs</category><category>performance</category><author>hello@ankit-rana.com</author></item><item><title>Deadlocks are a lock ordering bug, and lock ordering is a design decision</title><link>https://ankit-rana.com/logs/56-deadlocks-are-a-lock-ordering-bug/</link><guid isPermaLink="true">https://ankit-rana.com/logs/56-deadlocks-are-a-lock-ordering-bug/</guid><description>A deadlock needs four conditions and the only one you control is circular wait, which is why every deadlock reduces to two transactions acquiring the same locks in opposite orders. Imposing a global order on lock acquisition, usually by sorting the identifiers before touching any row, makes the cycle impossible to form. A database deadlock is the survivable version because the engine detects it and kills a victim, and an application level deadlock across two mutexes has no detector and simply hangs.</description><pubDate>Mon, 21 Sep 2026 00:00:00 GMT</pubDate><category>deadlocks</category><category>concurrency</category><category>locking</category><category>postgresql</category><category>transactions</category><category>java</category><author>hello@ankit-rana.com</author></item><item><title>Hot keys defeat consistent hashing</title><link>https://ankit-rana.com/logs/55-hot-keys-defeat-consistent-hashing/</link><guid isPermaLink="true">https://ankit-rana.com/logs/55-hot-keys-defeat-consistent-hashing/</guid><description>Consistent hashing distributes keys evenly across nodes, which is a different problem from distributing traffic evenly. One key that receives forty percent of requests lands on exactly one node no matter how many virtual nodes you configure, and adding capacity does nothing because the bottleneck is a single key rather than the cluster. Fixing it requires changing the key: replicating it under several suffixes, splitting the value into shards, or putting a small local cache in front of the handful of keys that are actually hot.</description><pubDate>Sat, 19 Sep 2026 00:00:00 GMT</pubDate><category>caching</category><category>hot-keys</category><category>consistent-hashing</category><category>redis</category><category>sharding</category><category>scalability</category><author>hello@ankit-rana.com</author></item><item><title>Local cache plus distributed cache: the coherence bill nobody budgets for</title><link>https://ankit-rana.com/logs/54-local-and-distributed-cache-coherence/</link><guid isPermaLink="true">https://ankit-rana.com/logs/54-local-and-distributed-cache-coherence/</guid><description>An in-process cache in front of a distributed cache removes a network hop and adds one independent copy of the data per instance, each of which can be stale on its own schedule. Invalidation is normally broadcast over pub/sub, which is fire and forget, so any instance that is restarting, garbage collecting or briefly disconnected simply misses the message and serves stale data until its TTL expires. That TTL is not a performance setting, it is the maximum duration of incorrectness.</description><pubDate>Thu, 17 Sep 2026 00:00:00 GMT</pubDate><category>caching</category><category>cache-coherence</category><category>redis</category><category>distributed-systems</category><category>consistency</category><category>jvm</category><author>hello@ankit-rana.com</author></item><item><title>Why your Redis is slow: it is single threaded and you sent it KEYS</title><link>https://ankit-rana.com/logs/53-redis-single-threaded-keys-command/</link><guid isPermaLink="true">https://ankit-rana.com/logs/53-redis-single-threaded-keys-command/</guid><description>Redis executes commands one at a time on a single thread, so any command that takes 200ms makes every other client wait 200ms regardless of how trivial their request was. KEYS scans the entire keyspace and is the obvious offender, but DEL on a large collection, unbounded LRANGE, SMEMBERS on a big set and FLUSHALL are all linear in the size of the data and block identically. The tell is a latency spike across all operations at once while CPU and network look normal.</description><pubDate>Tue, 15 Sep 2026 00:00:00 GMT</pubDate><category>redis</category><category>latency</category><category>caching</category><category>performance</category><category>single-threaded</category><category>observability</category><author>hello@ankit-rana.com</author></item><item><title>Cache invalidation is a distributed systems problem in a convenience costume</title><link>https://ankit-rana.com/logs/52-cache-invalidation-distributed-problem/</link><guid isPermaLink="true">https://ankit-rana.com/logs/52-cache-invalidation-distributed-problem/</guid><description>A cache and a database are two stores that must agree, which makes every invalidation a distributed transaction without a coordinator. The ordering matters more than the mechanism: invalidating before the database write leaves a window where a concurrent reader repopulates the cache with the old value and it stays wrong until the TTL expires. Deleting the key rather than writing the new value removes a whole class of ordering bug, because two concurrent deletes commute and two concurrent writes do not.</description><pubDate>Sun, 13 Sep 2026 00:00:00 GMT</pubDate><category>caching</category><category>cache-invalidation</category><category>consistency</category><category>distributed-systems</category><category>redis</category><category>race-conditions</category><author>hello@ankit-rana.com</author></item><item><title>Write-through, write-behind, write-around: picking wrong costs you consistency or throughput</title><link>https://ankit-rana.com/logs/51-write-through-behind-around/</link><guid isPermaLink="true">https://ankit-rana.com/logs/51-write-through-behind-around/</guid><description>The three write strategies differ in what happens between the cache write and the database write, and that gap is where correctness lives. Write-through updates both before acknowledging, so it is safe and pays the full database latency. Write-behind acknowledges after the cache write and flushes later, which is fast and can lose acknowledged writes if the process dies. Write-around skips the cache entirely on write, which avoids caching data nobody reads and costs a miss on the next read.</description><pubDate>Fri, 11 Sep 2026 00:00:00 GMT</pubDate><category>caching</category><category>write-through</category><category>write-behind</category><category>redis</category><category>consistency</category><category>system-design</category><author>hello@ankit-rana.com</author></item><item><title>Negative caching: the misses cost more than the hits</title><link>https://ankit-rana.com/logs/50-negative-caching-misses-cost-more/</link><guid isPermaLink="true">https://ankit-rana.com/logs/50-negative-caching-misses-cost-more/</guid><description>A cache that stores only found values gives you no protection against lookups for things that do not exist, and a miss on a nonexistent key costs the full origin query every single time. If the key is user supplied, an attacker can generate unlimited unique misses and bypass the cache entirely, which is cache penetration. Caching the negative result fixes it, with a shorter TTL than positive entries because a value appearing is a much more likely event than one disappearing.</description><pubDate>Wed, 09 Sep 2026 00:00:00 GMT</pubDate><category>caching</category><category>negative-caching</category><category>redis</category><category>reliability</category><category>cache-penetration</category><category>security</category><author>hello@ankit-rana.com</author></item><item><title>Jitter is the cheapest reliability fix you are not using</title><link>https://ankit-rana.com/logs/49-jitter-synchronised-clients/</link><guid isPermaLink="true">https://ankit-rana.com/logs/49-jitter-synchronised-clients/</guid><description>Distributed systems synchronise themselves without being told to: every client that retries on a fixed interval, restarts after a deploy, or reconnects after a network blip ends up firing at the same moment as every other client. The resulting spike is a self-inflicted denial of service that no single component is responsible for. Adding randomness to any repeating interval breaks the alignment, and it is usually one line of code against a failure mode that otherwise requires capacity you never needed.</description><pubDate>Mon, 07 Sep 2026 00:00:00 GMT</pubDate><category>reliability</category><category>jitter</category><category>thundering-herd</category><category>distributed-systems</category><category>retries</category><category>resilience</category><author>hello@ankit-rana.com</author></item><item><title>Cache stampede: how one expired key takes down the database</title><link>https://ankit-rana.com/logs/48-cache-stampede-expired-key/</link><guid isPermaLink="true">https://ankit-rana.com/logs/48-cache-stampede-expired-key/</guid><description>A cache TTL is a scheduled simultaneous failure: every request being served from one key misses at the same instant and goes to the origin together. If the recompute takes two seconds, every request arriving during those two seconds also misses, so the pileup grows faster than it drains. Jitter on the TTL stops keys expiring in lockstep, and request coalescing so only one caller recomputes while the rest wait or serve stale is what stops a single expensive key from saturating the database.</description><pubDate>Sat, 05 Sep 2026 00:00:00 GMT</pubDate><category>caching</category><category>cache-stampede</category><category>redis</category><category>reliability</category><category>thundering-herd</category><category>distributed-systems</category><author>hello@ankit-rana.com</author></item><item><title>One round trip beats a thousand, and your batch API probably is not batching</title><link>https://ankit-rana.com/logs/47-batching-one-round-trip-beats-a-thousand/</link><guid isPermaLink="true">https://ankit-rana.com/logs/47-batching-one-round-trip-beats-a-thousand/</guid><description>For small writes the per-statement overhead dominates the actual work, so throughput is set by round trips rather than by the database. JDBC batching is the usual fix and it silently does nothing on the wire unless the driver is told to rewrite the statements, so addBatch can look correct while still issuing one round trip per row. Autocommit compounds it by turning every row into its own transaction and its own durability barrier, which is the difference between one fsync and a hundred thousand.</description><pubDate>Thu, 03 Sep 2026 00:00:00 GMT</pubDate><category>batching</category><category>jdbc</category><category>postgresql</category><category>mysql</category><category>database-performance</category><category>bulk-load</category><author>hello@ankit-rana.com</author></item><item><title>Your JSONB column became the schemaless disaster you migrated away from</title><link>https://ankit-rana.com/logs/46-jsonb-column-schemaless-disaster/</link><guid isPermaLink="true">https://ankit-rana.com/logs/46-jsonb-column-schemaless-disaster/</guid><description>JSONB is a good fit for genuinely open-ended data and a poor one for schema you did not want to commit to yet. Without a schema there is no NOT NULL, no type, no foreign key and no way to know which keys are load bearing, so every read becomes a parse and a cast that can fail at runtime. Large documents are stored out of line and compressed, which means reading one key can require fetching and decompressing the whole document, and updating one key rewrites all of it.</description><pubDate>Tue, 01 Sep 2026 00:00:00 GMT</pubDate><category>jsonb</category><category>postgresql</category><category>schema-design</category><category>data-modelling</category><category>toast</category><category>indexing</category><author>hello@ankit-rana.com</author></item><item><title>Foreign keys are not overhead, and the thing you measured was a missing index</title><link>https://ankit-rana.com/logs/45-foreign-keys-are-not-overhead/</link><guid isPermaLink="true">https://ankit-rana.com/logs/45-foreign-keys-are-not-overhead/</guid><description>A foreign key check is an index lookup against a primary key that is almost certainly already in cache, which is close to the cheapest thing a database does. The expensive case people measure is a parent delete with no index on the child&apos;s referencing column, which forces a full scan of the child table per deleted row, and that is a missing index rather than a cost of the constraint. Dropping the key does not remove the work, it moves the integrity guarantee into application code where nothing reports when it stops holding.</description><pubDate>Sun, 30 Aug 2026 00:00:00 GMT</pubDate><category>foreign-keys</category><category>referential-integrity</category><category>postgresql</category><category>schema-design</category><category>database-performance</category><category>indexing</category><author>hello@ankit-rana.com</author></item><item><title>The replica lag you do not measure is the one serving checkout</title><link>https://ankit-rana.com/logs/44-replica-lag-read-your-writes/</link><guid isPermaLink="true">https://ankit-rana.com/logs/44-replica-lag-read-your-writes/</guid><description>Byte lag between primary and replica reads zero on an idle primary even when replication is completely stuck, so the metric that looks healthiest is the one that hides the failure. Time lag measured from the last replayed transaction is the signal that stays honest. Adding a read replica silently removes read-your-writes, which means any flow that writes and then reads back needs either primary routing or an explicit wait for the replica to reach that write&apos;s log position.</description><pubDate>Fri, 28 Aug 2026 00:00:00 GMT</pubDate><category>replication</category><category>replica-lag</category><category>postgresql</category><category>consistency</category><category>read-replicas</category><category>observability</category><author>hello@ankit-rana.com</author></item><item><title>ADD COLUMN is not always free, and the lock queue is what takes you down</title><link>https://ankit-rana.com/logs/43-add-column-is-not-always-free/</link><guid isPermaLink="true">https://ankit-rana.com/logs/43-add-column-is-not-always-free/</guid><description>Modern PostgreSQL adds a column with a default as a metadata change, so the table is never rewritten and the migration itself is instant. The outage comes from lock acquisition instead: ALTER TABLE needs an ACCESS EXCLUSIVE lock, and while it waits behind one long-running query, every subsequent query queues behind the waiting ALTER because the lock queue is ordered. Setting lock_timeout to a couple of seconds and retrying converts that from an outage into a no-op.</description><pubDate>Wed, 26 Aug 2026 00:00:00 GMT</pubDate><category>migrations</category><category>postgresql</category><category>mysql</category><category>locking</category><category>schema-design</category><category>ddl</category><author>hello@ankit-rana.com</author></item><item><title>LSM compaction is a background job that will wake you at 3am</title><link>https://ankit-rana.com/logs/42-lsm-compaction-write-stalls/</link><guid isPermaLink="true">https://ankit-rana.com/logs/42-lsm-compaction-write-stalls/</guid><description>An LSM tree makes writes fast by never updating in place, which means every write is eventually rewritten several times by background compaction. When compaction falls behind, the engine deliberately throttles or stops incoming writes to avoid unbounded read amplification, so a background job becomes a foreground outage. The signal to watch is pending compaction bytes rather than disk utilisation, and the disk needs headroom for the largest compaction because merging requires space for input and output at the same time.</description><pubDate>Mon, 24 Aug 2026 00:00:00 GMT</pubDate><category>lsm-tree</category><category>compaction</category><category>rocksdb</category><category>cassandra</category><category>storage-engine</category><category>write-amplification</category><author>hello@ankit-rana.com</author></item><item><title>Connection pool sizing is a queueing theory problem, not a tuning knob</title><link>https://ankit-rana.com/logs/41-connection-pool-sizing-queueing-theory/</link><guid isPermaLink="true">https://ankit-rana.com/logs/41-connection-pool-sizing-queueing-theory/</guid><description>Pool size follows from Little&apos;s law: concurrency equals throughput multiplied by holding time, so 500 requests per second each holding a connection for 20ms needs ten connections rather than a round number someone picked. Past the point where the database can execute requests in parallel, adding connections moves the queue rather than removing it, and latency grows while throughput stays flat. The number that actually reaches the database is the pool size multiplied by the instance count, which is usually the number nobody has calculated.</description><pubDate>Sat, 22 Aug 2026 00:00:00 GMT</pubDate><category>connection-pool</category><category>queueing-theory</category><category>postgresql</category><category>hikaricp</category><category>database-performance</category><category>capacity-planning</category><author>hello@ankit-rana.com</author></item><item><title>Soft deletes are a schema decision that breaks every query you write afterwards</title><link>https://ankit-rana.com/logs/40-soft-deletes-schema-decision/</link><guid isPermaLink="true">https://ankit-rana.com/logs/40-soft-deletes-schema-decision/</guid><description>A deleted_at column turns every future query into a conditional one, and the cost is not the extra predicate. Unique constraints stop working because the deleted row still occupies the key, foreign keys start pointing at rows the application considers gone, and any query written by someone who does not know about the column silently returns deleted data. Soft delete is a data lifecycle decision, and treating it as a boolean column is what makes it expensive.</description><pubDate>Thu, 20 Aug 2026 00:00:00 GMT</pubDate><category>schema-design</category><category>soft-delete</category><category>postgresql</category><category>data-modelling</category><category>orm</category><category>database-design</category><author>hello@ankit-rana.com</author></item><item><title>Covering indexes: the cheap 10x that most schemas leave on the table</title><link>https://ankit-rana.com/logs/39-covering-indexes-index-only-scans/</link><guid isPermaLink="true">https://ankit-rana.com/logs/39-covering-indexes-index-only-scans/</guid><description>A normal index scan finds matching rows and then follows a pointer into the table for every one of them, which is a random read per row. A covering index stores the columns the query selects, so the engine answers entirely from the index and skips those reads. In PostgreSQL this only works when the visibility map marks the pages all-visible, so an unvacuumed table will report Heap Fetches in EXPLAIN and give back most of the gain. SELECT star defeats the technique completely.</description><pubDate>Tue, 18 Aug 2026 00:00:00 GMT</pubDate><category>indexing</category><category>covering-index</category><category>postgresql</category><category>innodb</category><category>database-performance</category><category>vacuum</category><author>hello@ankit-rana.com</author></item><item><title>Why your index is not being used, and why the planner is usually right</title><link>https://ankit-rana.com/logs/38-why-your-index-is-not-being-used/</link><guid isPermaLink="true">https://ankit-rana.com/logs/38-why-your-index-is-not-being-used/</guid><description>An unused index is almost never a planner bug. It is usually a predicate the planner cannot match to the index, such as a function or an implicit cast applied to the column, or a cardinality estimate that is wrong because statistics are stale. When the estimate is right and the planner still refuses, it is often correct: past a few percent of the table, random access through an index costs more than reading the table sequentially. The diagnostic that matters is the gap between estimated and actual rows in EXPLAIN ANALYZE.</description><pubDate>Sun, 16 Aug 2026 00:00:00 GMT</pubDate><category>indexing</category><category>query-planner</category><category>postgresql</category><category>mysql</category><category>database-performance</category><category>explain</category><author>hello@ankit-rana.com</author></item><item><title>fsync is the only thing between you and data loss, and it is slower than you think</title><link>https://ankit-rana.com/logs/37-fsync-durability-cost-group-commit/</link><guid isPermaLink="true">https://ankit-rana.com/logs/37-fsync-durability-cost-group-commit/</guid><description>A successful write() only copies your data into the kernel page cache, where a power loss destroys it. Only fsync pushes it to the device, and because fsync is a barrier rather than a write, a system that syncs once per commit is capped at roughly one divided by the fsync latency, no matter how fast the rest of the stack is. Group commit exists to amortise that barrier, and replication solves a different failure domain than fsync does, which is why acks=all does not mean the data is on any disk.</description><pubDate>Fri, 14 Aug 2026 00:00:00 GMT</pubDate><category>durability</category><category>fsync</category><category>databases</category><category>storage</category><category>postgresql</category><category>replication</category><author>hello@ankit-rana.com</author></item><item><title>Your ORM issued 400 queries and the p99 looked fine until it didn&apos;t</title><link>https://ankit-rana.com/logs/36-orm-n-plus-one-queries-hidden-latency/</link><guid isPermaLink="true">https://ankit-rana.com/logs/36-orm-n-plus-one-queries-hidden-latency/</guid><description>N+1 queries hide from monitoring because no individual query is slow. Four hundred queries at 0.4ms each never appear in the slow query log, never move p99 query latency, and still cost the request 300ms because the expense is the round trip rather than the execution. The metric that catches it is queries per request, and the only durable fix is asserting on that count in tests, since the code that causes it looks like a field access rather than I/O.</description><pubDate>Sun, 02 Aug 2026 00:00:00 GMT</pubDate><category>orm</category><category>n-plus-one</category><category>database-performance</category><category>hibernate</category><category>observability</category><category>latency</category><author>hello@ankit-rana.com</author></item><item><title>Decoding isolation levels: I built a toy DB to force dirty reads and phantom reads</title><link>https://ankit-rana.com/logs/35-isolation-levels-toy-db-dirty-phantom-reads/</link><guid isPermaLink="true">https://ankit-rana.com/logs/35-isolation-levels-toy-db-dirty-phantom-reads/</guid><description>The ANSI isolation table lists which anomalies each level permits, but it does not describe what your engine actually does: Postgres silently upgrades READ UNCOMMITTED to READ COMMITTED, and its REPEATABLE READ prevents phantoms that the standard allows. Phantom reads are a locking problem rather than a row problem, because you cannot lock a row that does not exist yet. Snapshot isolation stops every anomaly the table names and still permits write skew, which the table never mentions.</description><pubDate>Sun, 02 Aug 2026 00:00:00 GMT</pubDate><category>isolation-levels</category><category>databases</category><category>transactions</category><category>mvcc</category><category>postgresql</category><category>concurrency</category><author>hello@ankit-rana.com</author></item><item><title>Implementing LFU Cache in O(1) Time: A Hands-on Breakdown</title><link>https://ankit-rana.com/logs/34-lfu-cache-o1-implementation/</link><guid isPermaLink="true">https://ankit-rana.com/logs/34-lfu-cache-o1-implementation/</guid><description>LFU evicts the least frequently used key rather than the least recently used, which protects a hot key during a long-tail burst that would make LRU drop a bestseller. The naive implementation scans every key to find the minimum frequency, which is O(n) per eviction. The O(1) version inverts the index: a key-to-node map, a frequency-to-bucket map of doubly linked lists, and a minFreq pointer.</description><pubDate>Sun, 02 Aug 2026 00:00:00 GMT</pubDate><category>caching</category><category>lfu</category><category>algorithms</category><category>java</category><category>system-design</category><category>performance</category><author>hello@ankit-rana.com</author></item><item><title>Boredom is a Signal to Find a Harder Problem: When Your CRUD API Stops Teaching You</title><link>https://ankit-rana.com/logs/33-game-of-life-boredom-harder-problem/</link><guid isPermaLink="true">https://ankit-rana.com/logs/33-game-of-life-boredom-harder-problem/</guid><description>A todo CRUD API teaches real things, including validation, schema design, the N+1 query, index selection, pool sizing, and cache invalidation, and then it goes quiet. Boredom arriving right after you fix those once is not laziness; it is the signal that the problem stopped presenting decisions you have not already seen. The move is up the stack, to a failure domain with cross-service contracts, event ordering, and downstream calls that hang.</description><pubDate>Sun, 02 Aug 2026 00:00:00 GMT</pubDate><category>learning</category><category>backend</category><category>api</category><category>career</category><category>system-design</category><category>crud</category><author>hello@ankit-rana.com</author></item><item><title>I Rebuilt a Minimal BitTorrent Client in Go to Understand Peer-to-Peer Choking Algorithms</title><link>https://ankit-rana.com/logs/32-minimal-bittorrent-choking-algorithms-go/</link><guid isPermaLink="true">https://ankit-rana.com/logs/32-minimal-bittorrent-choking-algorithms-go/</guid><description>The BitTorrent spec explains choking in two paragraphs; implementing it in Go and watching every peer choke you within 60 seconds is what makes it stick. Choking is a bandwidth allocator running independently on every node, not a courtesy flag. Upload is the scarce resource on an asymmetric link, and each connection carries just two booleans, choked and interested, whose four combinations drive the entire fairness policy of the swarm.</description><pubDate>Sun, 02 Aug 2026 00:00:00 GMT</pubDate><category>bittorrent</category><category>p2p</category><category>golang</category><category>networking</category><category>system-design</category><category>distributed-systems</category><author>hello@ankit-rana.com</author></item><item><title>Promotions are Proactive: The 3P Framework for Pitching Your Next Level</title><link>https://ankit-rana.com/logs/31-promotions-proactive-3p-framework/</link><guid isPermaLink="true">https://ankit-rana.com/logs/31-promotions-proactive-3p-framework/</guid><description>Promotion committees do not promote effort, they promote scope, and scope has to be legible before the vote rather than explained after it fails. Strip the leveling-guide language and the question is blast radius: a mid-level engineer&apos;s bad call fails one deploy unit, a senior&apos;s saturates a pool at 2 AM across teams. The 3P framework makes that visible: Problem at org scale, Proof in system metrics, and a Proactive pitch.</description><pubDate>Sun, 02 Aug 2026 00:00:00 GMT</pubDate><category>career</category><category>system-design</category><category>backend</category><category>leadership</category><category>engineering</category><author>hello@ankit-rana.com</author></item><item><title>Glue Work is the New System Design: Why Alignment is the Premium Skill in the Age of AI</title><link>https://ankit-rana.com/logs/30-glue-work-new-system-design/</link><guid isPermaLink="true">https://ankit-rana.com/logs/30-glue-work-new-system-design/</guid><description>AI made the write path fast and left the coordination path untouched, so failures now live in the gaps between services: two event schema versions across two regions, three teams, and one assumption that someone else handled the migration window. Alignment work, deciding ownership boundaries, contract stability, and failure semantics before anyone opens an IDE, is system design, and it produces concrete network cost when skipped.</description><pubDate>Sun, 02 Aug 2026 00:00:00 GMT</pubDate><category>system-design</category><category>alignment</category><category>ai</category><category>distributed-systems</category><category>architecture</category><category>backend</category><author>hello@ankit-rana.com</author></item><item><title>The AI code review bottleneck: When writing code is 5x faster, but reviewing is 2x slower</title><link>https://ankit-rana.com/logs/29-ai-code-review-bottleneck/</link><guid isPermaLink="true">https://ankit-rana.com/logs/29-ai-code-review-bottleneck/</guid><description>AI made writing code a local, fast operation while review stayed cold and global: the reviewer must reload architecture, trace data flow, and mentally simulate hardware and network cost. A 400-line PR can take twice as long to review as it took to generate. Keep AI-written PRs under 100 lines, state endpoint count and expected latency in the description, and show the network boundary up front.</description><pubDate>Sun, 17 May 2026 00:00:00 GMT</pubDate><category>ai</category><category>code-review</category><category>system-design</category><category>cloud</category><category>productivity</category><author>hello@ankit-rana.com</author></item><item><title>Stop Writing RFCs Like Mystery Novels: Why the Best Design Docs Start with the Conclusion</title><link>https://ankit-rana.com/logs/28-stop-writing-rfcs-like-mystery-novels/</link><guid isPermaLink="true">https://ankit-rana.com/logs/28-stop-writing-rfcs-like-mystery-novels/</guid><description>Reviewers pipeline like CPUs. Hide the proposed architecture on page seven and they load context with no index to file it under, saturate working memory, then skim and rubber-stamp. Invert the structure: conclusion, architecture diagram, hardware and latency impact, then background and rejected alternatives last, so reviewers spend their attention interrogating your network boundaries instead of solving a literary puzzle.</description><pubDate>Sun, 17 May 2026 00:00:00 GMT</pubDate><category>rfc</category><category>architecture</category><category>documentation</category><category>communication</category><category>systems-design</category><author>hello@ankit-rana.com</author></item><item><title>Clock synchronization is a nightmare: Why Spanner uses TrueTime and the rest of us suffer</title><link>https://ankit-rana.com/logs/27-clock-synchronization-truetime/</link><guid isPermaLink="true">https://ankit-rana.com/logs/27-clock-synchronization-truetime/</guid><description>Server clocks come from quartz crystals that drift with temperature, and NTP cannot fully correct them because you cannot measure absolute time over a variable-latency network. Under last-write-wins, a node whose clock runs 10 ms fast can silently discard a newer write from a node that is behind: no error, normal logs, lost user data. Spanner solves it with GPS and atomic clocks, where TrueTime returns an uncertainty interval and the commit waits it out.</description><pubDate>Sun, 17 May 2026 00:00:00 GMT</pubDate><category>clocks</category><category>truetime</category><category>distributed-systems</category><category>spanner</category><category>consistency</category><author>hello@ankit-rana.com</author></item><item><title>Scaling a distributed cache: Why consistent hashing is mandatory</title><link>https://ankit-rana.com/logs/26-scaling-distributed-cache-consistent-hashing/</link><guid isPermaLink="true">https://ankit-rana.com/logs/26-scaling-distributed-cache-consistent-hashing/</guid><description>Sharding a cache with hash(key) modulo N means the denominator changes when a node dies, remapping nearly every key. Dropping from five nodes to four invalidates about 80 percent of the cache instantly and routes that miss storm straight at the primary database. Consistent hashing maps nodes and keys onto a fixed ring so only the dead node&apos;s keys move, and virtual nodes fix the uneven distribution a handful of physical nodes would otherwise produce.</description><pubDate>Sun, 17 May 2026 00:00:00 GMT</pubDate><category>caching</category><category>distributed-systems</category><category>consistent-hashing</category><category>redis</category><category>memcached</category><author>hello@ankit-rana.com</author></item><item><title>Instrumenting distributed messaging: The fallacy of exactly once delivery</title><link>https://ankit-rana.com/logs/25-instrumenting-distributed-messaging-exactly-once-delivery/</link><guid isPermaLink="true">https://ankit-rana.com/logs/25-instrumenting-distributed-messaging-exactly-once-delivery/</guid><description>There is no physical mechanism for exactly-once delivery over an unreliable network. If the sender does not receive an acknowledgement it can drop the message, giving at-most-once, or resend it, giving at-least-once. Those are the only two options. Kafka&apos;s exactly-once semantics buy the illusion with a transactional wrapper costing extra round trips and forced fsyncs, so configure brokers for at-least-once and make consumers fiercely idempotent instead.</description><pubDate>Sun, 17 May 2026 00:00:00 GMT</pubDate><category>kafka</category><category>distributed-systems</category><category>messaging</category><category>idempotency</category><category>architecture</category><author>hello@ankit-rana.com</author></item><item><title>Instrumenting AI: Multi-master replication and the split brain problem</title><link>https://ankit-rana.com/logs/24-instrumenting-ai-multi-master-replication-split-brain/</link><guid isPermaLink="true">https://ankit-rana.com/logs/24-instrumenting-ai-multi-master-replication-split-brain/</guid><description>In multi-master replication every node accepts writes, so when the network partitions both masters stay active and accept conflicting writes into isolated silos. On heal, automated conflict resolution usually falls back to last-write-wins, which blindly discards valid data. Raft and Paxos prevent this by requiring an odd node count and a strict majority: an isolated leader cannot reach quorum, so it steps down instead of forming a second brain.</description><pubDate>Sun, 17 May 2026 00:00:00 GMT</pubDate><category>ai</category><category>distributed-systems</category><category>database</category><category>consensus</category><category>raft</category><category>split-brain</category><author>hello@ankit-rana.com</author></item><item><title>Instrumenting AI Agents: Why the Apology Metric Is a First Class Reliability Signal</title><link>https://ankit-rana.com/logs/23-vector-db-vs-graphrag-global-sense-making/</link><guid isPermaLink="true">https://ankit-rana.com/logs/23-vector-db-vs-graphrag-global-sense-making/</guid><description>An AI agent that returns &quot;I apologize, but I cannot find that order&quot; ships an HTTP 200. Infrastructure dashboards call that healthy; the business calls it a failure. Tracking apology phrases as a first-class SLO surfaces context starvation, a stalled dependency, a timeout guard tripping, or silent payload truncation, none of which HTTP status codes and CPU graphs can see.</description><pubDate>Sat, 21 Mar 2026 00:00:00 GMT</pubDate><category>ai-agents</category><category>observability</category><category>rag</category><category>llmops</category><category>distributed-systems</category><category>reliability-engineering</category><author>hello@ankit-rana.com</author></item><item><title>The Expensive Cosplay of Local Models: True 3 AM Operational Cost of Hosting Llama-3</title><link>https://ankit-rana.com/logs/22-expensive-cosplay-local-llama-inference-tco/</link><guid isPermaLink="true">https://ankit-rana.com/logs/22-expensive-cosplay-local-llama-inference-tco/</guid><description>Llama-3 70B at 16-bit precision needs roughly 140 GB of VRAM just to sit idle, before the KV cache that every concurrent user requires. Inference is memory-bandwidth-bound rather than compute-bound: an A100&apos;s roughly 2000 GB/s against a 140 GB weight set caps single-stream generation near 14 tokens per second before batching. Add idle GPU time, batching-versus-latency trade-offs, and an ML infra engineer on pager duty, and that salary alone can erase the API savings.</description><pubDate>Sat, 21 Mar 2026 00:00:00 GMT</pubDate><category>llm</category><category>inference</category><category>gpu</category><category>vram</category><category>llama</category><category>operations</category><author>hello@ankit-rana.com</author></item><item><title>AI agents break connection pooling by holding the slot while they think</title><link>https://ankit-rana.com/logs/21-llms-connection-pooling-ai-agents/</link><guid isPermaLink="true">https://ankit-rana.com/logs/21-llms-connection-pooling-ai-agents/</guid><description>Connection pooling assumes an implicit contract that transactions stay microscopic, roughly 50 ms of database time per request. An agent that holds a pooled connection while waiting 3 to 5 seconds for LLM inference breaks that assumption: 100 concurrent agents can occupy every slot in a 100-connection pool while the database sits at 2 percent CPU. Fetch, release the connection immediately, then call the model asynchronously.</description><pubDate>Sat, 21 Mar 2026 00:00:00 GMT</pubDate><category>connection-pooling</category><category>postgresql</category><category>llm</category><category>agents</category><category>databases</category><category>performance</category><author>hello@ankit-rana.com</author></item><item><title>Thread-per-Core Architecture: Why Extra Threads Eventually Destroy Throughput</title><link>https://ankit-rana.com/logs/20-thread-per-core-architecture/</link><guid isPermaLink="true">https://ankit-rana.com/logs/20-thread-per-core-architecture/</guid><description>A machine with 16 cores runs 16 streams of execution regardless of how many threads the runtime creates. Past that point the scheduler timeslices, and each context switch costs roughly 1 to 2 microseconds of bookkeeping plus the far larger hidden cost of cache thrashing as each thread evicts the previous one&apos;s working set. Size worker pools to physical cores, pin them, and use non-blocking I/O so a thread never parks a core waiting on the network.</description><pubDate>Sat, 21 Mar 2026 00:00:00 GMT</pubDate><category>threading</category><category>context-switch</category><category>cpu-affinity</category><category>cache</category><category>performance</category><category>systems</category><author>hello@ankit-rana.com</author></item><item><title>Branch Prediction: Why an if Inside a Hot Loop Costs Milliseconds</title><link>https://ankit-rana.com/logs/19-branch-prediction-loop-unrolling/</link><guid isPermaLink="true">https://ankit-rana.com/logs/19-branch-prediction-loop-unrolling/</guid><description>CPUs pipeline instructions and speculate on branch outcomes. A misprediction discards the speculative work and flushes the pipeline at roughly 10 to 20 cycles. In a million-iteration loop with random branch outcomes, those flushes dominate runtime. Sorting the data so the branch resolves the same way for long runs, or removing the branch entirely with a mask or 0/1 multiplier, is what recovers the time.</description><pubDate>Sat, 21 Mar 2026 00:00:00 GMT</pubDate><category>branch-prediction</category><category>cpu</category><category>performance</category><category>pipelining</category><category>optimization</category><category>systems</category><author>hello@ankit-rana.com</author></item><item><title>CPU Caches and Spatial Locality: Why an Array is 3x Faster Than a Linked List for the Exact Same Big-O Complexity</title><link>https://ankit-rana.com/logs/18-cpu-caches-spatial-locality/</link><guid isPermaLink="true">https://ankit-rana.com/logs/18-cpu-caches-spatial-locality/</guid><description>Arrays and linked lists are both O(N) to traverse, but an array can run about three times faster because CPUs fetch 64-byte cache lines, not individual values. Sequential array access turns the next several iterations into cache hits at roughly 1 ns and lets the hardware prefetcher work ahead. Linked list nodes scattered across the heap defeat the prefetcher, so each dereference risks a 100 ns trip to RAM.</description><pubDate>Sat, 21 Mar 2026 00:00:00 GMT</pubDate><category>cpu-caches</category><category>spatial-locality</category><category>data-structures</category><category>performance</category><category>systems</category><category>memory-hierarchy</category><author>hello@ankit-rana.com</author></item><item><title>RSS vs VSZ in Virtual Memory: What the OOM Killer Actually Counts</title><link>https://ankit-rana.com/logs/17-virtual-memory-rss-vsz-oom-killer/</link><guid isPermaLink="true">https://ankit-rana.com/logs/17-virtual-memory-rss-vsz-oom-killer/</guid><description>malloc() does not hand you RAM, it reserves virtual address space. VSZ is a credit limit; RSS is cash. Physical pages are committed one page fault at a time as you actually touch memory, which is why the reservation is cheap and the memset is expensive. The OOM killer selects on RSS, so virtual promises are not what gets your process killed.</description><pubDate>Tue, 17 Mar 2026 00:00:00 GMT</pubDate><category>virtual-memory</category><category>linux</category><category>performance</category><category>observability</category><category>operating-systems</category><category>memory</category><author>hello@ankit-rana.com</author></item><item><title>Cuckoo Filters: Cache-Friendly Membership Checks With Deletions</title><link>https://ankit-rana.com/logs/16-cuckoo-filters-architecture/</link><guid isPermaLink="true">https://ankit-rana.com/logs/16-cuckoo-filters-architecture/</guid><description>A Cuckoo filter stores a one-to-two byte fingerprint in a hash table and finds it by checking exactly two buckets, the primary index and its XOR-derived alternate, instead of k random bit positions scattered across a large array. That spatial locality is the whole win on real CPUs. The trade-off is a hard edge: when the kick-out chain exceeds its limit, the insert fails outright.</description><pubDate>Tue, 17 Mar 2026 00:00:00 GMT</pubDate><category>cuckoo-filter</category><category>data-structures</category><category>cache</category><category>performance</category><category>probabilistic</category><category>systems</category><author>hello@ankit-rana.com</author></item><item><title>Bloom Filters vs Counting Bloom Filters: When Deletions Kill Performance</title><link>https://ankit-rana.com/logs/15-bloom-filters-deletable-bloom-filters/</link><guid isPermaLink="true">https://ankit-rana.com/logs/15-bloom-filters-deletable-bloom-filters/</guid><description>A standard Bloom filter is append-only because bits are shared between items, so clearing a bit for one item can create a false negative for another. Counting Bloom filters fix deletion by replacing each bit with a 4-bit or 8-bit counter, which multiplies the footprint four to eight times, pushes the structure out of L3, and turns each of the k lookups into a roughly 100 ns RAM hit instead of a 10 ns cache hit.</description><pubDate>Tue, 17 Mar 2026 00:00:00 GMT</pubDate><category>bloom-filter</category><category>cache</category><category>performance</category><category>data-structures</category><category>distributed-systems</category><category>systems</category><author>hello@ankit-rana.com</author></item><item><title>Pagination at Scale: Why OFFSET and SKIP Will Eventually Break Your API</title><link>https://ankit-rana.com/logs/14-pagination-offset-vs-cursor/</link><guid isPermaLink="true">https://ankit-rana.com/logs/14-pagination-offset-vs-cursor/</guid><description>OFFSET does not seek. The engine fetches offset plus limit rows, sorts them, and discards the first N, so cost grows linearly with page depth. Cursor pagination passes the last seen key instead of a page number, letting the B+ tree seek in logarithmic time and read a fixed number of rows, which keeps latency flat at any depth. The price is losing absolute page numbers.</description><pubDate>Tue, 17 Mar 2026 00:00:00 GMT</pubDate><category>pagination</category><category>api-design</category><category>database-performance</category><category>scalability</category><category>sql</category><category>b-tree</category><author>hello@ankit-rana.com</author></item><item><title>The RUM Conjecture: You Cannot Optimize Reads, Updates, and Memory at Once</title><link>https://ankit-rana.com/logs/13-rum-conjecture-database-tradeoffs/</link><guid isPermaLink="true">https://ankit-rana.com/logs/13-rum-conjecture-database-tradeoffs/</guid><description>You can strictly optimise at most two of read overhead, update overhead, and memory overhead; the third will be expensive. B-Trees optimise reads and memory and pay on writes. LSM-Trees optimise writes and memory and pay on reads. Hash indexes optimise reads and writes and pay in RAM. The useful question is not whether a database is good but which corner it optimises and what you are willing to pay for the other two.</description><pubDate>Tue, 17 Mar 2026 00:00:00 GMT</pubDate><category>databases</category><category>indexing</category><category>performance</category><category>system-design</category><category>storage-engine</category><author>hello@ankit-rana.com</author></item><item><title>Why UUID Primary Keys Quietly Destroy Database Performance</title><link>https://ankit-rana.com/logs/12-uuids-primary-keys-performance/</link><guid isPermaLink="true">https://ankit-rana.com/logs/12-uuids-primary-keys-performance/</guid><description>The problem with UUIDv4 primary keys is not uniqueness, it is that random keys fight the storage engine&apos;s physical layout. In a clustered index the primary key is the table, so random inserts land mid-page, trigger page splits, leave pages half-full, and can inflate a 50 GB dataset to roughly 100 GB while wasting buffer pool on empty space. Use UUIDv7 or ULID, or keep an auto-increment clustered key with the UUID in a unique secondary index.</description><pubDate>Mon, 16 Mar 2026 00:00:00 GMT</pubDate><category>uuid</category><category>database-performance</category><category>innodb</category><category>b-tree</category><category>system-design</category><category>mysql</category><author>hello@ankit-rana.com</author></item><item><title>Designing Resilient APIs: Failure-Handling Patterns for Distributed Systems</title><link>https://ankit-rana.com/logs/11-resilient-api-design-patterns/</link><guid isPermaLink="true">https://ankit-rana.com/logs/11-resilient-api-design-patterns/</guid><description>Resilience is failing in controlled ways rather than not failing. Validate and fail fast at the boundary, degrade gracefully by serving cached or reduced responses, require an idempotency key for side-effecting operations, and bound retries with exponential backoff, jitter, an attempt cap, and a total time budget. Unbounded retries amplify outages.</description><pubDate>Mon, 16 Mar 2026 00:00:00 GMT</pubDate><category>resilience</category><category>api-design</category><category>distributed-systems</category><category>fault-tolerance</category><category>observability</category><category>reliability</category><author>hello@ankit-rana.com</author></item><item><title>Microservices Deep Dive: Architecting for Scalability and Resilience</title><link>https://ankit-rana.com/logs/10-microservices-architecture/</link><guid isPermaLink="true">https://ankit-rana.com/logs/10-microservices-architecture/</guid><description>Microservices trade deployment simplicity for independent scaling, fault isolation, and team autonomy, and they only pay off once domain complexity and scale justify the operational cost. Align services to bounded contexts, give each its own data store, and extract one domain at a time rather than splitting by technical layer.</description><pubDate>Mon, 16 Mar 2026 00:00:00 GMT</pubDate><category>microservices</category><category>system-design</category><category>distributed-systems</category><category>devops</category><category>architecture</category><category>cloud</category><author>hello@ankit-rana.com</author></item><item><title>Consistency Models in Azure Cosmos DB: From Strong to Eventual</title><link>https://ankit-rana.com/logs/09-cosmosdb-consistency-models/</link><guid isPermaLink="true">https://ankit-rana.com/logs/09-cosmosdb-consistency-models/</guid><description>Cosmos DB exposes the PACELC trade-off as five explicit levels instead of forcing a strong-or-eventual choice. Strong gives linearizable reads at the cost of write latency and availability. Session, the practical default for user-facing apps, gives read-your-writes within a session via per-partition session tokens while staying highly available.</description><pubDate>Mon, 16 Mar 2026 00:00:00 GMT</pubDate><category>cosmosdb</category><category>consistency</category><category>distributed-systems</category><category>pacelc</category><category>database-design</category><category>cloud-architecture</category><author>hello@ankit-rana.com</author></item><item><title>Zero Trust Architecture: From Perimeter Walls to &quot;Never Trust, Always Verify&quot;</title><link>https://ankit-rana.com/logs/08-zero-trust-architecture/</link><guid isPermaLink="true">https://ankit-rana.com/logs/08-zero-trust-architecture/</guid><description>Zero Trust starts from the assumption that the network is already compromised, so every request is authenticated, authorised, and encrypted regardless of where it originates. It rests on explicit verification, least privilege, micro-segmentation, continuous monitoring, and encryption everywhere. It is an architectural direction, not a product you buy.</description><pubDate>Mon, 16 Mar 2026 00:00:00 GMT</pubDate><category>zero-trust</category><category>security-architecture</category><category>identity-and-access</category><category>network-security</category><category>observability</category><category>cloud</category><author>hello@ankit-rana.com</author></item><item><title>Mastering Event-Driven Architecture with Apache Kafka</title><link>https://ankit-rana.com/logs/07-kafka-event-driven-architecture/</link><guid isPermaLink="true">https://ankit-rana.com/logs/07-kafka-event-driven-architecture/</guid><description>Event-driven architecture replaces synchronous point-to-point calls with immutable events on a durable log, so producers and consumers scale and fail independently. Kafka provides that log: topics sharded into ordered append-only partitions, replicated across brokers, with consumer groups sharing partitions to scale read throughput.</description><pubDate>Mon, 16 Mar 2026 00:00:00 GMT</pubDate><category>event-driven-architecture</category><category>apache-kafka</category><category>stream-processing</category><category>microservices</category><category>distributed-systems</category><author>hello@ankit-rana.com</author></item><item><title>Transitioning from REST to gRPC: System Design and Tradeoffs</title><link>https://ankit-rana.com/logs/06-grpc-vs-rest/</link><guid isPermaLink="true">https://ankit-rana.com/logs/06-grpc-vs-rest/</guid><description>gRPC defines services in a .proto file, compiles them into typed client and server code, and transports binary protobuf over HTTP/2. Choose it for internal service-to-service calls that need low latency, schema-first contracts, or streaming, and keep REST with JSON at the edge where browsers and external consumers live.</description><pubDate>Mon, 16 Mar 2026 00:00:00 GMT</pubDate><category>grpc</category><category>rest</category><category>api-design</category><category>microservices</category><category>protobuf</category><category>system-design</category><author>hello@ankit-rana.com</author></item><item><title>HTTP/2 System Design: How It Fixes HTTP/1.1</title><link>https://ankit-rana.com/logs/05-http2-system-design/</link><guid isPermaLink="true">https://ankit-rana.com/logs/05-http2-system-design/</guid><description>HTTP/1.1 hit concurrency limits that forced hacks like domain sharding and sprite sheets. HTTP/2 keeps HTTP semantics but replaces the wire format with binary framing, multiplexed streams over a single TCP connection, HPACK header compression, server push, and stream prioritisation, which removes most head-of-line blocking at the HTTP layer.</description><pubDate>Mon, 16 Mar 2026 00:00:00 GMT</pubDate><category>http2</category><category>http1-1</category><category>web-performance</category><category>networking</category><category>protocols</category><category>tls</category><author>hello@ankit-rana.com</author></item><item><title>Shazam finds songs by voting on time offsets, not by comparing audio</title><link>https://ankit-rana.com/logs/04-shazam-music-recognition/</link><guid isPermaLink="true">https://ankit-rana.com/logs/04-shazam-music-recognition/</guid><description>Shazam does not compare audio. It reduces each track to spectrogram peaks, pairs nearby peaks into ~32-bit hashes, and looks those up in an inverted index. A match is declared when many hashes from the sample agree on a single time offset into one track. The offset histogram is the whole trick: noise scatters offsets randomly, a real match stacks them into a spike.</description><pubDate>Mon, 16 Mar 2026 00:00:00 GMT</pubDate><category>music-recognition</category><category>audio-fingerprinting</category><category>system-design</category><category>algorithms</category><category>indexing</category><author>hello@ankit-rana.com</author></item><item><title>System Migration: Minimize Downtime, Maximize Efficiency</title><link>https://ankit-rana.com/logs/03-system-migration/</link><guid isPermaLink="true">https://ankit-rana.com/logs/03-system-migration/</guid><description>Migrate behind a bridge layer that routes all client traffic and supports three modes: old-only, dual, and new-only. Run dual mode to compare responses without user impact, keep a back-sync pipeline so the old system stays current for rollback, and shift traffic in stages while watching metrics at each step.</description><pubDate>Mon, 16 Mar 2026 00:00:00 GMT</pubDate><category>system-migration</category><category>bridge-layer</category><category>traffic-leakage</category><category>observability</category><category>data-pipelines</category><category>reliability</category><author>hello@ankit-rana.com</author></item><item><title>System Design: Principles for Maintainability, Scalability, and Reliability</title><link>https://ankit-rana.com/logs/02-system-design-principles/</link><guid isPermaLink="true">https://ankit-rana.com/logs/02-system-design-principles/</guid><description>Reliability, scalability, and maintainability rest on one distinction: a fault is a component-level anomaly, a failure is the system no longer delivering its service. Design to contain faults so they never become failures, and stay precise that latency is waiting time while response time is the full client-visible number.</description><pubDate>Mon, 16 Mar 2026 00:00:00 GMT</pubDate><category>system-design</category><category>reliability</category><category>scalability</category><category>maintainability</category><category>data-systems</category><category>architecture</category><author>hello@ankit-rana.com</author></item><item><title>Your week is a queueing system, and you are running it at 100% utilization</title><link>https://ankit-rana.com/logs/01-time-management-software-engineering/</link><guid isPermaLink="true">https://ankit-rana.com/logs/01-time-management-software-engineering/</guid><description>An engineer&apos;s week behaves like a queueing system: book yourself at 100% utilization and the wait time for anything new goes vertical, exactly as it does for a server. The fixes are the ones we already use in systems: keep headroom, coalesce interrupts instead of taking them one by one, cap work in progress because Little&apos;s law applies to you, and stop letting urgent-but-small tasks hold the lock while important work starves.</description><pubDate>Sun, 15 Mar 2026 00:00:00 GMT</pubDate><category>time-management</category><category>productivity</category><category>queueing-theory</category><category>focus</category><category>software-engineering</category><author>hello@ankit-rana.com</author></item></channel></rss>