moleculer: metrics make request 10x times slower
The issue scenario is :
apiGateway.rest -> auth.authorize->demo.welcome->demo.hello
every step is very simple, should only consider network cost.
If i enable metrics: true
in each services process, use about 120ms
total. Buf if i disable metrics
, it only use about 10ms
.
metrics
internal use event broadcast ? Then is should not impact normal performance so badly.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 39 (37 by maintainers)
Commits related to this issue
- add nats noDelay workaround #313 — committed to moleculerjs/moleculer by icebob 6 years ago
After long time digging and testing, i found the reason. I don’t know its
NATS
orNodejs
bug. The Nodejs saidnoDelay defaults to true
, but its not.Just modify this file at:
node_modules/nats/lib/nats.js
After manually add
setNoDelay(true)
, it works fine on ubuntu:test environment:
npm already has a fix for this, you may want to just update and remove the patching.
OK, i will create a dev example file