-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-Use Connections When Publishing to the Aggregator #51
Comments
The Connection Reuse section of the Everything curl book explains how this works: https://everything.curl.dev/libcurl/connectionreuse > When you are using the easy API, or, more specifically, curl_easy_perform(), > libcurl will keep the pool associated with the specific easy handle. Then > reusing the same easy handle will ensure it can reuse its connection. Before, in the `HttpClient::perform` method, a new curl handle was created upon every invocation, which meant that there was no opportunity to reuse connections from the underlying connection pool. By making the curl handle static, it ensures that the same one remains in use, thus providing the means to reuse the established connection pool. Fixes Netflix-Skunkworks#51.
The
The
https://curl.se/libcurl/c/libcurl-tutorial.html
https://everything.curl.dev/libcurl/connectionreuse
https://curl.se/libcurl/c/threadsafe.html
https://stackoverflow.com/a/44740820
https://curl.se/libcurl/c/libcurl-multi.html
https://www.onlineaspect.com/2009/01/26/how-to-use-curl_multi-without-blocking/
Given this behavior, it's not quite clear how it is possible to have CLOSE_WAIT connections stacking up as described in #68. Unless the Possible solutions:
|
Originally, in the `HttpClient::perform()` method, a new `CurlHandle` was created upon every invocation, leading to subsequent calls to `curl_easy_init()` and `curl_easy_cleanup()`, as the variable went in and out of scope while it executed on the `asio::thread_pool`. This meant that there was no opportunity to reuse connections from the underlying connection pool, because it was always cleaned up. By marking the `CurlHandle` with the `thread_local` storage duration, it ensures that the same one remains in use for each thread, thus providing the means to reuse the established connection pool. Fixes Netflix-Skunkworks#51.
Originally, in the `HttpClient::perform()` method, a new `CurlHandle` was created upon every invocation, leading to subsequent calls to `curl_easy_init()` and `curl_easy_cleanup()`, as the variable went in and out of scope while it executed on the `asio::thread_pool`. This meant that there was no opportunity to reuse connections from the underlying connection pool, because it was always cleaned up. By marking the `CurlHandle` with the `thread_local` storage duration, it ensures that the same one remains in use for each thread, thus providing the means to reuse the established connection pool. Fixes Netflix-Skunkworks#51.
Originally, in the `HttpClient::perform()` method, a new `CurlHandle` was created upon every invocation, leading to subsequent calls to `curl_easy_init()` and `curl_easy_cleanup()`, as the variable went in and out of scope while it executed on the `asio::thread_pool`. This meant that there was no opportunity to reuse connections from the underlying connection pool, because it was always cleaned up. By marking the `CurlHandle` with the `thread_local` storage duration, it ensures that the same one remains in use for each thread, thus providing the means to reuse the established connection pool. Fixes Netflix-Skunkworks#51.
Using the On the MacOS platform (
On the Ubuntu Jammy platform:
Marking some of the Since the In order to control publisher thread access to the HttpClient pool, because the number of batches may exceed the number of threads, and we cannot know how fast each thread will progress, we may need to implement something like an object pool: https://codereview.stackexchange.com/questions/273467/c-thread-safe-object-pool |
This should reduce the overhead per request.
The text was updated successfully, but these errors were encountered: