0

Moving to other question

Here is final question on this topic. I removed Express from the equationand generally cleared the question.


I have a linked question which is much more detailed, and yet I want to have a question as simple as possible. For this I will omit most the details at all.

Visualize most basic node+express+mongo application. If I give mongo some large async task (large array of tasks), then express (or node? Do not know), stops supplying my users with pages. With debugger help I know that it even does not go inside respected router. Why?

UPDATE 1 From Express logs - seems that when I try to reach http://localhost Node does not push it to express.

UPDATE 2 After few more hours of testing now I can see that there is distinct connection between MongoClient (node driver for mongo) pool size and Node serving pages. When mongo driver takes all his allocated pool in, Node stop serving the pages. Why? And how to fight it?

Amantel
  • 659
  • 1
  • 8
  • 18
  • Does the second request get processed after Mongo finishes thinking? I've had that happen and it turned out my request wasn't actually asynchronous. I fixed it by running the Mongo requests in a timeout. That was a while ago - there might be better ways to do it now. If that's the problem you're having. – theGleep Sep 29 '17 at 16:27
  • Second request to server is procedure with no problems. I'm using async.map to fire my mongo requests (which are handled by nodejs mongo driver) - should that be enough? – Amantel Sep 29 '17 at 16:35
  • IIRC, the issue was that my request to mongo was not async - it was blocking while the http request was active; so I had to move that to a background task. – theGleep Sep 29 '17 at 16:56
  • Nope. Everything async. here :) I double checked to be safe. Please see question update. – Amantel Sep 29 '17 at 17:03
  • Oh! That sounds like a different problem that I've been up against - I can execute ~1500 requests and the DB stops working. I've figured out it's because I'm not closing my connections, but I haven't found a method that I like for doing that. (Even in the documentation examples, `.close()` is called "far away" from where the connection is created.) So I don't *know* that's the issue. – theGleep Sep 29 '17 at 17:07
  • What your mongostats say? Even without any tweaks I can execute ~50000 simple requests without any errors from DB. And even if I do more (100k+) and got errors and everything hangs, after awhile (I think it comes from [link](http://mongodb.github.io/node-mongodb-native/2.2/reference/connecting/connection-settings/)timeout) I can query the DB from shell – Amantel Sep 29 '17 at 17:14
  • Honestly, I have no idea ... this was almost a year ago, and I got sidetracked – theGleep Sep 29 '17 at 17:17

0 Answers0