mint icon indicating copy to clipboard operation
mint copied to clipboard

HTTP2 Waiting for Server Settings increases latency

Open DunyaKokoschka opened this issue 3 years ago • 4 comments

In HTTP2 it is optional for the client to wait for the server settings frame before making requests. However, Mint waits for the server settings frame and this increases the amount of time before Mint is able to make a request. For example if it takes 80ms for a packet to be sent from the server to the client then this increases the latency for the first request by 80ms. If you look at browser implementations like Chrome, Firefox or Safari none of these browsers will wait for the server settings frame before making a request.

DunyaKokoschka avatar Apr 19 '21 11:04 DunyaKokoschka

If we do not wait for server settings, how should Mint.HTTP2.get_server_setting/2 behave if it is called before we received the settings frame?

ericmj avatar Apr 20 '21 14:04 ericmj

If I'm reading the cowlib code correctly here, cowlib returns default values until the server sends a SETTINGS frame.

From - https://tools.ietf.org/html/rfc7540#section-3.5:

To avoid unnecessary latency, clients are permitted to send additional frames to the server immediately after sending the client connection preface, without waiting to receive the server connection preface. It is important to note, however, that the server connection preface SETTINGS frame might include parameters that necessarily alter how a client is expected to communicate with the server. Upon receiving the SETTINGS frame, the client is expected to honor any parameters established. In some configurations, it is possible for the server to transmit SETTINGS before the client sends additional frames, providing an opportunity to avoid this issue.

lukebakken avatar Apr 21 '21 13:04 lukebakken

Great that you found in the specification how to handle this issue.

Do you think we can do this @whatyouhide?

ericmj avatar Apr 22 '21 13:04 ericmj

@DunyaKokoschka please see pull request #318 which implements async settings. Please give the branch a test in your environment. Thanks!

lukebakken avatar Nov 23 '21 21:11 lukebakken