6 ms·
How efficient is to have an HTTP2 server serving sever-push events to thousands of clients? Better than websockets I assume.
by knocte 9y ago
How efficient is to have an HTTP2 server serving sever-push events to thousands of clients? Better than websockets I assume.
- meritt 9y agoI can't speak for exact performance comparisons but server-push isn't designed for events like SSE or websockets. It's designed for the client to make a request and the server to efficiently responded with multiple payloads to populate a client cache.
- pwdisswordfish 9y agoI'm pretty sure that's not how server push works. Client requests A, then server pushes B and C with A. Server just cannot push something to God knows where.
- deleted 9y ago[deleted]
- stabbles 9y agoServer-Sent Events (SSEs) are actually a thing. Sure, the client must establish a connection with the server first, but from then on data can be streamed from the server. Similar to websockets, but then a one-way connection from server to client.
- k__ 9y agoBut do SSEs have anything to do with HTTP/2 server push?
- techdragon 9y agoThey do not. https://en.m.wikipedia.org/wiki/Server-sent_events https://en.m.wikipedia.org/wiki/Server-sent_events
- manigandham 9y agoDo you mean Server-Sent Events? That's a well-supported and efficient model that'll work fine, although the payload will always be heavier than websockets since all the headers have to be sent, even if compressed within the HTTP/2 stream. It's also not supported on IE or Edge. If you actually mean server-push then that would basically be long-polling and not very efficient, also it's meant to send along assets that the server already knows will be needed for a request (like CSS with the HTML). There's not much client-side API to actually deal with server-push because it's just like another network http request/response.
- rcarmo 9y agoI’m sorry, but when you mention all headers need to be sent, what are you referring to? I have working SSE implementations where I only send out the headers once and then pipe minimal data to the client while the socket is open.
- manigandham 9y agoYou're right, I misspoke. I meant that the "data: " pseudo-header for each SSE message is always included, and repeated for multiple lines (but it's HTTP so can be gzipped). It's also UTF8 encoded and meant for text while websockets can send the exact binary bytes you need and no more. Either way, it doesn't really matter unless it's a latency-sensitive or high-volume service, but I prefer the simplicity of SSE.
- invisible 9y agoYeah, but packets being able to be maximized to the window size of the connection early on (and being able to have more than 6 "parallel" downloads as a result) is great for initial page loads.
- nailer 9y agoWe use SSE for realtime identity verification updates at CertSimple but note it's hampered by lack of support in Edge - looking at Microsoft's roadmap it doesn't look like it's coming soon either.
- akmittal 9y agoIf you mean Server sent events then no, WebSockets are still more performant. I'm ignoring the fact that SSE are not replacement for WebSocket because with SSE we can't send data from client to server.