MatthewWid / better-sse

⬆ Dead simple, dependency-less, spec-compliant server-sent events implementation for Node, written in TypeScript.
MIT License
485 stars 14 forks source link

HTTP/2 Support #37

Closed MatthewWid closed 2 years ago

MatthewWid commented 2 years ago

Add support for HTTP/2 servers by conforming to the HTTP/2 Node interface.

strarsis commented 2 years ago

@MatthewWid: Would putting this node app behind a reverse proxy like Traefik add most HTTP/2 advantages? Using HTTP/2 would be worthwhile as the infamous 6 connections per domain issue and other performance issues would go away with HTTP/2.

MatthewWid commented 2 years ago

@strarsis I'm not familiar with Traefik specifically but yes, an HTTP/2 proxy but still an HTTP/1.1 back-end should alleviate that issue.

The connection limit is imposed by the browser, so if your proxy talking to the browser supports HTTP/2 the connection limit will not be an issue. The Node-side can handle as many open connections as your operating system can.

As for performance it should be the same as once the connection is established and the session is open the library is simply writing data to a TCP socket whether you're using HTTP/1.1 or HTTP/2.

I haven't tested this so it's a bit of conjecture on my end, but I'm mostly confident that that should be the case.