Design S3 (Object Storage) - System Design

An object store looks like a hash map with two methods: PUT(key, bytes) and GET(key) -> bytes. That framing is exactly why it is hard. A hash map lives in one process’s memory; this one holds trillions of objects and exabytes of bytes across hundreds of thousands of disks in dozens of datacenters, and promises that once a PUT returns 200 OK the bytes will still be there in a thousand years - eleven nines of durability, meaning if you store ten million objects you expect to lose one every ten thousand years. The naive version is a directory on a big disk behind an HTTP server, and it dies the first time a disk fails, the first time one key gets a billion reads, and the first time the index of keys outgrows a single machine. Everything real about S3 is the machinery that keeps a dumb key-value interface alive when the disk will fail, the datacenter will burn, and the keyspace will not fit anywhere. ...

31 min

ClickHouse Is Not Just for Big Data - When to Replace PostgreSQL for Analytics

Most teams do not choose ClickHouse. They run away from PostgreSQL until it stops working, panic, and reach for whatever managed analytics service their cloud vendor is advertising that quarter. That is an expensive way to make a decision. Here is the part nobody tells you: ClickHouse is not a “big data” tool. You do not need a cluster, a data engineering team, or a petabyte of logs. A single machine with 16 cores and a couple hundred gigabytes of disk will answer aggregation queries over a few billion rows in milliseconds. The same query on Postgres takes seconds, saturates a core, and evicts your OLTP working set from cache while it runs. ...

10 min

Design Apple Find My / Google Find My Device - System Design

Find My looks like a location-tracking problem and it is, but the interesting half is a paradox: you must locate a device that is offline - powered-off phone, an AirTag with no radio but Bluetooth, a laptop in a stranger’s bag - using a network of a billion other people’s devices, while guaranteeing that the company running the network can never see where any device is, and that the strangers doing the finding can never be identified or turned into a tracking tool. An online device reporting its own GPS is the easy case. The hard case is: a lost AirTag has no GPS, no cellular, no wifi - it can only whisper over Bluetooth. Someone else’s iPhone walks past, hears the whisper, knows its own location, and has to get that location back to the owner - without the passer-by learning what they found, without Apple learning who found what or where, and without a stalker being able to slip an AirTag into your bag and watch you on a map. ...

30 min

Design Snapchat / Instagram Stories - System Design

Stories look like a photo feed with a countdown, and people design them like one. That is the trap. A story is not a permanent post you happen to hide after a day - the 24-hour lifetime, the ordering, and the read patterns are all fundamentally different from a feed, and they push the design in directions Instagram’s main feed never has to go. Three things make Stories their own animal. First, everything is ephemeral: a story exists for exactly 24 hours and then it is gone, so the entire data model is built around a TTL and auto-expiry rather than durable storage. Second, ordering is not ranked, it is per-viewer state: the story tray at the top of the app is sorted by “who has stuff I have not seen yet,” which means the sort key is a function of me, the viewer, not a global score. Third, the read amplification is brutal: 5B story views a day, most of which are cheap “has anything new happened” tray checks that must return in tens of milliseconds. The media bytes are the easy part (that is a solved CDN problem, same as any photo/video service); the hard part is the seen/unseen state and the tray, so that is where I spend the depth. ...

28 min

Design Voice Assistant (Alexa) - System Design

You say “Alexa, what’s the weather in Bangalore tomorrow?” and about eight hundred milliseconds later a speaker on your kitchen counter says “Tomorrow in Bangalore it’ll be partly cloudy, with a high of 31 degrees.” In that under-a-second window the device woke up on the word “Alexa,” streamed your voice to a data centre, turned the audio into text, figured out that this is a weather question about a specific city and a specific day, called a weather service, turned the answer back into a sentence, synthesized that sentence into speech, and streamed the audio back to the speaker. Any one of those steps done slowly blows the illusion that you are talking to something that understands you. ...

30 min

You Can Claim HRA and Home Loan Interest Together: The Dual-City Tax Hack Most Miss

Almost everyone who owns a home loan property believes the HRA in their salary slip is now dead money. “I own a flat, so I can’t claim HRA” is one of the most expensive myths in Indian salaried tax planning. It is also flatly wrong. The Income Tax Act never links your HRA exemption to whether you own property somewhere. It links it to one thing only: whether you actually pay rent for the place you live in. Own a flat in Lucknow, rent one in Pune because that is where your job is, and you get both breaks in the same year. HRA on the Pune rent under section 10(13A), and home loan interest on the Lucknow flat under section 24(b). Two separate provisions, two separate heads of income, zero conflict. ...

11 min

Design a Spam / Fraud Detection Pipeline - System Design

Everyone thinks fraud detection is a set of if statements. “Block logins from Nigeria, flag transactions over $5000, rate-limit signups per IP, done.” Then the interviewer piles on the constraints that make it a real system: it is not a rulebook run once a night, it is a synchronous gate in front of every login, every payment, every signup, and every message send - so it must return a verdict in the tens of milliseconds before the user’s request proceeds; it is not thousands of events, it is billions of events per day; the signal it needs (this card was used in three countries in the last hour, this device fingerprint has 40 accounts, this IP just failed 200 logins) lives in history, so scoring means joining live events against a huge, constantly-updating memory; and the fraudsters adapt, so the model that caught them yesterday is stale today, which is why the model has to be retrained daily on fresh labels and hot-swapped without downtime. ...

34 min

Design Gmail (Email Service Backend) - System Design

Email looks like a solved problem. It is 40 years old, the protocol fits on a napkin, and every framework ships a send_mail() in three lines. So when the interviewer says “design Gmail,” the temptation is to draw a box called “mail server” and move on. That box is where the interview goes to die. The real problem is that email is not one system. It is at least four, wired together and each hard at a different scale. You have to receive mail from the entire internet over SMTP, a protocol you do not control and cannot rate-limit at the source, from senders who range from your own users to botnets. You have to store it durably forever, because people treat their inbox as a filing cabinet and never delete anything. You have to make every user’s mailbox fully searchable in milliseconds, which at billions of messages means an inverted index the size of a small country. And you have to filter spam and malware on the way in, at line rate, before it ever touches a mailbox. 1.8B users, billions of messages a day, attachments up to 25MB, and a storage bill that only grows. Let me build it properly, one hard part at a time. ...

27 min

Design Truecaller (Crowdsourced Caller ID) - System Design

An unknown number rings your phone and, before you pick up, the screen says “Rajesh Kumar - Reported as spam 240 times.” You have never saved that number. Your phone has never seen it. So where did the name come from? The trick behind Truecaller is deceptively simple to state and genuinely hard to build: millions of other people have that number saved in their address book under some name, and Truecaller has quietly aggregated all of those private address books into one giant global reverse phone directory. You uploaded your contacts once; so did 350M other people; the union of everyone’s contacts is the product. ...

29 min

NSC vs KVP vs Post Office Time Deposit: Which Wins After Tax for a 30 Percent Bracket Investor

Here is the line that gets repeated at every post office counter: “KVP doubles your money, NSC gives you tax benefit, TD gives you flexibility - pick what suits you.” It sounds balanced. It is wrong for one specific person, and that person is you if you sit in the 30 percent tax bracket. For you, the headline rate barely matters. What matters is a single boring clause in Section 80C, and it separates these three instruments by roughly 1.6 percentage points of post-tax return every year, which is a chasm at these rates. ...

10 min

Tool-Calling Patterns That Actually Work in Production AI Agents

Most agent tutorials show the same thing: define one tool, let the model call it once, print the result, declare victory. That is not an agent. That is a function call with extra steps. The moment you put it in front of real traffic, the model calls three tools when it should have called one, invents a parameter that does not exist, retries a failed payment four times, and hangs for ninety seconds because a downstream API timed out and nobody told the model. ...

11 min

CI/CD for AI Applications Is Different - What Changes When Your Logic Lives in a Prompt

A git commit does not capture what your AI application actually does. You can freeze every line of Python, tag the release, and deploy the exact same container to two regions - and get materially different behavior because one region is pinned to a model snapshot that got deprecated and silently rerouted, and the other is reading a retrieval index that was rebuilt yesterday. Your test suite passed. Your code did not change. Your product got worse anyway. ...

12 min

Design a CDN (Content Delivery Network) - System Design

A CDN sounds like a caching proxy you already know how to build: put an Nginx in front of the origin, set a TTL, done. That intuition survives about one slide. A real CDN is a globally distributed system whose entire job is to put a copy of someone else’s bytes physically close to every human on earth, keep those copies fresh (or provably safe to serve stale), route each request to the right box in the right city without the client knowing any of the plumbing exists, and do all of this while sustaining billions of requests per second and ~100 Tbps of egress without ever letting the origins behind it feel the load. The interesting part is not “cache a file.” It is: thousands of points of presence spread across the planet, each independently caching, each pulling from a shared origin through a tiered hierarchy that collapses cache-fill traffic, all fronted by a routing layer that steers a viewer in Lagos to a box in Lagos, plus an invalidation system that can purge a stale object from every edge on earth in seconds. Let me build it properly. ...

33 min

Design a DNS Resolver System - System Design

A DNS resolver sounds like a lookup table: a client asks “what is the IP for example.com,” you return an A record, done. That intuition survives about one query. A real recursive resolver is a globally distributed system whose whole job is to turn a name into an address by walking a delegation tree of servers it does not own, cache the answer for exactly as long as the record’s TTL allows and not one second more, hand back the geographically right address so a user in Mumbai gets the Mumbai edge of the site they asked for, and do all of this in under 50ms at p99 while sustaining trillions of queries per day. The interesting part is not “look up a name.” It is: thousands of resolver nodes spread across the planet behind one anycast IP, each running a recursive engine that chases NS delegations from the root down while a multi-tier cache absorbs 90%+ of traffic, each honoring per-record TTLs so answers are fresh without hammering authoritative servers, and each returning ECS-aware answers so the address you get is close to you - all while a single slow or dead authoritative server upstream must never stall the box. Let me build it properly. ...

32 min

Design Jira (Bug / Issue Tracking) - System Design

Jira looks like a CRUD app with extra menus. Create a ticket, assign it, drag it across a board, close it. Say that in an interview and the hard parts arrive in the first follow-up. “Every org defines its own fields - one team has a Story Points number, another has a Severity dropdown and a Customer picker - and users search across all of them with JQL like project = PAY AND status IN (Open, Reopened) AND assignee = currentUser() AND "Story Points" > 5 ORDER BY priority DESC.” “A ticket cannot jump from Open straight to Closed if the workflow says it must pass through In Review first, and the transition may run validators and fire a post-function.” “There are 100K organizations and 1B tickets total, most orgs tiny and a few enormous, and complex queries are the common case, not the exception.” ...

28 min

NPS Is Not as Illiquid as You Think: The 25 Percent Partial Withdrawal Rule

The single most common objection to NPS is one word: illiquid. “Your money is locked till 60.” That line kills the product for most people before they read a single rule. It is also mostly wrong, and the people repeating it have usually never opened the withdrawal section of the PFRDA rulebook. Here is what almost nobody tells you: after just three years in NPS, you can pull out up to 25% of your own contributions, tax-free, for a specific list of life events - a child’s education, a child’s marriage, buying or building a house, or treating a serious illness. Three years. Not sixty. That is faster access than PPF, which makes you wait until the seventh year. ...

9 min

Design Coursera / Online Learning Platform - System Design

An online learning platform looks like “YouTube with a login” for about a minute, and then the differences bite. Video is only one plane of it: the actual product is a learner working through a structured course - watching a lecture, then taking a quiz that gets graded instantly, then submitting a programming assignment that runs against a test harness, then having every one of those actions bump a progress record that decides whether they have earned a certificate. The video is stateless and cacheable; everything wrapped around it is stateful, per-learner, write-heavy, and correctness-sensitive in a way a video counter never is. A wrong view count is a rounding error nobody notices. A wrong grade or a certificate issued to someone who did not finish is a support ticket and a trust problem. ...

31 min

Design Multiplayer Game Matchmaking - System Design

Everyone thinks matchmaking is “put waiting players in a list, grab the first ten, start a game.” That works in a hackathon demo with fifty players. Then the interviewer piles on the real constraints: the ten players you grabbed have to be close in skill or the match is a stomp and everyone rage-quits; they have to be in the same region or the connection lags to death; the ping between them has to be low even within a region; nobody should wait more than about thirty seconds staring at a “finding match” spinner; and the two teams you form out of those ten have to be balanced against each other, not just individually skilled. And you are doing this for 10 million people queued at the same time, continuously. ...

28 min

Design Online Auction (eBay) - System Design

An online auction looks like “a listing with a current price that goes up,” and if you model it that way you will lose the interview in the first five minutes. The trap is that an auction is not a CRUD row you update - it is a serialization problem wearing a shopping-site costume. The moment two people bid on the same item at the same instant, you have a race: which bid is higher, which one wins, what is the new current price, and did the loser get told they were outbid. Multiply that by a “hot” item - a rare sneaker drop, a graded Charizard, a concert ticket - where thousands of people pile in during the last ten seconds, and the naive “read price, compare, write price” pattern shreds itself into lost updates and double-wins. Then remember there are 100M active listings and each one has a hard deadline, and every one of those deadlines must fire close to on time, or the auction that “ended at 9:00:00” is still taking bids at 9:00:04 and someone is furious. ...

31 min

Sovereign Gold Bond: The Tax Math of Selling Early Versus Waiting 8 Years

Most people think the SGB lock-in is the problem: eight years with your money stuck. That framing is backwards. The eight-year clock is not a cage, it is a coupon. The last three years of an SGB’s life are the only years in Indian gold where your entire capital gain is legally tax-free. Sell on the NSE in year five and you do not just exit early, you hand back the single best tax break the government still offers a retail investor. This post puts a rupee number on exactly what that costs. ...

9 min