diff --git a/README.md b/README.md index 8abfdc3d..ccce594f 100644 --- a/README.md +++ b/README.md @@ -931,7 +931,7 @@ With it: - Consecutive requests on a connection may run on different threads. - When the [max queued requests](#max-queued-requests) limit is reached, only a connection that has not been served yet (or, with `SSLServer`, has not finished its TLS handshake) is closed. An established one waits for room. -- Each request pays for handing the connection over, so with no more connections than threads and very light handlers, it can serve fewer requests per second. +- Handing the connection over to a worker adds roughly 10-20 µs to each request. It only shows when the client is as near as loopback and the handlers are very light: in our measurements, 2 connections on 2 threads served about a third fewer requests per second over loopback, but only a few percent fewer with a 250 µs round trip. - A handler, a content provider and a WebSocket still hold their thread while they run. - A subclass that overrides the private `process_and_close_socket()` is bypassed. - `SSLServer` runs the TLS handshake on a worker when the client starts it. Until then the connection waits in the event loop and is closed at the keep-alive timeout, not the read timeout, and `ssl_last_error()` is not set for it. diff --git a/docs-src/pages/en/cookbook/s20-keep-alive.md b/docs-src/pages/en/cookbook/s20-keep-alive.md index 445a13a4..95aff5dc 100644 --- a/docs-src/pages/en/cookbook/s20-keep-alive.md +++ b/docs-src/pages/en/cookbook/s20-keep-alive.md @@ -65,7 +65,7 @@ With keep-alive parking, a connection waiting for its next request is handed to What changes with it: - Consecutive requests on one connection may run on different threads, so don't keep per-connection state in `thread_local` variables. -- With no more connections than threads and very light handlers, handing the connection over can lower the requests served per second. +- Handing the connection over to a worker adds roughly 10-20 µs to each request. It only shows with very light handlers and a client as near as loopback. - A handler, a content provider and a WebSocket still hold their thread while they run. The full list is in the [README](https://github.com/yhirose/cpp-httplib/blob/master/README.md#keep-alive-parking). diff --git a/docs-src/pages/ja/cookbook/s20-keep-alive.md b/docs-src/pages/ja/cookbook/s20-keep-alive.md index 5c53b52a..4cedd4f4 100644 --- a/docs-src/pages/ja/cookbook/s20-keep-alive.md +++ b/docs-src/pages/ja/cookbook/s20-keep-alive.md @@ -65,7 +65,7 @@ Keep-Aliveのパーキングを有効にすると、次のリクエストを待 有効にすると変わること: - 同じ接続の連続するリクエストが、別々のスレッドで処理されることがあります。接続ごとの状態を`thread_local`変数に持たせないでください。 -- 接続数がスレッド数以下で、ハンドラがとても軽い場合は、接続の受け渡しのぶん毎秒の処理数が下がることがあります。 +- ワーカーへの接続の受け渡しで、1リクエストあたり10〜20µsほど時間が増えます。目立つのは、ハンドラがとても軽く、クライアントがループバック並みに近いときだけです。 - ハンドラ、コンテンツプロバイダ、WebSocketは、実行中は今までどおりスレッドを占有します。 すべての変更点は[README](https://github.com/yhirose/cpp-httplib/blob/master/README.md#keep-alive-parking)にあります。