Muhammad Sohaib (@Muhammad1Sohaib) header
Muhammad Sohaib (@Muhammad1Sohaib) profile picture

I have no energy for hate. I either love you. Wish you well. Or hope you heal🤲

Islamabad, Pakistan
Joined September 2025
Muhammad Sohaib retweeted
Which payment gateway would you prefer for your SaaS?
80
9
1
84
6,549
Muhammad Sohaib retweeted
System Design Series - Day 13/30 Database Failover & High Availability – How to Survive When Your Primary DB Dies Your primary database will crash one day. It’s not a question of if, but when. The real question is: how fast can you recover without losing revenue or trust? Here’s exactly how production systems handle failover, including the real 2 AM incident we faced. The Nightmare Scenario 2:47 AM. Primary database goes down. All writes fail instantly. Your app becomes read-only. Users can’t sign up, post, buy, or update anything. Without a proper plan, you’re looking at hours of downtime and angry customers. What is Failover? Failover is the process of automatically or manually promoting a healthy replica to become the new primary when the old one dies. Before crash: Primary (handles all writes) → Replicas (handle reads) After failover: Replica 1 becomes the new primary (now handles writes) → remaining replicas follow it. Manual Failover (Most startups do this at 2 AM) bash # On the chosen replica psql -c "SELECT pg_promote(); # Update your application config to point to the new primary # Restart your API servers systemctl restart api-server Downtime: 10–15 minutes. It works, but it’s stressful and slow. Automatic Failover with Patroni (Production Standard) Patroni + etcd monitors the primary every 10 seconds. If it doesn’t respond for 30 seconds, it automatically promotes the best replica. Downtime drops to 30–60 seconds. The Dangerous Split-Brain Problem What happens during a network partition? Both the old primary and a replica think they are the leader and start accepting writes. Result: Data divergence and corruption. Solution: Use distributed consensus (etcd or Consul). Only one node can hold the leader lock at any time. Our Production Setup - HAProxy with virtual IP (db. prod. com) - Patroni cluster running on Primary + Replicas - etcd cluster (3 nodes) for leader election Tested scenarios: - Primary crash → new primary promoted in ~45 seconds - Network partition → etcd prevents split-brain - Replica crash → no impact Result: 99.95% uptime. Key Takeaways: - Manual failover = 10–15 min downtime (acceptable for early startups) - Automatic failover with Patroni = 30–60 sec downtime (required for real SaaS) - Always use etcd/Consul to prevent split-brain - Test your failover process every quarter - Monitor replication lag constantly Database high availability isn’t glamorous, but it saves your company at 2 AM. Questions about failover, Patroni, or etcd?
22
29
1
204
6,253
Muhammad Sohaib retweeted
Load Balancer vs Reverse Proxy vs API Gateway (explained in 2 minutes or less):
11
95
601
16,469
Muhammad Sohaib retweeted
System Design Cheat Sheet - 15 Core concepts you need to know.  Ready for that? Here is a cheat sheet for system design that will help you go over key concepts quickly. (I wish I had created this earlier for myself!) 1. Requirement Gathering- Identify functional and non-functional requirements.- Define user stories and workflows.- Set priorities based on business goals.- Map dependencies and potential constraints. 2. System Architecture- Define system components and interactions.- Choose suitable architectural patterns and styles.- Optimize for scalability and maintainability.- Evaluate trade-offs between monolithic and distributed systems. 3. Data Design- Design data models, schemas, and relationships.- Choose the right database for scalability and consistency.- Define retention policies, backups, and archival strategies.- Use normalization and denormalization where required. 4. Domain Design- Break systems into logical business domains.- Encapsulate functionality within domain modules.- Minimize dependencies across domains for flexibility.- Ensure domain-specific data ownership and boundaries. 5. Scalability- Implement horizontal and vertical scaling strategies.- Use load balancing for traffic distribution.- Optimize database partitioning and sharding techniques.- Plan for autoscaling to handle traffic spikes. 6. Reliability- Design for fault tolerance and graceful degradation.- Set up monitoring, alerting, and logging systems.- Implement backup and restore mechanisms.- Use retries, circuit breakers, and timeouts for resilience. 7. Availability- Replicate data across nodes for redundancy.- Minimize downtime with failover strategies.- Design disaster recovery plans with RTO and RPO goals.- Test high availability setups regularly under load. 8. Performance- Optimize latency and throughput for responsiveness.- Use caching layers for frequently accessed data.- Optimize algorithms and query performance.- Enable compression for faster data transmission. 9. Security- Implement authentication and authorization systems.- Encrypt sensitive data at rest and in transit.- Perform regular vulnerability scans and audits.- Protect APIs and endpoints from common attacks. 10. Maintainability- Write modular, clean, and well-documented code.- Automate deployments and version control.- Design systems to scale without breaking features.- Incorporate CI/CD pipelines for fast and safe updates. 11. Testing- Define unit, integration, and end-to-end test cases.- Simulate load testing for performance benchmarks.- Validate API behavior and input-output correctness.- Test for security vulnerabilities and compliance. 12. User Experience Design- Prioritize intuitive and responsive UI designs.- Optimize workflows for faster task completion.- Conduct usability testing for continuous improvement.- Implement accessibility standards for diverse users. 13. Cost Estimation- Evaluate hardware and infrastructure costs upfront.- Assess licensing, scaling, and operational expenses.- Optimize cloud resource utilization for efficiency.- Plan budgets for disaster recovery and failover systems. 14. Documentation- Maintain up-to-date technical and architectural documents.- Provide API references and user manuals.- Use diagrams for visual representations.- Ensure documentation is version-controlled and shareable. 15. Migration Plan- Verify compatibility between old and new systems.- Create a step-by-step migration strategy.- Test migration processes in a staging environment.- Monitor and validate data integrity post-migration.
31
175
6,415
Muhammad Sohaib retweeted
How to Get a Developer Job in 3 Months 🚀 🔥 Month 1: Foundations + Momentum 📚 Learn HTML, CSS, JavaScript (basics) 🧠 Understand how the web works (browser, DOM) 💻 Build 1–2 simple websites (landing page) 🌐 Learn Git & GitHub (push projects from day one) 🛠️ Month 2: Projects That Matter 🧱 Strengthen JavaScript fundamentals 🖼️ Build 2–3 small projects 📱 Make projects responsive 🎨 Learn basic UI/UX principles 📂 Start organizing a portfolio repo ⚡ Month 3: Job-Ready Mode ⚛️ Learn one framework (React or Vue – basics) 🔗 Work with APIs & fetch 🧑‍💼 Polish GitHub + LinkedIn 🌐 Launch a simple portfolio site 📝 Prepare CV & cover letter 📨 Apply to 2–3 jobs/day 💬 Start networking (Discord, X, LinkedIn) 💻 Practice interview questions (JS + logic) 🔁 Daily Rule ⏱️ Code at least 1–2 hours/day 📈 Build → Apply → Learn → Repeat
3
16
106
5,800
Muhammad Sohaib retweeted
Polling vs Long Polling vs Webhooks vs SSE Four ways to get updates from a server. Each one makes a different tradeoff between simplicity, efficiency, and real-time delivery. Here's how they compare: - Polling: The client sends a request every few seconds asking "anything new?" The server responds immediately, whether or not there's new data. Most of those requests come back empty, wasting client and server resources. For use cases like an order status page where a small delay is acceptable, polling is the simplest option to implement. - Long Polling: The client sends a request, and the server keeps the HTTP connection open until new data is available or a timeout occurs. This means fewer empty responses compared to regular polling. Some chat applications used this pattern to deliver messages closer to real-time communication. - Server-Sent Events (SSE): The client opens a persistent HTTP connection, and the server streams events through it as they're generated. It is one-way, lightweight, and built on plain HTTP. Many AI responses that appear token by token are delivered through SSE, streaming each chunk over a single open connection. - Webhooks: Instead of the client asking for updates, the service sends an HTTP POST to a pre-registered callback URL whenever a specific event occurs. Stripe uses this for payment confirmations. GitHub uses it for push events. The client never polls or holds a connection open, it just waits for the server to call. Many systems don't rely on a single pattern. You may use polling for order status, SSE for streaming AI responses, and webhooks for payment confirmations.
13
99
5
511
69,588
Muhammad Sohaib retweeted
Data Warehouse vs Data Lake vs Data Mesh Storing data is the easy part. Deciding where and how to organize it is the real challenge. A data warehouse is the traditional approach. It cleans and structures data before storing it. Queries run fast, and reports stay consistent. But adding a new data source takes effort because everything has to fit the schema first. A data lake takes the opposite approach. It stores everything raw, like databases, logs, images, and video. Process it when you need it. The flexibility is great, but if rules around naming, formatting, and ownership are not properly set, you end up with duplicate, outdated, and undocumented data that is hard to manage. Data mesh shifts data ownership from a central team to individual departments. For example, sales publishes sales data, and finance publishes finance data. Shared standards keep things compatible across teams. It works well in larger organizations. But it requires every team to have the right people and processes to manage their data quality, documentation, and access, which is a challenge. In practice, many companies use more than one approach. They'll use a warehouse for dashboards and reporting, a lake for machine learning workloads and start applying mesh principles as teams scale.
7
114
4
531
28,231
Muhammad Sohaib retweeted
API Concepts Every Software Engineer Should Know
6
152
1
784
64,070
Muhammad Sohaib retweeted
SLA vs SLO vs SLI These three terms are related, but they mean different things. Knowing the difference helps you define what to measure, aim for, and promise your customers. Here's how they actually connect: - SLI (Service Level Indicator): This is the metric you're measuring. For a login service, it could be the ratio of successful login requests to total valid requests. It tells you how your service is performing right now. - SLO (Service Level Objective): You take that SLI and define a target around it. Something like "login availability should stay above 99.9% over a rolling 28-day window." When you're missing your SLO, it’s a signal to find out what's failing before customers notice. - SLA (Service Level Agreement): This is what you promise your customers in a contract. It's usually set lower than the SLO, say 99.5% monthly availability. If you breach it, you owe service credits. If your SLO and SLA are both set to 99.9%, then the moment your availability drops below 99.9%, you've already breached the agreement. The SLI tells you where you stand. The SLO tells you where you should be. The SLA tells your customers what they can expect.
4
71
362
22,178
Muhammad Sohaib retweeted
Interviewer: A user clicks "Logout from all devices". How would you invalidate all active sessions?
35
5
1
96
9,680
Muhammad Sohaib retweeted
If it’s async - Node.js If it’s debugging - console.log If it’s type-safe - TypeScript If it’s rapid prototyping - Firebase If it’s clean APIs - FastAPI If it’s frontend - React If it’s mobile - Flutter If it’s styling - Tailwind If it’s auth - Supabase If it’s payments - Stripe If it’s deployment - Vercel If it’s containers - Docker If it’s orchestration - Kubernetes If it’s monitoring - Prometheus If it’s CI/CD - GitHub Actions
15
33
256
21,280
Muhammad Sohaib retweeted
All Paid Courses (Free for First 4500 People) 𝗣𝗮𝗶𝗱 𝗖𝗼𝘂𝗿𝘀𝗲 𝗙𝗥𝗘𝗘 (PART - 1) 1. Artificial Intelligence 2. Machine Learning 3. Prompt Engineering 4. Claude,Chatgpt,Grok 5. Data Analytics 6. AWS Certified 7. Data Science 8. BIG DATA 9. Python 10. Ethical Hacking (72 Hours only ) To get- 1. Follow me to get DM 2. Like + RT 3. Reply " All "
2,443
1,342
7
3,475
386,779
Muhammad Sohaib retweeted
ایرانی ٹرولنگ بھی کمال کی کرتے ہیں ، ابراہیم ذوالفقاری امریکہ اور اسرائیل کو چھیڑتے ہوئے ، آج کے دن کی سپر وائرل ویڈیو
45
2,658
26
13,597
204,099
Muhammad Sohaib retweeted
If you want death of #Netanyahu please retweet.
163
6,400
47
10,201
139,502
Muhammad Sohaib retweeted
میرے اکاؤنٹ کو بہت زیادہ رپورٹ کیا گیا ہے جسکی وجہ سے اکاؤنٹ بہت زیادہ نیچے چلا گیا ہے آپ خواتین و حضرات سے گزارش ہیں کہ میری آخری 5 پوسٹوں کو ری پوسٹ کریں لائک کریں کمنٹ کریں
42
251
1
890
57,875
Muhammad Sohaib retweeted
ایران کا ایک ایک میزائل اسرائیل میں شدید تباہی کا باعث بن رہا ہے اگر اس تباہی سے آپکو سکون۔ ملا ہے تو اس پوسٹ کو ری پوسٹ کریں لائک کریں
40
1,032
11
2,651
55,332
Muhammad Sohaib retweeted
Toughest military in the world when it comes to fighting women and children. "Keep posting. Keep resharing. Never stop speaking about P@lestine. Harassment and humiliation are part of their daily life under occupation and apartheid. 🇵🇸. 🇵🇸" Israel Palestine Iran
204
3,725
97
6,968
156,633
Muhammad Sohaib retweeted
ڈرون تصاویر سے ظاہر ہوتا ہے کہ عراق کے شہر بصرہ میں امریکی کمپنی کے دفاتر اور گوداموں پر مشتمل کمپاؤنڈ ایرانی ڈرون حملوں میں مکمل طور پر تباہ ہو گیا اگر اس خبر سے آپکو سکون۔ ملا ہے تو اس پوسٹ کو ری پوسٹ کریں لائک کریں
73
1,893
50
6,489
441,264