awolden / brakes

Hystrix compliant Node.js Circuit Breaker Library
MIT License
300 stars 35 forks source link

Runaway memory growth/CPU utilization #94

Closed marksteele closed 6 years ago

marksteele commented 6 years ago

Hi,

I've implemented brakes in a Lambda function in AWS, and have seen a gradual performance degradation over the course of about an hour.

We can observe the lambda running slower and slower up until a point where it takes about 10-30 seconds for it to execute, whereas on a fresh startup, requests are processed within a few milliseconds.

Memory consumption appears to increase linearly.

Our usage looks like this:

class Foo extends Service {

    init(stuff) {
        return super.init(stuff)
        .then(res => {
            this.getFooCB = new Brakes(
                 this.getFoo.bind(this), // Bind the scope, or won't have access to class vars
                 {
                     circuitDuration: 15000,
                     timeout: 10000,
                     waitThreshold:0 // After how many requests should we check?
                 });            
        });
    }

   getFoo(stuff) {
      // do some async thing
   }

  useFoo() {
    return this.getFooCB.exec(stuff).then(res => {...});
  }
awolden commented 6 years ago

Hey @marksteele. It looks like you closed this right away. Is this still an issue? Looking at the code, I would be concerned that maybe you are calling init and instantiating a new brakes instance on every request.