Performance

Tomasz Janczuk edited this page May 10, 2013 · 4 revisions

Edge.js is 32x faster than a cross-process call

Edge.js allows node.js applications to call CLR code in-process. For heterogeneous applications that have components written in node.js and .NET, edge.js provides an alternative to using cross-process communication mechanisms to exchange data between node.js process and CLR process.

The measurements below compare the latency of a call from node.js to C# made in-process using edge.js and latency of a functionally equivalent cross-process, localhost call over HTTP from a node.js process to a CLR process. In both cases the caller invokes .NET function that returns an instance of a book. The book contains information about the author (first and last name), price (double), availability (boolean), description (long string), and a picture (16KB byte array). To give you an idea of the size of a book, if serialized to JSON it would be about 22KB. You can see the test code here.

For each variation, the latency measurement is making 10,000 sequential calls and computing the average duration of one call given the elapsed time. Results are shown below.

edgejs-performance1

The results show that edge.js call is about 32x faster than an equivalent cross-process call over HTTP. At the same time, edge.js call is about 6x slower than an equivalent call to a JavaScript function. The latter measurement was done for baseline purposes only - if your scenario can be implemented fully in JavaScript, edge.js is not required in the first place.

The measurements were not taken at 100% CPU utilization. With fully saturated CPU they would likely be different (expected even more in favor of edge.js compared to cross-process call). The measurements were taken using node.js 0.8.19 x64 and edge.js 0.7.9 on ThinkPad T430 running Windows 8.