Monday 29 May 2017

Why does installing bufferUtil and utf-8-validate drastically improve performance of the WS websocket library in Node.js?

While reading through the documentation for the WS websocket library, I noticed the following statement:

There are 2 optional modules that can be installed along side with the ws module. These modules are binary addons which improve certain operations. Prebuilt binaries are available for the most popular platforms so you don't necessarily need to have a C++ compiler installed on your machine.

npm install --save-optional bufferutil: Allows to efficiently perform operations such as masking and unmasking the data payload of the WebSocket frames.
npm install --save-optional utf-8-validate: Allows to efficiently check if a message contains valid UTF-8 as required by the spec.

Sure enough, installing these modules gave me drastically better performance. My question is: why do they make such a huge difference? What about them makes the library so much faster? Is it because they were written in C++?



via dalanb

No comments:

Post a Comment