𝗣𝗼𝗹𝗹𝗶𝗻𝗴 𝗶𝗻 𝗦𝘆𝘀𝘁𝗲𝗺 𝗗𝗲𝘀𝗶𝗴𝗻
Polling allows a client to get updates from a server. You can compare this to a waiter checking on your food.
Three main methods exist.
Short Polling
The client asks for an update at fixed intervals. If the data is not ready, the server sends an empty response. The client repeats this cycle until the data arrives. This method creates many unnecessary requests.
Long Polling
The client sends a request and the server holds it open. The server only responds when the data is ready. Once the client gets the response, it sends a new request immediately. This creates a near real-time feel. It reduces empty responses compared to short polling.
Event Stream
The client and server open a single connection. This connection stays open until one side closes it. The server pushes data to the client whenever an event happens. This is true real-time communication.
The downside is resource use. The connection occupies a specific port. That port remains unavailable for other tasks until the connection ends.
Your choice depends on your system needs and the trade-offs you accept.
Source: https://dev.to/cibani_joe/polling-in-system-design-ph6