Giter Club home page Giter Club logo

Comments (6)

joshlf avatar joshlf commented on June 2, 2024

Come to think of it, spawning goroutines introduces a memory leak risk - an attacker could send requests faster than we can process them, which would result in a large number of goroutines being spawned. The channel supplying the pool with jobs would eventually back up, at which point all of the spawned goroutines would be blocked on sending and unable to die. The reader goroutine would continue reading packets off the connection and spawning goroutines until the system ran out of memory.

from gokeyless.

joshlf avatar joshlf commented on June 2, 2024

I suppose that one approach would be to have a maximum number of outstanding requests (or even just a maximum number of outstanding key lookups) per connection and blocking if you reach that maximum.

from gokeyless.

Bren2010 avatar Bren2010 commented on June 2, 2024

I suppose that one approach would be to have a maximum number of outstanding requests

You could say that the number of workers in the pool is this parameter, so from the latency point-of-view a worker pool is optimal because we don't have to create new goroutines and wait for them to get scheduled.

From a throughput point-of-view: Assuming we want to handle 1,000 req/s (a huge number) and that different workers are truly parallel, then the most expensive operation needs to happen in less than 8 milliseconds. This sounds like a sufficient amount of to me.

If you want to add a metric that somehow measures "typical number of busy/idle worker threads", I think that would valuable for making sure we are using the right model. Although I imagine that 8 workers is more-than-sufficient for now.

from gokeyless.

joshlf avatar joshlf commented on June 2, 2024

You could say that the number of workers in the pool is this parameter, so from the latency point-of-view a worker pool is optimal because we don't have to create new goroutines and wait for them to get scheduled.

This is an interesting thought, although my concern would be that, just like the issue of generating random ECDSA values in the worker threads as opposed to in an idle thread, you'd run the risk that at the moment a request came in, all of the worker threads were in the middle of a long-running (IO-bound, in this case) computation, and so the latency would be high due to waiting for the first one to finish its computation and be ready to process the request.

from gokeyless.

joshlf avatar joshlf commented on June 2, 2024

If you want to add a metric that somehow measures "typical number of busy/idle worker threads", I think that would valuable for making sure we are using the right model.

I'm not sure how that'd be done, but I think it's a good idea.

from gokeyless.

cbroglie avatar cbroglie commented on June 2, 2024

This has proven to be a non-issue in practice

from gokeyless.

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.