Nifty 50 plus Nifty Next 50: You Are Not as Diversified as You Think

There is a very common two-fund starter portfolio doing the rounds on Indian finance forums: put money into a Nifty 50 index fund and a Nifty Next 50 index fund, usually 50-50, and feel diversified because you now “own 100 stocks.” The pitch sounds airtight. Fifty large caps plus the next fifty, no stock repeated, double the names. Here is the uncomfortable part. Those two funds together are, almost to the constituent, the Nifty 100 index. You have not built a clever diversified portfolio. You have rebuilt an off-the-shelf index by hand, paid for the privilege of running two funds, and in the 50-50 version you have quietly made a large active bet without realising it. This post works the actual numbers: how much weight the second fund really carries, why “100 stocks” is a diversification illusion, where the genuine diversification actually comes from, and when one fund does the job better. ...

10 min

Accidental Death Rider vs Standalone PA Policy: What Your Term Insurer Does Not Tell You

When you buy a term plan online, the last screen before payment offers you an “Accidental Death Benefit” rider. Rs. 50 lakh of extra cover for about Rs. 1,800 a year. It feels like a no-brainer, so most people tick the box. Here is the uncomfortable part. That rider covers the one accidental outcome you are already insured against, and skips the one that will actually ruin you financially. If you die in an accident, your family gets a cheque either way. If you survive the accident but can never work again, the rider pays nothing. ...

9 min

Design Ads Management & Display in Social Feed - System Design

Everyone models an ad server as a lookup: “the user opens the feed, we fetch an ad, we show it, done.” The interviewer lets that sit for a moment and then piles on the constraints that make it a real system. There are not ten ads to choose from, there are millions of live campaigns; the best ad for this user has to be chosen from that pool in under 50 milliseconds while the feed is already rendering; advertisers set budgets and if you overspend theirs you eat the cost, if you underspend it you lose their trust and their business; the spend has to be paced evenly across the day, not blown in the first hour; a large fraction of clicks are bots and you must not charge advertisers for them; and all of this runs at 100 billion impressions a day. An ad server is not a lookup. It is a real-time per-impression auction over a targeted candidate set, constrained by budgets and paced over time, with a fraud filter in the loop - and the ad shown is just its output. ...

31 min

Design Distributed Document Editor (Notion / Wikipedia) - System Design

Almost everyone reaches for Google Docs the moment they hear “document editor,” and almost everyone is answering the wrong question. Google Docs is a real-time collaboration problem: two people typing into the same sentence at the same millisecond, operational transforms, CRDTs, convergence. That is a specific and hard sub-problem, and it is not what Notion or Wikipedia are. Notion and Wikipedia are async document systems: you open a page, you edit it, you save it. Someone else might edit it an hour later, or a minute later, but the design does not live or die on sub-200ms convergence of concurrent keystrokes. It lives or dies on three other things - how you store a document made of structured blocks, how you keep a full version history without exploding storage, and how you search across tens of millions of documents fast. ...

26 min

Design Toll Collection (FASTag) - System Design

A car drives through a toll lane at 30 km/h, an overhead antenna reads its RFID tag, and by the time the nose of the car reaches the barrier the boom has lifted and a rupee amount has left a prepaid wallet. That is the whole product in one sentence, and the interviewer will let you feel good about it for about a minute before pointing at the parts that are actually hard. The barrier has to decide in under half a second while the wallet that funds the toll lives in a different bank’s ledger a network hop away. The same tag gets read three times because the car crawled under the antenna. The plaza in a valley loses connectivity for twenty minutes and cars keep coming. And the one thing that absolutely cannot go wrong - the number in the wallet - has to stay exactly right across 100 million debits a day even though two lanes, a retry, and a settlement job might all touch the same balance at once. ...

27 min

Idempotency Keys Are How You Make Retries Safe in Distributed Systems

The network will lie to you. A client sends POST /charges, the server charges the card, and then the response is lost to a dropped connection, a load balancer timeout, or a client that gave up at 30 seconds. The client has no idea whether the charge happened. So it retries. Now you have charged the customer twice, and no amount of careful transaction code on the server prevented it, because the duplicate came from outside your database. ...

12 min

Database Connection Pooling Is the Performance Win Most Teams Skip

Most teams reach for a bigger database instance long before they reach for a connection pooler. That is backwards. A surprising amount of “Postgres is slow under load” is not Postgres being slow. It is Postgres drowning in connections, each one costing 5 to 10 MB of memory and a backend process, while your application opens a fresh connection for every request and throws it away a few milliseconds later. ...

13 min

Design Flash Sale (6M Free Burgers in 1 Hour) - System Design

“Design a flash sale” sounds like a shopping-cart problem until you write down the actual numbers: Burger King runs a promo, the app has 50 million people who will all tap the same button in the same minute, and there are exactly 6,000,000 free-burger coupons to give away. Not 6,000,001. Not 5,999,998. Exactly six million, then the button says “sold out” and everyone else goes home. The interviewer is not testing whether you can serve a page. They are testing whether you can run a single shared counter down from 6M to 0 under a 50-million-user stampede without ever letting it go negative, without handing one person two coupons, and without the whole app falling over. ...

28 min

Design IRCTC Train Booking (Tatkal) - System Design

“Book a train ticket” sounds like inserting a row. Then you look at Tatkal. At 10:00:00 sharp, a few days’ worth of demand for a scarce quota lands in a single second. Two or three million people press “Book” against a train that has maybe eighty Tatkal seats. The seats sell out in ten to twenty seconds. Every one of those millions must get a truthful answer - a confirmed seat with a berth number, a waitlist position, or a clean rejection - and no seat may ever be sold twice, because a double-booked berth is two paying passengers standing in the same coach at midnight. This is not a CRUD service with a form in front. It is a scarce-inventory contention problem where the read load is enormous, the write load is fierce and concentrated, and correctness on the write path is absolute. ...

35 min

Design MakeMyTrip Travel Search - System Design

“Design MakeMyTrip” sounds like a shopping app: a user types two cities and a date, a list of flights comes back, they pick one and pay. The interviewer lets that run for a minute, then asks the question the toy version cannot answer. A user in Bangalore types “BLR to DEL, 12 August, 1 adult” and expects, in under two seconds, a ranked list of every way to make that trip - direct flights and connections - across 50-plus airlines, each with a real bookable price, layover, and total duration. MakeMyTrip does not own a single seat. The inventory lives behind dozens of airline APIs and Global Distribution Systems, each slow, rate-limited, priced per query, and disagreeing about what a fare costs from one second to the next. ...

30 min

Senior Citizen Savings Scheme vs FD vs RBI Floating Rate Bond: Post-Tax at 60

You retired last month with ₹40 lakh you want to keep safe and income-producing. Every relative has an opinion: “SCSS, 8.2%, government-backed, done.” Someone else swears by the RBI Floating Rate Bond. Your banker is quietly pushing a senior-citizen FD. The lazy answer is “put it all in SCSS, it pays the most.” You cannot. SCSS caps a single account at ₹30 lakh. So the real question is not “which one” but “what do I do with the ₹10 lakh that will not fit in SCSS, and does the tax on all of it change the ranking?” ...

11 min

Design an Authentication & Login System - System Design

“Let users log in” is the request that hides an entire distributed system. You need to store a password without ever storing the password, verify it in a way that is slow for attackers but fast enough at 100K logins a second, hand out a credential the user carries around, revoke that credential the instant an account is compromised, survive a leaked database dump, layer on a second factor, and let people sign in with Google without you ever seeing their Google password. Every one of those is a place the system breaks, and most of them are places where breaking means a breach, not a slow page. ...

33 min

Design Facebook Marketplace - System Design

Facebook Marketplace looks like “Craigslist with photos,” and if you design it that way you will fail the interview. The naive read is a CRUD app: a listings table, a search box, a chat window. But every one of those three has a scale trap hiding in it. The listing store is easy until you remember that “500M active listings” means half a billion rows that are constantly created, edited, marked sold, and expired, each with several photos that dwarf the metadata. The search box is easy until you realize the query is not “find listings matching iphone” but “find listings matching iphone, priced under 30000, in category Electronics, within 10km of where I am standing, sorted by relevance and recency” - a keyword search and a geospatial search and a set of filters, all at once, over 500M documents, at ~150k queries a second. And the chat window is easy until you count the fraud: Marketplace is one of the most heavily-abused surfaces on the internet, so a scammer posting a fake listing and a stolen-goods reshipping scheme are not edge cases, they are the main event. ...

28 min

Design Live Stock Prices Worldwide (Bloomberg) - System Design

“Show live prices for every stock on every exchange to millions of people at once” reads like a websocket that pushes a number. Then you look at what is actually flowing. Global exchanges emit millions of price ticks per second across hundreds of thousands of symbols. You have millions of users connected, each watching a different handful of symbols, each expecting the number to move within a blink of it moving on the exchange floor. The problem is not “get a price,” it is fan-out: one tick for a hot symbol must reach potentially a million users’ screens in under 100ms, and you cannot afford to send every tick to every user or run a query per user per tick. ...

29 min

HUF for Tax Saving: Real Numbers for a Rs 20 Lakh Salary Household

Most salaried Indians treat their family as a single taxpayer. It does not have to be. If you are Hindu, Jain, Sikh, or Buddhist, the law already recognises a second, separate assessee living in your house: the Hindu Undivided Family. It gets its own PAN, its own Rs 2.5 lakh basic exemption in the old regime (Rs 4 lakh in the new one), and its own full Rs 1.5 lakh 80C limit. Route the right income into it and you are splitting that income across two tax brackets instead of piling it all onto one. ...

12 min

The Outbox Pattern Is the Only Safe Way to Publish Events After a Database Write

The most dangerous line of code in a microservice is not the one that crashes. It is this one: order = db.save(order) # write to Postgres kafka.publish("orders", order) # tell the world It looks correct. It passes every test you write. It works in staging for months. Then one Tuesday your billing service is missing 0.3% of orders, nobody can explain it, and the audit takes three days because there is no error anywhere. The database has the order. Kafka does not. No exception was thrown. No alert fired. The two systems just quietly disagreed, and you found out because a customer did not get charged. ...

11 min

Design Cluster Health Monitoring - System Design

“Monitor the health of the cluster” sounds like a cron job that pings every box and pages someone when one goes quiet. Then you put 50,000 nodes behind it and ask for sub-second detection, and every easy choice breaks. Poll 50K nodes from one monitor and you cannot finish a sweep in a second. Trust a single missed heartbeat and every GC pause or 200ms network blip pages you at 3am. Auto-restart on the first miss and a flaky switch takes down a rack, then your remediation logic restarts all of it in a storm and you have turned a blip into an outage. The whole problem is doing three hard things at once: detect a real failure in under a second across 50K nodes, be sure it is real and not a false alarm, and act on it without making things worse. ...

28 min

Design On-Call Escalation (PagerDuty) - System Design

Everyone thinks PagerDuty is a glorified SMS sender. “A monitoring tool posts an alert, you look up who is on call, and you text them. If they do not reply, you text the next person.” Then the interviewer starts asking the questions that turn it into a real system: how do you know who is on call right now when the schedule is a weekly rotation with a holiday override layered on top and the engineer is in a different timezone? When you say “escalate if not acknowledged within 5 minutes,” where does that 5-minute timer live so that it still fires if the machine holding it crashes? If the same outage trips 400 alerts in ten seconds, how do you page one human once instead of 400 times? And the thing that actually matters: the entire product is a promise that when production breaks at 3am, exactly one awake human gets woken up and, if they do not answer, the timer does not silently die - it escalates. A dropped page is the one bug this system is not allowed to have. ...

33 min

Design P2P File Transfer (BitTorrent) - System Design

The whole point of a file-transfer service sounds like a solved problem: put the file on a server, hand out a URL, let people download. That works until the file is 10GB and a million people want it in the same hour. Now do the arithmetic the interviewer is waiting for: 10GB times 1,000,000 downloads is 10 petabytes of egress, and if half of them show up in the first hour you need roughly 10 PB / 3600s ≈ 2.9 TB/sec of outbound bandwidth from your origin. No single origin, no CDN tier you would willingly pay for, serves 2.9 TB/sec for one file. The server-centric model does not scale sub-linearly with popularity - it scales linearly, and popularity is exactly when it collapses. ...

28 min

Long Context Windows Do Not Replace RAG - They Change When You Use It

Every few months someone declares RAG dead. The argument is always the same: context windows keep growing, so just stuff the whole corpus into the prompt and let the model sort it out. No chunking, no embeddings, no vector database, no retrieval logic. Delete half your pipeline. I have built both. I have shipped a system that dumped 150K tokens of documentation into every request, and I have shipped chunked retrieval over the same corpus. The long-context version was simpler to build and worse to run. It was slower, it cost roughly 30x more per query, and on a specific class of questions it was measurably less accurate. ...

10 min