Monday, 15 May 2017

When is delay too large for choosing synchronous calculation in NodeJS?

I am writing a node.js addon to perform some cryptographic computation, which may take about 1 μs – 20 μs. Now I have a choice: implement this as a synchronous or as an asynchronous method (which does the computation on a background worker)?

It is obvious that network and I/O, which sometimes takes longer than a millisecond should be done asynchronously. Parsing JSON input is fast and should be done synchronously.

In my situation keeping the latency low is important, but optimizing away microseconds feels a lot like premature optimization. So with this context in mind I would be interested to get your view on the question:

When using node.js, how long does a (synchronous) call have to block until you decide to run it asynchronously on a background thread?



via Daan Sprenkels

No comments:

Post a Comment