Firestore Listeners vs WebSockets: How Real-Time Updates Actually Work

Firestore has one of the most convenient real-time APIs in web and mobile development. We write a listener: import { collection, onSnapshot, query, where } from "firebase/firestore"; const q = query( collection(db, "messages"), where("roomId", "==", "general") ); const unsubscribe = onSnapshot(q, (snapshot) => { snapshot.docChanges().forEach((change) => { console.log(change.type, change.doc.id, change.doc.data()); }); }); After that, the UI updates whenever matching documents are added, modified, or removed. It feels similar to a WebSocket because the browser receives real-time updates without manually polling. But Firestore listeners and WebSockets are not the same abstraction. ...

May 3, 2026 · 13 min · Nitin

WebSockets Explained: How Real-Time Communication Works on the Web

Most web applications start with a simple request-response model. The browser asks for something, the server responds, and the connection is done. That model works well for pages, APIs, forms, dashboards, and most CRUD applications. But some features need something different: chat messages that appear instantly live sports scores multiplayer game state collaborative editing cursors trading prices delivery tracking real-time notifications terminal sessions in the browser For these features, repeatedly asking the server “anything new?” becomes wasteful and slow. ...

May 3, 2026 · 12 min · Nitin
CAP theorem cover illustrationA triangle showing consistency, availability, and partition tolerance with a note that partitions force a trade-off between consistency and availability.CAP TheoremHow distributed systems choose behaviorwhen the network stops cooperatingCConsistencyAAvailabilityPPartitionToleranceNetwork splitWhen a partition happens, you usually choose CP or AP.

CAP Theorem Explained: Consistency vs Availability in Distributed Systems

The CAP theorem is one of the most important ideas in distributed systems because it explains why “just make it always correct and always online” is not a realistic requirement once multiple nodes and unreliable networks enter the picture. In simple terms, CAP says that when a network partition happens, a distributed system can prioritize either: Consistency Availability But not both at the same time. Partition tolerance is not a feature you casually add or remove. If your system runs across multiple machines, partitions are a fact of life, so the real design choice is usually CP vs AP. ...

March 9, 2026 · 4 min · Nitin
Stripe hosted checkout flow using webhook-first fulfillment and order status polling

Integrating Stripe Payment with Checkout Flow (Webhooks + Polling)

If you use a hosted payment page like Stripe Checkout, the safest architecture is: Create an internal order before redirecting. Redirect the user to the hosted checkout URL. Use webhooks as the source of truth for fulfillment. Let the frontend poll order status after return. This avoids race conditions and ensures users still get entitlements even if they close the tab before the success page loads. Why This Pattern Works Hosted checkout redirects are excellent for UX and compliance, but redirects are not guaranteed delivery signals. ...

March 3, 2026 · 2 min · Nitin

Building Robust Systems: Key Lessons from Designing Data-Intensive Applications Chapter 1

Introduction If you’re involved in building software today, chances are you’re dealing with data. Lots of it. Maybe it’s user activity, sensor readings, financial transactions, or something else entirely. Martin Kleppmann’s phenomenal book, “Designing Data-Intensive Applications” (often called DDIA), is practically required reading for navigating this landscape. Let’s dive into some key takeaways from this essential chapter. The Shift: It’s About the Data, Not Just the CPU The chapter opens by highlighting a crucial distinction: many modern applications are data-intensive, not compute-intensive. While CPU power is abundant, the real challenges often lie in: ...

May 4, 2025 · 5 min · Nitin

Demystifying API Gateways: A Comprehensive Guide

Introduction In today’s interconnected digital landscape, APIs (Application Programming Interfaces) serve as the backbone of modern software development, enabling seamless communication between disparate systems. However, managing and securing APIs can be complex, especially in microservices architectures where numerous services interact with each other. What is an API Gateway? An API gateway is an architectural pattern that sits between clients and backend services, acting as a single entry point for all incoming API requests. It serves as a reverse proxy, routing requests to the appropriate services based on predefined rules and configurations. API gateways offer a centralized point of control for managing various aspects of API communication, including routing, authentication, authorization, rate limiting, logging, and monitoring. ...

March 8, 2024 · 3 min · Nitin

Understanding Anycast IP Addresses: How They Work and When to Use Them

Introduction In the realm of networking, Anycast IP addresses represent a fascinating concept that has become increasingly popular due to its ability to enhance performance, scalability, and reliability of services across distributed networks. This blog post aims to delve into the intricacies of Anycast, exploring its underlying principles, mechanics, use cases, and considerations for implementation. What is Anycast? Anycast is a networking technique that allows multiple servers to advertise the same IP address. When a client sends a request to this shared IP address, the routing infrastructure directs the request to the nearest or best-performing server based on network conditions such as proximity, latency, or routing metrics. ...

February 20, 2024 · 3 min · Nitin