GithubHelp home page GithubHelp logo

Comments (10)

DnOberon avatar DnOberon commented on May 30, 2024

I'm seeing a similar issue running inside k8s, but it doesn't matter on the interval - I get an extremely high cpu usage spike every time it runs. I could just be doing something stupid in the jobs but I figured you'd be able to spot that quickly if so.

Job(s) initialized here: https://github.com/idaholab/Deep-Lynx/blob/master/src/main.ts#L33
Job(s) in question: https://github.com/idaholab/Deep-Lynx/blob/master/src/jobs/data_staging_emitter.ts , https://github.com/idaholab/Deep-Lynx/blob/master/src/jobs/edge_queue_emitter.ts

from bree.

brenc avatar brenc commented on May 30, 2024

I've noticed this too even with 5s interval jobs. Bree spikes to > 100% CPU on each run (running the job manually doesn't do this).

from bree.

shadowgate15 avatar shadowgate15 commented on May 30, 2024

Would one of you be willing to give us a basic repo that reproduces this with the Dockerfile in it? We haven't seen this on our servers and it doesn't seem to happen on my local setup even when running in Docker.

from bree.

brenc avatar brenc commented on May 30, 2024

Sure, I'll try to whip something up this week.

from bree.

brenc avatar brenc commented on May 30, 2024

https://github.com/brenc/bree-issue-201-demo

I set up a simple job that only connects to redis and prints to the console. This causes bree to consistently use 10-20% CPU. Let me know if you need anything else.

from bree.

brenc avatar brenc commented on May 30, 2024

Just added a DNS query and web requests to mimic the original job. The job runner is now using 18-38+% CPU.

You can use the run.sh command to run the project (or just copy the compose command out of there).

bree-cpu-usage

from bree.

shadowgate15 avatar shadowgate15 commented on May 30, 2024

Thanks for putting this together. Since the job is running so frequently, the cpu usage will consistently be relatively high since every second you will incur the resource usage of building a new worker. One thing to keep in mind, specifically with Docker, is that the cpu's are limited by docker itself, so depending on your settings that could be 18-38% of one core.

I would suggest for tasks like these to define a long running job and use something like p-queue to run the task on an interval.

from bree.

shadowgate15 avatar shadowgate15 commented on May 30, 2024

There might be a better way for us to handle this in Bree using a worker pool, but I will have to think on it some more.

from bree.

brenc avatar brenc commented on May 30, 2024

That seems reasonable. A loop with a sleep would probably suffice as well. Thanks!

I'll keep this open in case you want to do anything more with it.

from bree.

titanism avatar titanism commented on May 30, 2024

Yes, this is a code structure problem. You should be using something like p-queue and definitely not spawning a new worker thread every 1s. You should spawn a long running worker that then runs setInterval or something else in serial once high intense CPU operations are complete. See https://github.com/sindresorhus/promise-fun for more packages like p-queue.

from bree.

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.