𝗦𝗲𝘀𝘀𝗶𝗼𝗻 𝟱 𝗦𝘂𝗺𝗺𝗮𝗿𝘆
I studied three ways to handle data updates in system design today.
Short Polling The client sends requests to the server at set times. You set an interval, like 5 seconds. The client asks the server for new data every 5 seconds. This works but wastes many requests.
Long Polling The client sends a request. The server holds that request open until new data arrives. This uses more server resources. It also wastes many active connections.
Server-Side Events The server sends data to the client at regular intervals. In JavaScript, you use the EventSource object. This creates a connection. The server then pushes data to the client automatically.