将 linger.ms 保持为 0 的含义
Implications of keeping linger.ms at 0
我们正在使用 kafka 0.10.2.1。文档指定即使缓冲区未满也可以发送缓冲区-
By default a buffer is available to send immediately even if there is additional unused space in the buffer. However if you want to reduce the number of requests you can set linger.ms to something greater than 0.
然而,它也表示生产者将尝试批处理请求,即使延迟时间设置为 0ms-
Note that records that arrive close together in time will generally batch together even with linger.ms=0 so under heavy load batching will occur regardless of the linger configuration; however setting this to something larger than 0 can lead to fewer, more efficient requests when not under maximal load at the cost of a small amount of latency.
直觉上,似乎任何类型的批处理都需要一些延迟时间,而实现延迟时间为 0 的唯一方法是使代理调用同步。显然,将延迟时间保持为 0 似乎不会像阻塞发送调用那样损害性能,但似乎对性能有一些影响。有人可以澄清文档上面所说的内容吗?
文档说,即使您将延迟时间设置为 0,您最终可能会在负载下进行一些批处理,因为添加记录的速度比发送线程可以分派它们的速度要快。此设置正在针对最小延迟进行优化。如果您真正关心的性能衡量标准是吞吐量,那么您会稍微增加逗留时间以进行更多批处理,这就是文档的目的。在这种情况下与同步发送没有太大关系。 More in depth info
使用 linger.ms=0
会尽快发送记录,对于许多请求,这可能会影响性能。通过在 moderate/high 负载上增加 linger.ms
来强制等待一段时间将优化批处理的使用并增加吞吐量。这也取决于记录的大小,批次中的记录大小越大越少(batch.size
默认为 16Kb)。
基本上这是 请求数和吞吐量 之间的权衡,这实际上取决于您的场景,但是立即发送并不能充分利用批处理和压缩(如果启用),我建议 运行 一些具有不同 linger.ms
值的指标,例如 0/5/10/50/200
一般我会建议设置linger.ms > 0
参考文献:
我们正在使用 kafka 0.10.2.1。文档指定即使缓冲区未满也可以发送缓冲区-
By default a buffer is available to send immediately even if there is additional unused space in the buffer. However if you want to reduce the number of requests you can set linger.ms to something greater than 0.
然而,它也表示生产者将尝试批处理请求,即使延迟时间设置为 0ms-
Note that records that arrive close together in time will generally batch together even with linger.ms=0 so under heavy load batching will occur regardless of the linger configuration; however setting this to something larger than 0 can lead to fewer, more efficient requests when not under maximal load at the cost of a small amount of latency.
直觉上,似乎任何类型的批处理都需要一些延迟时间,而实现延迟时间为 0 的唯一方法是使代理调用同步。显然,将延迟时间保持为 0 似乎不会像阻塞发送调用那样损害性能,但似乎对性能有一些影响。有人可以澄清文档上面所说的内容吗?
文档说,即使您将延迟时间设置为 0,您最终可能会在负载下进行一些批处理,因为添加记录的速度比发送线程可以分派它们的速度要快。此设置正在针对最小延迟进行优化。如果您真正关心的性能衡量标准是吞吐量,那么您会稍微增加逗留时间以进行更多批处理,这就是文档的目的。在这种情况下与同步发送没有太大关系。 More in depth info
使用 linger.ms=0
会尽快发送记录,对于许多请求,这可能会影响性能。通过在 moderate/high 负载上增加 linger.ms
来强制等待一段时间将优化批处理的使用并增加吞吐量。这也取决于记录的大小,批次中的记录大小越大越少(batch.size
默认为 16Kb)。
基本上这是 请求数和吞吐量 之间的权衡,这实际上取决于您的场景,但是立即发送并不能充分利用批处理和压缩(如果启用),我建议 运行 一些具有不同 linger.ms
值的指标,例如 0/5/10/50/200
一般我会建议设置linger.ms > 0
参考文献: