Polling and webhooks: a better way to get updates

Polling and webhooks are two methods used by applications and services to receive updates or data. Polling is a technique where an application repeatedly checks (or "polls") a server at regular intervals to see if there is new data available. This is like continuously asking, "Do you have anything new for me?" Polling is simple to implement but can be inefficient because it involves making requests at intervals even when there might not be any new data, leading to unnecessary load on the server and network traffic. Webhooks, on the other hand, are a more efficient way for applications to get updates. Instead of asking for new data at regular intervals, a server will send (or "push") data to the application as soon as something new happens. This is done by the server making an HTTP request to a URL (webhook URL) provided by the application. Webhooks are like a subscription to events, where the server notifies the subscriber immediately when a specific event occurs, resulting in real-time updates without the need for constant polling. Read below to know more

View organization page for ByteByteGo

612,366 followers

Polling Vs Webhooks  .  .  - Polling  Polling involves repeatedly checking the external service or endpoint at fixed intervals to retrieve updated information.    It’s like constantly asking, “Do you have something new for me?” even where there might not be any update.    This approach is resource-intensive and inefficient.    Also, you get updates only when you ask for it, thereby missing any real-time information.    However, developers have more control over when and how the data is fetched.    - Webhooks  Webhooks are like having a built-in notification system.    You don’t continuously ask for information.    Instead you create an endpoint in your application server and provide it as a callback to the external service (such as a payment processor or a shipping vendor)    Every time something interesting happens, the external service calls the endpoint and provides the information.    This makes webhooks ideal for dealing with real-time updates because data is pushed to your application as soon as it’s available.    So, when to use Polling or Webhook?  Polling is a solid option when there is some infrastructural limitation that prevents the use of webhooks. Also, with webhooks there is a risk of missed notifications due to network issues, hence proper retry mechanisms are needed.    Webhooks are recommended for applications that need instant data delivery. Also, webhooks are efficient in terms of resource utilization especially in high throughput environments. – Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): https://bit.ly/3KCnWXq #systemdesign #coding #interviewtips .

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories