Project

General

Profile

Feature #45306

Feature #50320: mgr/dashboard: Lean Dashboard

mgr/dashboard: asynchronous back-end: Use HTTP2 or websockets

Added by Stephan Müller over 1 year ago. Updated 3 months ago.

Status:
New
Priority:
Normal
Category:
General
Target version:
-
% Done:

0%

Source:
Tags:
Backport:
Reviewed:
Affected Versions:
Pull request ID:

Description

In order to determine what we want to use in future. I will compare both HTTP2 and websockets.

First a bunch of information.

Currently we use the protocol HTTP1.1, which only allows one request per connection.

With HTTP2 and websockets it is possible to allow an unlimited amount of request per connection.

What does one request per connection mean? For example a client asks the server for a file, this will open a connection telling the server GET me something, the server will respond and close the connection. As our dashboard does not only consist of one file, a lot of connections are made. To meet the demand of any modern site of so many connections all modern browsers will do 8 connections simultaneously. On every connection also the same header is send.

What does unlimited amount of requests per connection mean? For example a client asks for a (whole) website. The client sends the first request like in HTTP1.1, the server responds with an HTTP1.1 Upgrade header, client and server negotiate which protocol to use (handshake). A connection is established and left open for requests. The client sends requests for multiple files while the server already responds with the files. This maxes out the established connection, as both participants can send at the same time (for example a video chat). As the connection is left open the server can PUSH data to the client even if he had not explicitly asked for (removes polling). To save data, only the headers during the handshake are send, they will not be send multiple times.

Whats the difference between HTTP2 (released as standard 2015) and websockets (released as standard 2011)?
Both only need one connection. Websockets can run insecure using port 80 and both can run secure using port 443. Websockets use a different URL prefix ws:// for insecure connections or wss:// for secure ones, HTTP2 uses only https:// as prefix. If HTTP2 is used data will automatically be compressed and the handshake is easier to implement than with websockets.

Sure HTTP2 is the better one as the protocol is much newer, but can we use it with cherrypy?
Currently I only found a plugin for cherrypy to allow websockets.
I've not found one for HTTP2 yet but I'm still collecting information.

History

#1 Updated by Ernesto Puerta 8 months ago

  • Project changed from mgr to Dashboard
  • Category changed from 132 to General

#2 Updated by Ernesto Puerta 3 months ago

  • Parent task set to #50320

#3 Updated by Ernesto Puerta 3 months ago

Avan suggested exploring the use of Server-sent Events:

Limitations:
  • Max 6 EventSources for each domain in major browsers (Chrome and Firefox) in HTTP 1.1. This will improve with HTTP/2, but Cherrypy doesn't support it.
  • MIME type is plaintext and most JSON parsers don't play with streamed JSON objects.

#4 Updated by Ernesto Puerta 3 months ago

  • Subject changed from mgr/dashboard: Use HTTP2 or websockets to mgr/dashboard: asynchronous back-end: Use HTTP2 or websockets

#5 Updated by Avan Thakkar 3 months ago

I'm adding some basics of SSEs https://www.html5rocks.com/en/tutorials/eventsource/basics/
and I think they can be useful(over web-sockets) for use-cases like alerts/notifications or maybe cluster health status which are just some events/updates server can push to client.

Also available in: Atom PDF