1
0
mirror of https://github.com/actix/examples synced 2024-11-24 23:02:59 +01:00
examples/other/server-sent-events
2022-02-02 01:44:26 +00:00
..
src Restructure folders (#411) 2021-02-26 00:57:58 +00:00
benchmark.js Restructure folders (#411) 2021-02-26 00:57:58 +00:00
Cargo.toml remove authors 2022-02-02 01:44:26 +00:00
drain.js Restructure folders (#411) 2021-02-26 00:57:58 +00:00
README.md fix broken links (#441) 2021-10-06 22:28:53 +01:00

actix-sse

Example of server-sent events, aka EventSource, with actix web.

cd other/server-sent-events
cargo run

Open http://localhost:8080/ with a browser, then send events with another HTTP client:

curl localhost:8080/broadcast/my_message

my_message should appear in the browser with a timestamp.

Performance

This implementation serve thousands of clients on a 2013 macbook air without problems.

Run benchmark.js to benchmark your own system:

$ node benchmark.js
Connected: 1000, connection time: 867 ms, total broadcast time: 23 ms^C⏎

Error Too many open files

You may be limited to a maximal number of connections (open file descriptors). Setting maximum number of open file descriptors to 2048:

ulimit -n 2048

Test maximum number of open connections with drain.js:

$ node drain.js
Connections dropped: 5957, accepting connections: false^C⏎

Accepting connections indicates whether resources for the server have been exhausted.