polling
Having the client ask repeatedly, on its own schedule, whether something has changed or finished.
In more detail
Polling is simple and easy to retry, and it works when the client cannot receive inbound calls. It costs repeated requests when nothing changed, so use a sensible interval, backoff and a cursor. Webhooks and streams push changes instead.
Examples
In the browser: Polling the DOM every few milliseconds wastes CPU and still reacts late. Observers such as MutationObserver notify you only when something actually happens.The outbox relay polls for unsent rows; web-first assertions poll the page.select {
case value := <-updates:
fmt.Println(value)
default:
fmt.Println("no update")
}Go: a select with a default case polls a channel onceRelated terms
- job resource — A resource that represents long-running work, answered with 202 Accepted and a Location the client can poll for progress and the result.
- webhook — An HTTP request a provider sends to an address you registered, to tell you an event happened, instead of you polling for it.
- Server-Sent Events — A standard way for a server to keep an HTTP response open and push a stream of text events to the client, in one direction only.
- 202 Accepted — The HTTP status meaning the request was accepted for processing but the work has not finished yet.
- network socket — One end of a two-way network connection between programs, identified by an IP address and a port number.
- MutationObserver — A browser object that watches part of the DOM and reports changes, such as added nodes or changed attributes, in batches.
- setInterval() — A JavaScript function that runs a callback repeatedly, roughly every given number of milliseconds, until clearInterval stops it.
- background worker — A process that runs outside the request path and handles work such as publishing events or sending emails.
- web-first assertion — A Playwright assertion that keeps rechecking the page until the condition is true or a timeout expires.
- select statement — A Go statement that waits on several channel operations at once and runs the first one that is ready.
- timer and ticker — Go time values that deliver on a channel later: a timer fires once after a duration, a ticker fires repeatedly at an interval.
- blocking operation — An operation that makes the code wait until something happens, such as a receive waiting for a value to arrive on a channel.
- WebSocket — A protocol that turns an HTTP connection into a long-lived, two-way channel where client and server can each send messages at any time.
- epoll — The Linux kernel facility that lets one thread watch many file descriptors and be told which are ready for reading or writing.
Taught in
- Actions That Do Not Fit CRUD — Modern API Architecture: REST, GraphQL & gRPC
- Webhooks Versus Polling — Modern API Architecture: REST, GraphQL & gRPC
- Event-Driven Architecture And Queues — Modern API Architecture: REST, GraphQL & gRPC
- Confusable Services Sprint: One Clue Each — AWS Certified Cloud Practitioner (CLF-C02) Exam Prep
- Decoupling: SQS, SNS, EventBridge And Step Functions — AWS Certified Solutions Architect – Associate (SAA-C03) Exam Prep
- MutationObserver: Reactive DOM Watching Without Polling — Frontend Architecture & Web Platform
- Asynchronous Event Processing: Outbox Pattern & Queues — Production Full-Stack Engineering
- End-to-End Testing with Playwright: Multi-Tier Suites — Production Full-Stack Engineering
- The select Statement — Concurrent Systems Programming with Go
- libuv Architecture: Event Demultiplexer & Thread Pool — Node.js Internals & Backend Services
- Event Loop Lifecycle: The Six Phases & libuv uv_run — Node.js Internals & Backend Services
- Poll & Check Phases: I/O Callbacks & setImmediate — Node.js Internals & Backend Services
- Native WebSockets: Bidirectional Real-Time Streams — Node.js Internals & Backend Services
- Queues, Events And Asynchronous Work — Scalable System Design & Distributed Architecture
- Backpressure And Load Shedding — Scalable System Design & Distributed Architecture
- Worked Design Two: A Global Chat System — Scalable System Design & Distributed Architecture
References
- Google AIP-151: Long-running operations
- RFC 6202: Known Issues and Best Practices for the Use of Long Polling and Streaming
- Azure Architecture Center: Asynchronous Request-Reply pattern
- MDN: MutationObserver
- microservices.io: Polling publisher pattern
- The Go spec: select statements
- poll(2) manual page