𝗘𝘃𝗲𝗻𝘁 𝗦𝘁𝗿𝗲𝗮𝗺, 𝗦𝗵𝗼𝗿𝘁 𝗣𝗼𝗹𝗹𝗶𝗻𝗴, 𝗮𝗻𝗱 𝗟𝗼𝗻𝗴 𝗣𝗼𝗹𝗹𝗶𝗻𝗴
Fetching large amounts of data creates problems for users. If a user waits too long for a response, the experience feels slow. You use different methods to handle these data requests.
Short Polling The client sends requests to the server at fixed intervals. The server responds to each request immediately. It tells the client if new data exists or not. This method uses many resources because of the constant requests.
Long Polling The client sends a request to the server. The server holds the request open until new data arrives or a timeout occurs. This reduces the number of empty responses.
Event Stream (SSE) Large datasets cause long wait times. If you have 100,000 rows of data, sending them all at once is slow. You can improve the user experience by sending data in chunks.
Event Stream works like this:
- The client opens a connection to the server.
- The connection stays open.
- The server sends small parts of data as they become ready.
- The user sees results immediately instead of waiting for the full set.
This method keeps the connection active until the server finishes sending all events. It makes applications feel fast and responsive.
Source: https://dev.to/anubama_i/event-stream-short-polling-long-polling-54n