Giter VIP home page Giter VIP logo

Comments (8)

alimoeeny avatar alimoeeny commented on July 16, 2024

Does this have a measurable impact on performance? or memory use? I guess the actual HTTP connections to S3 servers are closed after each call on the sever side, right?

from goamz.

kixelated avatar kixelated commented on July 16, 2024

It's difficult to benchmark because of S3's performance fluctuations, but the theory is that reusing connections will reduce latency on subsequent requests.

The documentation says: The Client's Transport typically has internal state (cached TCP connections), so Clients should be reused instead of created as needed.

http://golang.org/pkg/net/http/#Client

from goamz.

bmatsuo avatar bmatsuo commented on July 16, 2024

It's possible that this is significant/measurable for HTTPS communication (all requests from the s3 package are HTTPS, yes?). AFAIK each connection will initiate a new TLS handshake. The handshake involves back and forth communication that (in my experiences working with HTTP libraries in other languages) adds a significant amount of time to the request.

from goamz.

bmatsuo avatar bmatsuo commented on July 16, 2024

The Go 1.3 http.Client has a Timeout field that can effectively replace the way ReadTimeout is implemented. If that's changed the http.Client (and its underlying tcp connections) should be reusable across multiple calls to s3.run() (the current implementation appears to have deadlines kick in on subsequent requests using the same underlying tcp connection, closing them and causing an error).

I'm willing to write a patch for this.

from goamz.

alimoeeny avatar alimoeeny commented on July 16, 2024

Go for it man!

from goamz.

bmatsuo avatar bmatsuo commented on July 16, 2024

Cool.

After playing around with it a little yesterday I'm considering removing the ConnectTimeout and ReadTimeout fields from S3 and replacing them with a public *http.Client field. That would also allow a proper workaround for #127.

I think it's ok. Implementing the timeouts in 1.3 is more straightword than what is being done currently. The net.Dialer type can be used now that SetDeadline isn't needed.

&http.Client{
    Transport: &http.Transport{
        Dial: (&net.Dialer{
            Timeout:   connect,
            KeepAlive: 30 * time.Second,
        }).Dial,
    },
    Timeout: read,
}

There could be a public function in the s3 package that constructs and returns a client like above. I don't have a very strong opinion about that.

How does this sound?

from goamz.

bmatsuo avatar bmatsuo commented on July 16, 2024

ping @alimoeeny

I have been thinking, instead of doing what I described above, the exported API could stay the same (with timeout fields and an unexported http client) if the methods I suggest in #169 are introduced. It allows the user to completely bypass the http client used by the S3 type. IMO, this is also an acceptable workaround for #127. At the moment I'm leaning toward this solution because it is backwards compatible.

Unless there are other ideas I will start forming a pull request implementing these changes.

from goamz.

alimoeeny avatar alimoeeny commented on July 16, 2024

Thanks @bmatsuo ,
IMHO, keeping things backward compatible is very important.
If we can have a default behavior that is good enough for the majority, which could be overridden when somebody needs better performance or finer control, that would be the best.
Thanks again,

from goamz.

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.