Which is better? Having 1000 clients using SSE to talk with server or Ajax polling by 1000 clients to the server

StackOverflow https://stackoverflow.com/questions/18985051

Frage

I am beginning to learn AJAX and SSE. Performance wise which method would be considered better? Assume my application will cater to 1000 clients.

  1. Having Server sent events which keep 1000 http connections open for one way communication to push updates to the clients.

    or

  2. Having the clients implement ajax polling for every 1 second to the server.

War es hilfreich?

Lösung

You do not want to have each client poke your server every 1 second. Just make the math: 1000 requests every second. As soon as one of the request starts taking more than 1 second, you will slowly start to launch a Denial of Service on your own server.

I don't know if you are in the ASP.NET environment for the server, but if you are, I suggest that you take a look at the SignalR library.

A typical demo app for SignalR is a chat program. See ChatJS or Jabbr.

You can follow this tutorial to learn more about SignalR.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top