A user can trigger a task that takes approximately 5 seconds. What are the pros and cons of each of the ways to notify him about the response in terms like scalability, memory, resources and performance?
- Websocket
- Polling in order to check if the task is done(maybe every second)
- One request, waiting until the task is finished and then return the result(Long polling).
As I understand, for a longer task Websocket has more advantages, because the initialization overhead is small compared to the duration of the task, but in this case it is different.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…