Skip to content

HTTP/2 write buffering

Artem Boldariev requested to merge artem-http-write-buffering into main

This MR adds the ability to consolidate HTTP/2 write requests if there is already one in flight. If it is the case, the code will consolidate multiple subsequent write request into a larger one allowing to utilise the network in a more efficient way by creating larger TCP packets as well as by reducing TLS records overhead (by creating large TLS records instead of multiple small ones).

This optimisation is especially efficient for clients, creating many concurrent HTTP/2 streams over a transport connection at once. This way, the code might create a small amount of multi-kilobyte requests instead of many 50-120 byte ones.

In fact, it turned out to work so well that I had to add a work-around to the code to ensure compatibility with the flamethrower, which, at the time of writing, does not support TLS records larger than two kilobytes. Now the code tries to flush the write buffer after 1.5 kilobyte, which is still pretty adequate for our use case. There is a separate MR which addresses that.

Essentially, this commit implements a recommendation given by nghttp2 library:

https://nghttp2.org/documentation/nghttp2_session_mem_send.html

Edited by Artem Boldariev

Merge request reports