My CPU overheat when i'm using a mongo tailable cursor with .stream()

Viewed 664

I am trying to use a tailable cursor with stream. We are using mongoose and it works but when I launch my server with this code :

const listStream = ListsSub.find()
  .tailable({
    await_data: true,
    numberOfRetries: -1,
  })
  .stream();

my CPU is overheating.

Activity Monitor when code is active

enter image description here

Commentating the .stream() make the server runs great again.

Activity Monitor when the code is in commented

enter image description here

I don't really know how to do without it. Is it something with my code ? Anyone experienced the same problem ?

EDIT :

  • mongoose : 4.11.3
  • mongodb : 3.4.6
  • node : 8.1.2
  • Server and mongodb on the same machine
2 Answers

I am using mongooseV5.9.2 and I needed to add below way to fix the issue

let options = { tailable: true, 
                awaitData: true, 
                numberOfRetries: -1, 
                tailableRetryInterval: 200
              };
    collection.find().cursor(options);
Related