What is event-driven REST and when do you use webhooks vs SSE vs WebSockets?

Answer

Three push mechanisms serve different needs. Webhooks: the server POSTs to a client-registered URL when events occur. Best for: event notifications where the client does not need to be actively connected, server-to-server integrations (Stripe, GitHub, Shopify). Drawbacks: clients must expose a public endpoint, and delivery failures need retry logic. Server-Sent Events (SSE): the server streams newline-delimited JSON events over a long-lived HTTP connection (Content-Type: text/event-stream). Best for: one-way server-to-browser push (live feeds, progress bars, notifications). SSE works over standard HTTP/1.1, is automatically reconnecting, and is natively supported by browsers via EventSource. Drawback: HTTP/1.1 limits to 6 connections per domain. WebSockets: full-duplex bidirectional communication over a persistent TCP connection. Best for: real-time collaborative applications (live chat, multiplayer games, collaborative editing) where both client and server need to send messages. Drawback: more complex infrastructure (requires WebSocket-aware load balancers and sticky sessions or pub/sub backend).