Giter Site home page Giter Site logo

Thoughts on backpressure about tower HOT 6 CLOSED

tower-rs avatar tower-rs commented on May 8, 2024
Thoughts on backpressure

from tower.

Comments (6)

carllerche avatar carllerche commented on May 8, 2024 1

tower-balance is the counter example.

In this case, tower-balance holds a set of inner services. When Balance::poll_ready is called, it in turn calls poll_ready on all the inner services. When a request is received, it is dispatched to a ready inner service.

The problem is that poll_ready has been called on all the inner services, which reserves capacity for a request. A request is only sent to one inner service. All the other inner services then have capacity for one request held in limbo, unable to be used for any other service clones. The capacity is not released until those other services are selected to receive requests.

Thoughts @olix0r

from tower.

jonhoo avatar jonhoo commented on May 8, 2024

The proposed and_then solution smells a lot like it could introduce deadlock? Imagine two threads, 1 and 2, which try to call two service in opposite orders. They both reserve the last (/only) slot in their "first" service, and will now wait forever to acquire a slot in the second.

from tower.

carllerche avatar carllerche commented on May 8, 2024

@jonhoo The existing (and really any concurrent code) is at risk of introducing deadlocks. Granted, this makes it a bit easier.

Given that the only other option (that I can think of) is unbounded buffering, I think it is a necessary hazard.

from tower.

jonhoo avatar jonhoo commented on May 8, 2024

Yeah, I mostly raised it because this seems like a pre-made deadlock trap, much like locks are, and should probably be documented as such. That's not to say I think we shouldn't have it β€” we should just make sure that users are aware that this can deadlock.

from tower.

carllerche avatar carllerche commented on May 8, 2024

This is implemented, but we need to document it better.

from tower.

carllerche avatar carllerche commented on May 8, 2024

Closing in favor of the doc meta issue (#33).

from tower.

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.