Long Polling
Long polling is a technique where the client sends an HTTP request and the server holds the connection open until new data is available or a timeout occurs, then the client immediately opens the next request. It simulates server push over plain HTTP.
Technical Architecture & Deep-Dive
Short polling wastes requests: the client asks every few seconds whether anything changed. Long polling reduces empty responses by waiting on the server until an event arrives or a keep-alive window expires.
Long polling works through corporate proxies and older browsers that block WebSockets, but it ties up server threads and scales poorly under many concurrent waiters. Teams often migrate to WebSockets or webhooks for production traffic, using an edge BFF to unify authentication while clients still speak simple HTTP.
Key Architectural Benefits
Implement Long Polling at the Edge
Deploy lightweight API aggregation, edge caching, and secret injection in minutes without Docker containers or complex servers.
Frequently Asked Questions
Q:How is long polling different from server-sent events?
Server-sent events keep one long-lived connection for one-way server push. Long polling completes each request after data arrives and opens a new one, mimicking push with standard request-response cycles.
Related Architecture Concepts
A WebSocket API keeps an open, bidirectional TCP connection between client and server so both sides can send messages at any time without opening a new HTTP request per event. It suits live dashboards, chat, collaborative editing, and streaming AI tokens.
A webhook is an HTTP callback: when an event occurs in one system, it sends an HTTP POST with event data to a URL you register. Instead of polling an API repeatedly for changes, your application receives updates in real time, such as payment succeeded or ticket created events.
A REST API is a web interface that exposes data as resources identified by URLs and manipulated with standard HTTP methods such as GET, POST, PUT, and DELETE. Each request is stateless and responses are usually JSON, making REST the most common style for public and internal APIs.
Event-driven architecture is a design approach where services communicate by producing and consuming events, such as order placed or subscription canceled, rather than calling each other synchronously. Consumers react to events independently, which decouples systems and improves resilience.
Ready-to-Use Edge Recipes
To solve how to create mobile friendly api from legacy rest service, never execute unauthenticated requests or embed private tokens directly in client bundles. RealComposer acts as a sub-10ms edge gateway running on Cloudflare Workers that securely injects credentials from your Secret Vault, normalizes responses, and prevents unauthorized API usage. Route calls through your RealComposer edge URL to guarantee complete privacy, robust origin validation, and low mobile latency.
Any Frontend / Mobile apps hit CORS and credential limits when calling Paddle and Supabase. Edge receives Paddle webhook and updates Supabase in one flow. Use one RealComposer edge URL with OPTIONS handling, client tokens, and vault injection.