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)
BOLA (Broken Object Level Authorization) : Meaning: BOLA happens when an application allows a user to access another user's data by changing an object ID in an API request. In simple words, a user can see or modify someone else's data without permission. Small example: Imagine you have a banking application. User A has account ID 101. User B has account ID 102. User A sends an API request: GET /api/accounts/101 The application correctly shows User A's account details. But User A changes the ID: GET /api/accounts/102 If the application shows User B's account details, it has a BOLA vulnerability.
19
Low-cardinality columns may not benefit from ordinary B-tree indexes. Consider: text users ------------------- id active 1 true 2 true 3 false 4 true 5 false ... - Suppose 95% of users have active = true. - An index on active might not be useful for: SELECT * FROM users WHERE active = true; - Because the query needs most of the table anyway. - However, if you frequently query inactive users, a partial index could be much better: CREATE INDEX idx_inactive_users ON users(id) WHERE active = false; This index contains only inactive users. - That means a much smaller index for that particular workload. - Low cardinality alone doesn't automatically make an index bad. Distribution, query selectivity, table size, and whether the query needs the entire row all matter.
23
🎯 Optimistic vs. Pessimistic UI Updates 1. Optimistic UI update The UI updates immediately, assuming the API request will succeed. The API request runs in the background. ⭐ Immediate feedback Example: A user clicks the Like button. - User clicks Like. - UI immediately changes the button to Liked. - API request is sent to the server. - If successful, nothing more is needed. - If it fails, revert the UI to its previous state.
1
43
2. Pessimistic UI update The UI waits for the API request to succeed before reflecting the change. ⭐ Wait for server confirmation Example: A user submits a payment. - User clicks Pay. - UI sends the API request. - UI displays a loading indicator. - Server processes the payment. - If successful, UI displays payment success. - If it fails, UI displays an error.
31
GitHub's 2018 incident: GitHub experienced a 43-second network partition in October 2018. ❓What happened? -> GitHub had MySQL clusters using semi-synchronous replication. -> A network partition separated its East Coast infrastructure. -> Its failover system promoted West Coast replicas. -> The old East Coast primaries had accepted writes that hadn't replicated to the West Coast. -> Both sides had divergent writes. -> GitHub decided to keep the West Coast as primary rather than risk losing user data. 🤔Consequences: -> One busy cluster had 954 unreplicated writes. -> Recovery took 24 hours and 11 minutes. -> Database restoration and replica catch-up took hours. -> Millions of queued events and builds had to be processed afterward. Lesson: Replication alone doesn't guarantee safe failover. You must design for network partitions, divergent writes, fencing, and recovery.
59
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.
54
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
50
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
32
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
57
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.
45
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
106
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
66
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
80
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
70
🔥 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
130
The Three Body Problem...
1
125
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
99