Code Monkey home page Code Monkey logo

Comments (7)

joe-elliott avatar joe-elliott commented on May 25, 2024 1

I have tested 0.4.0 on a http2 connection to www.google.com and with the gcs client. Worked like a charm with both.

Thank you for the work on this πŸ™

from hedgedhttp.

cristaloleg avatar cristaloleg commented on May 25, 2024

Thank you for filling this issue, I'm not a big pro of net/http internals, so cannot answer so quickly, that's why I'm not sure about which path is the best.

There is #6 which removes context cancelling at all (we just use original context inside request, without creating own), but also there is a sub-context in closure for runInPool and maybe the problem will be triggered there.

Sadly I don't have good bench/project/whatever where I can test it under real load (btw, can you share how much requests do you make when this problem appears?) and trying to debug in head and docs.

from hedgedhttp.

cristaloleg avatar cristaloleg commented on May 25, 2024

Also, jumping through the link from original PR I've found a thread on Google Groups, slightly changing the code I got something like this https://play.golang.org/p/iV2UMxZGPtr (you need to run it locally, url doesn't matter, feel free to change).

Locally this 'sometimes' appears to be 'always' πŸ‘€

from hedgedhttp.

joe-elliott avatar joe-elliott commented on May 25, 2024

I like the change in #6, but I think that we will need an optional cancel like was originally proposed. After you merge #6 I'll submit a PR for the optional cancel.

from hedgedhttp.

cristaloleg avatar cristaloleg commented on May 25, 2024

@joe-elliott idea is to cancel the context outside of the hedgehttp.

ctx, cancel := context.WithCancel(otherCtx)
defer cancel()

req := <create desired request>
req = req.WithContext(ctx)

// do hedgedhttp request
// read the body if it's present

// invoke cancel() here

In this way we're getting response, reading the body, canceling a context (it's scope is just to contain hedging), had a discussion with @storozhukBM yesterday, it may be slightly sub-optimal because we're not closing hanging requests as fast as possible, but it's a matter of 'how long do you process' the successfully received response.

I'm super eager to check how does #6 behaves in your situation and if it doesn't fix it, we can add optional cancelling or even cancelling failed requests manually (more code and more responsibility).

from hedgedhttp.

cristaloleg avatar cristaloleg commented on May 25, 2024

So, https://github.com/cristalhq/hedgedhttp/releases/tag/v0.3.0 is available, please test it πŸ˜‰

from hedgedhttp.

cristaloleg avatar cristaloleg commented on May 25, 2024

So, #9 has landed. Please try it https://github.com/cristalhq/hedgedhttp/releases/tag/v0.4.0 :)

from hedgedhttp.

Related Issues (9)

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.