Webhook, WebSocket or periodic polling: which one to use in each case

Published on 2026-09-12 by frfrand

Three ways to find out that something happened, with very different costs. Four questions that resolve the decision without discussing architecture.

Webhook, WebSocket or periodic polling: which one to use in each case

Short answer: use a webhook when an external service is the first to know; a WebSocket when frequent back-and-forth with the browser is needed; Server-Sent Events when the client only receives; and periodic polling when a delay of a few seconds or minutes doesn't change anything. Most systems combine two of these.

The three solve the same underlying problem: finding out that something happened. They differ in who speaks first, how much it costs to maintain, and what happens when something fails.

The three, in one line each

Periodic polling. You ask every so often. Simple, nothing to keep alive.

Webhook. The other service calls you when something happens. No permanent connection, but you need a public address.

WebSocket. An open connection in both directions. Minimum latency, in exchange for keeping that connection per client.

The four questions

1. Who starts the conversation?

If the one who knows something new is an external service (a payment platform, GitHub, WhatsApp), the answer is webhook. No discussion: it's the mechanism those services offer.

If the one who knows something new is your own backend and the recipient is a browser, look at the other two.

2. How often?

Events per hour → webhook or periodic polling. Events per second → WebSocket.

Keeping a thousand open connections to report something that happens three times a day is costly in maintenance and resources.

3. Is a round trip necessary?

If the client only receives (notifications, task progress, a panel that updates), Server-Sent Events is usually better than a WebSocket: it runs over normal HTTP and the browser reconnects on its own.

WebSocket is justified when the client also sends frequently: a chat, a collaborative editor, a game.

4. What if it arrives late?

If a thirty-second delay changes nothing, periodic polling and done. It's the most boring option and the one that breaks the least.

Why periodic polling is not the losing option

It has a bad reputation and deserves a defense, because in production it wins more often than is admitted:

  • There are no connections to maintain nor reconnections to implement.
  • It recovers on its own: if a request fails, the next one brings everything up to date.
  • It scales without thinking: any server can respond, there is no need for the client to always return to the same one.

When volume is the problem, there are intermediate ways: request only what changed since the last time, or leave the request waiting until there is news (long polling), which gives almost real-time latency with much less complexity.

The classic mistake

Choosing WebSockets because it sounds modern, and discovering three months later that you have to solve: reconnection, recovery of lost messages while you were disconnected, sticky sessions on the load balancer, open file descriptor limits, and a Redis to distribute among servers.

All that is real and permanent work. It's worth it when the product needs it. It's not worth it to update a counter every minute.

Most common in real life

Most systems use two of the three, not just one.

A typical example: webhooks to find out what's happening outside (payments, messages, repositories), WebSocket or SSE for the part of the interface that really needs to be seen live, and periodic queries for everything else.

Choosing a single technology for everything is the shortest path to fighting with it.

Webhook, WebSocket or periodic polling: which one to use in each case
Webhook, WebSocket or periodic polling: which one to use in each case

How to choose for a project hosted on ArduMaker

Notification from a payment provider: use a webhook, validate the sender's signature, and process the event idempotently. Real-time chat: evaluate WebSocket and plan authentication, reconnections, and persistent connection consumption. Occasional panel update: a periodic query may be easier to operate.

On an ArduMaker VPS you can host the API that receives webhooks or maintains WebSockets; the key is to properly configure HTTPS, logs, retries, and scaling according to need. Published domains pass WebSocket through the edge proxy, which cuts connections with more than 360 seconds without traffic: if you use WebSocket, send a ping beforehand. Do not add persistent connections if the user only needs to update information every few minutes.

Related: What is a webhook · What is a WebSocket.

Frequently Asked Questions

When is periodic polling (polling) convenient? When the data changes every few minutes and the application does not need to react instantly. It does not maintain connections, recovers on its own, and scales without sticky sessions.

What is long polling? A request that the server keeps waiting until there is news. It provides near real-time latency with much less complexity than a WebSocket.

Can I use webhooks to the browser? No: a webhook needs a public address to receive requests. For the browser, the options are WebSocket, Server-Sent Events, or periodic polling.

  • webhooks
  • WebSocket
  • polling
  • arquitectura
  • tiempo real

Keep reading

All articles · VPS plans