Posts

Showing posts from 2026

JS async await execution process

 Example console.log("0") async function f() {     console.log("1");     const pr1 = await new Promise((resolve) => {         console.log("2");         setTimeout(() => {             console.log("3");             resolve("pr1");         }, 5000);     });     const pr2 = await new Promise((resolve) => {         console.log("4");         setTimeout(() => {             console.log("5");             resolve("pr2");         }, 2000);     });     return [pr1, pr2]; } console.log("6"); f().then(result => console.log("Result:", result)); console.log("7"); ==========OUTPUT========== 0 6 1 2 7 3 (after 5 seconds) 4 5 (after 2 seconds) Result: [pr1, pr2] Execution order console.lo...

Angular - Recommended 14-day interview ready plan

Angular - Recommended 14-day interview ready plan Days 1-2 — Angular Fundamentals Angular architecture CLI Project structure Components Templates Data Binding Directives Pipes Component lifecycle Days 3-4 — TypeScript in Angular Decorators Dependency Injection Services Providers Injection hierarchy Signals (modern Angular) Days 5-6 — Routing Router Lazy Loading Route Guards Resolvers Nested Routes Dynamic Routing Days 7-8 — Forms Template-driven Forms Reactive Forms FormBuilder Validators Async Validators Custom Validators Days 9-10 — API Communication HTTP Client RxJS basics Observables Subjects BehaviorSubject Operators map switchMap mergeMap concatMap forkJoin combineLatest debounceTime catchError Day 11 — State Management Services Signals NgRx basics Component communication Smart vs Presentational Components Day 12 — Advanced Angular Change Detection Zone.js OnPush Standalone Components Performance Optimization SSR Hydration Day 13 — Machine Coding Build: Login Dashboard Product Li...

Scalable Websocket Systems: What to know?

Scalable Websocket Systems: What to know? How connections are established. Why sticky sessions matter. How room membership is tracked. How message ordering is handled. What happens when a WebSocket server dies. Presence (online/offline users). Persistence vs Pub/Sub. Why Redis Pub/Sub may fail at scale. Why NATS worked better. Fan-out optimization techniques. Backpressure handling. Monitoring and metrics. Multi-region challenges. Let's rebuild the entire story from the beginning as if we are designing WhatsApp ourselves. Chapter 1: User Opens WhatsApp Suppose User A opens WhatsApp. Immediately: User A | | Internet | Load Balancer | WebSocket Server The client requests: GET /socket Upgrade: websocket Server accepts. Now connection becomes: User A <=================> Server and stays alive. Chapter 2: Why Not HTTP? With HTTP: User A | Request | Server If User B sends a message: Server cannot push because HTTP request ended. Server must wait. WebSocket solves thi...