Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPU growth #88

Open
bdfinst opened this issue Jul 12, 2017 · 6 comments
Open

CPU growth #88

bdfinst opened this issue Jul 12, 2017 · 6 comments

Comments

@bdfinst
Copy link

bdfinst commented Jul 12, 2017

Using the default setting, we experienced growth in CPU usage and increasing performance degradation throughout the day. We were forced to add a cron job to bounce the service every 6 hours. When I removed brakes, CPU usage returned to normal.

@awolden
Copy link
Owner

awolden commented Jul 12, 2017

Hi @YamatoMan,

Sorry to hear you are having troubles with Brakes. I haven't seen any rise in CPU usage using brakes in my services, so I would be interested to know more about how it is being implemented in your application. Can you provide some more details on how you are implementing it?

Thanks,

-Alex

@awolden
Copy link
Owner

awolden commented Jul 27, 2017

@YamatoMan Hopefully this message finds you well. I was able to reproduce a very similar issue by instantiating new brakes instances in the request handler for a service. This was causing run away CPU growth as a new circuit breaker instance was being created for every request. I'm not sure if this was causing your issue, but I hope the information might be helpful.

@bdfinst
Copy link
Author

bdfinst commented Jul 28, 2017 via email

@bdfinst
Copy link
Author

bdfinst commented Jul 28, 2017

Here's how we're implementing

function circuitBreakify(fnToWrap) {
    const brake = new brakes(fnToWrap);
    return brake;
}
.
.
.
function getInfoForThing(req, thing) {
    const request = httpHelper.circuitBreakify(getInfoForThingRequest);
    return request.exec(req, thing);
    return getInfoForThingRequest(req, thing);
}

So, we're doing exactly what you said. How would you recommend we implement instead?

Thanks!

@awolden
Copy link
Owner

awolden commented Jul 28, 2017

You will want to create 1 brakes instance for every function you want to circuit break, and stick it in a reference-able spot.

Something like this:

// create each circuit exactly once some where else in your app or module
const circuits = {
  getInfoForThingRequest: new Brakes(fnToWrap);
}

...
...

function getInfoForThing(req, thing) {
    // do not create a circuit per request, instead exec a previously instantiated circuit.
    return circuits.getInfoForThingRequest.exec(req, thing);
}

@bdfinst
Copy link
Author

bdfinst commented Jul 30, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants