4 ms·
For these particular improvements, good implementations of HTTP/1.1 (and HTTP/2) already have these optimisations because HTTP versions before 3 use TCP. With
by jlokier 4y ago
For these particular improvements, good implementations of HTTP/1.1 (and HTTP/2) already have these optimisations because HTTP versions before 3 use TCP.
With TCP, they are mostly done in the kernel and network hardware. TCP syscalls can transfer many packets worth of data per syscall, and the kernel and hardware have done segmentation offloads for TCP for many years automatically, depending on the hardware and kernel version. Over time these optimisations have been improved in the kernel, and over time newer hardware provided more capabilities for the kernel to use.
There's not much need for complex application or library support in userspace, though there are some syscall patterns that help the TCP stack more than others. The main thing is, send and receive in larger sizes to let the kernel handle buffering as well as reducing syscall count. Don't do silly things like a write() syscall for each HTTP header and then the body, for example. Buffer it up into a single write.