Shubh Singh (@Beyond_Prompt) header
Shubh Singh (@Beyond_Prompt) profile picture

Somewhere between distributed systems and artificial intelligence.

Event Horizon
Joined November 2026
Photo by Shubh Singh (@Beyond_Prompt)Photo by Shubh Singh (@Beyond_Prompt)Photo by Shubh Singh (@Beyond_Prompt)Photo by Shubh Singh (@Beyond_Prompt)Photo by Shubh Singh (@Beyond_Prompt)Photo by Shubh Singh (@Beyond_Prompt)Photo by Shubh Singh (@Beyond_Prompt)Photo by Shubh Singh (@Beyond_Prompt)Photo by Shubh Singh (@Beyond_Prompt)Photo by Shubh Singh (@Beyond_Prompt)
What is split-brain? This is a particularly dangerous failure scenario. Imagine: - Primary A becomes unreachable due to a network partition. - Replica B gets promoted to primary. - Primary A is still running and accepting writes. - Both A and B now accept independent writes. - Now you have two primaries with conflicting data. This is called split-brain. The solution is fencing: ensure the old primary is prevented from accepting writes before the new primary takes over.
17
Synchronous vs Asynchronous replication This is another critical interview topic. The question is: When should the primary tell the application that a write is successful? Read ⬇️
1
27
Asynchronous replication 1. Application sends a write. 2. Primary saves the data. 3. Primary immediately responds success. 4. Replication happens afterward. Advantages: - Faster writes. = Lower latency. - Less dependency on replica availability. Disadvantage: - If the primary crashes before replication completes, recent writes can be lost.
1
15
Synchronous replication 1. Application sends a write. 2. Primary saves the data. 3. Primary waits for replica confirmation. 4. Application receives success. Advantages: - Stronger durability guarantees. - Lower risk of losing acknowledged writes. Disadvantages: - Higher write latency. - If replicas are unavailable, writes may block.
4
Multi-leader replication : Multiple databases can accept writes independently. Example: US users write to the US database. Indian users write to the India database. Changes replicate between both databases. Advantages: - Lower write latency across regions. - Multiple regions can accept writes. - Better regional availability. Disadvantages: - Conflicting writes can happen. - Conflict resolution becomes complicated. - Last-write-wins (LWW) can silently overwrite valid data.
1
1
43
Example conflict: Two users update the same bank account from different regions simultaneously. One update says balance = ₹5,000, while another says balance = ₹7,000. Which value wins? With last-write-wins, one update may simply overwrite the other. Solution: For banking systems: - Don't use Last-Write-Wins for financial balances. - Use atomic database transactions. - Use optimistic locking or row-level locking. - Maintain an immutable transaction ledger. - Use idempotency keys to prevent duplicate processing. - Use strong consistency across regions for financial operations.
34
If you are into AI/ML this is an important read: Distribution shift: why the 87% goes stale Distribution shift is the mismatch between the data a system was built on and the data it meets in the wild. It is the single biggest reason eval scores and fine-tunes both rot over time. Production prompts drift along three axes: Time: users get more fluent with your product and phrase things differently month over month. User group: the cohort you launched with doesn't look like the cohort you acquire later. Geography: language and cultural patterns vary by region.
3
96
Remember these about Context Engineering: Prompt engineering is a subset of context engineering. An LLM's output depends on everything it sees, not just the prompt. More context can actually reduce answer quality. Memory, retrieval, tools and metadata must be managed dynamically. Context assembly should be treated as a first-class engineering component.
1
2
57
For all system design engineers out there, read carefully : Don't overcomplicate database architecture. PostgreSQL or MySQL is usually enough for most applications, even at significant scale. Engineers often introduce NoSQL databases, distributed databases, and sharding too early. The better approach is: Start with a traditional SQL database. Optimize queries and indexes. Use connection pooling. Scale vertically (more CPU and RAM). Add read replicas when necessary. Introduce sharding only when you genuinely hit scaling limits. This follows the engineering principle of choosing boring, proven technology rather than introducing complexity prematurely.
2
3
73
Database Partitioning vs Sharding : 🎯 Partitioning: One PostgreSQL database contains a users table divided into smaller partitions. 🎯 Sharding: You have three independent PostgreSQL databases: DB1 → Users 1–1 million DB2 → Users 1–2 million (a separate assigned range, not overlapping in a real design) DB3 → Remaining users The important distinction: partitioning doesn't necessarily give you more hardware capacity, while sharding does.
1
63
🔥 Tricky System Design Interview Question: You are designing a payment system like Google Pay or PhonePe. A customer makes a payment of ₹10,000. The bank successfully deducts ₹10,000. Your payment service crashes immediately afterward. Your database still shows the payment as PENDING. The customer retries the payment. The retry request reaches a different server. Question: How will you ensure that: The customer is NOT charged twice? The payment status eventually becomes SUCCESS? No transaction is lost, even if the server crashes multiple times?
1
124
The Three Body Problem...
1
120
Common cache eviction techniques LRU (Least Recently Used): Removes the item that hasn't been accessed for the longest time. LFU (Least Frequently Used): Removes the item accessed the fewest times. FIFO (First In, First Out): Removes the oldest inserted item. Random Replacement: Removes a randomly selected item. MRU (Most Recently Used): Removes the most recently accessed item. TTL (Time To Live): Removes or expires items after a specified duration.
2
95
Five Caching Patterns : 1. Cache-aside: The application manages the cache itself. 2. Read-through: The cache itself fetches data from the database when a cache miss happens. 3. Write-through: Every write updates both cache and database synchronously. 4. Write-behind: The application writes to cache first. The cache asynchronously flushes changes to the database. 5. Refresh-ahead: The cache refreshes data before it expires. Instead of waiting for a cache miss, it proactively refreshes frequently accessed keys.
2
92
Nobody wants your chips jensen they want your secret...
1
100
What is Consensus ? Imagine you have 5 servers storing the same database. A client sends a request: Transfer ₹1,000 from Account A to Account B All 5 servers must agree on: Whether the transaction should happen. The order in which transactions happen. Whether the transaction is permanently committed. What if one server crashes? What if two servers cannot communicate? You still need the remaining servers to agree without creating conflicting data. This is the problem consensus solves.
69
The quality of an AI agent depends heavily on how its tools are designed. A tool isn't just a function that an LLM calls. It's an interface the model must understand, select, invoke, and recover from when something goes wrong.
54
Different AI Agent workflows & how to choose between them -> 👉 Known sequential steps? → Chaining 👉 Different categories need different handlers? → Routing 👉 Independent subtasks? → Parallelization 👉 Subtasks depend on the specific request? → Orchestrator-workers 👉 Need iterative refinement against clear criteria? → Evaluator-optimizer
50
The Magic Library: Understanding Neural Networks An important concept in AI, explained through a short story. Once upon a time, in a small village, there lived a curious girl named Maya. Maya loved identifying flowers. She could recognize roses, sunflowers, and tulips just by looking at them. One day, her grandfather gave her a magical machine. "This machine can learn to recognize flowers," he said. "But you must teach it first." The learning begins Maya showed the machine 100 pictures of flowers. She told it which pictures contained roses. She showed it pictures of sunflowers. She also showed it pictures of tulips. At first, the machine made many mistakes. It called roses tulips and sunflowers roses! But every time it made a mistake, Maya showed it the correct answer. Slowly, the machine started recognizing patterns: Roses often have layered petals. Sunflowers have large central discs. Tulips have distinctive cup-shaped flowers. After seeing thousands of examples, the machine became very good at recognizing flowers. The big discovery Maya realized something amazing: The machine wasn't simply memorizing every picture. It was learning patterns from examples. Her grandfather smiled. "That's the basic idea behind a Neural Network!" Neural networks are AI systems loosely inspired by the human brain. They contain interconnected mathematical units that process information and learn patterns from data. What did Maya actually learn? Story element AI concept Flower pictures -> Training data Teaching correct answers -> Supervised learning Machine's mistakes -> Prediction errors Correcting mistakes -> Adjusting weights Recognizing flowers -> Prediction
54
Indian CEO's after realizing they are not going to get "Honeytrapped", as they never invested in any R&D ...
49