Giter VIP home page Giter VIP logo

Comments (8)

bbrowning avatar bbrowning commented on June 25, 2024 1

The section "Repro #2: Create excessive TIME_WAIT connections by exceeding connection pool" at http://tleyden.github.io/blog/2016/11/21/tuning-the-go-http-client-library-for-load-testing/ has a nice description of what's happening here as well. And, it hints that we may need to allow tuning both MaxIdleConns and MaxIdleConnsPerHost. Or, if the Knative use-case of sending lots of CloudEvents to a single host is too specific, we can tune it there instead of here. It just requires some internal knowledge of how cloudevents sdk-go works to tune that in Knative.

from sdk-go.

matzew avatar matzew commented on June 25, 2024

I think the use-case of knative is good, it's still generic enough, and useful for a general "from x to cloudEvent" bridge. that may invoke (public) cloud services, distributing CEs, from internal events (wrapped in CEs)

from sdk-go.

n3wscott avatar n3wscott commented on June 25, 2024

The solution for this would be to set these settings on the http client in the cloudevents http transport object, like:

			t, err := cloudevents.NewHTTPTransport(
				cloudevents.WithTarget(env.Target),
				cloudevents.WithEncoding(encoding),
			)
			t.Client = myHttpClient

from sdk-go.

bbrowning avatar bbrowning commented on June 25, 2024

Thanks - I'll give that a try and close this issue if that works as expected.

from sdk-go.

bbrowning avatar bbrowning commented on June 25, 2024

So, with release 0.4.0 I was able to get acceptable throughput here by tuning the DefaultTransport to raise MaxIdleConnsPerHost. The ability to set a Client (and have that Client actually used for requests) appears to have landed around 0.4.2. However, upgrading to that or newer, I can never get acceptable throughput here.

The issue is

Explicitly telling the client request to close like that means the client is forced to constantly tear down and create new connections, thus leading to resource exhaustion under even moderate load when sending all CloudEvents to a single host. From the net/http docs:

        // Close indicates whether to close the connection after
        // replying to this request (for servers) or after sending this
        // request and reading its response (for clients).
        //
        // For server requests, the HTTP server handles this automatically
        // and this field is not needed by Handlers.
        //
        // For client requests, setting this field prevents re-use of
        // TCP connections between requests to the same hosts, as if
        // Transport.DisableKeepAlives were set.

So, we'll need to track down why we started explicitly asking client requests to close. I'm working on an automated test for this in Knative, but it's more of an integration test since it needs to spin up a webserver and run a sustained throughput against it for at least 30 seconds or more.

from sdk-go.

matzew avatar matzew commented on June 25, 2024

from sdk-go.

n3wscott avatar n3wscott commented on June 25, 2024

Perhaps the issue is on host vs multi-host targets? you want to close for multi, and leave open for a single target?

from sdk-go.

n3wscott avatar n3wscott commented on June 25, 2024

Fixed via #110

from sdk-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.