mod_h2
mod_h2 copied to clipboard
mod_http2: TLS throughput/record sizes
Current implementation of mod_http2
buffers output to manage desired TLS record sizes. This achieves much better throughput than passing frame meta data and resource data down the connection filters unchanged.
To illustrate the problem: serving response bodies using Apache's bucket brigades gives a small 9/10 bytes frame header bucket, followed by a larger bucket with the frame data (often 16 KB) and an optional bucket with padding bytes. Rinse and repeat.
Existing mod_ssl
connection filters try to coalesce small buckets into larger ones for more efficiency, but are unable to manage a chain of 9+16K+9+16k+... But small TLS record sizes produce too much overhead. Copying all data into larger buffers and sending those give currently better performance. But the copying should be optimized to look at the bucket patterns and only copy data when necessary for better TLS record sizes.
This should be implemented as part of a new connection output filter in mod_ssl
and replace the implementation in mod_http2
. This would then also benefit http/1.1 connections.
Existing
mod_ssl
connection filters try to coalesce small buckets into larger ones for more efficiency, but are unable to manage a chain of 9+16K+9+16k+... But small TLS record sizes produce too much overhead. Copying all data into larger buffers and sending those give currently better performance. But the copying should be optimized to look at the bucket patterns and only copy data when necessary for better TLS record sizes.
I wasn't aware this was a problem for mod_http2
as well; the buffering done in h2_conn_io.c exists to mitigate this problem?
The mod_ssl coalesce filter was made smarter on trunk but still won't cope with cases like 9+16K+9+16K. Will ponder this one.
Yes, I measured it and it was quite a difference. However I was not certain about changing the ssl filters and thus introduced the buffering.
This is a very h2 specific pattern, so if you do not find a good way to do it in a generic way, it should be fine.