WebSocket vs Polling connection
Difference between websocket and polling connection
Source: https://www.youtube.com/watch?v=IVhwW1JkULo&t=749s
WebSockets are used in real-time connections when the frontend and backend are constantly exchanging data in both directions, such as when a real-time system requires consistent communication back and forth.
If you utilize a serverless stack, setting up websockets will be difficult since serverless apps do not have a long enough lifespan to send responses and maintain the server connection alive. Serverless is short-lived; you generate it and then kill it.
Polling can be used when we simply want a one-time response.
Example: polling