At NearForm, we like to scratch our own itch, and we build tools based on the needs of our customers and our own needs as consultants. When David Mark Clements and myself were in London conducting a performance training and consulting engagement with Net-A-Porter, we noticed that the routes which were logging more were the slowest ones. Moreover, disabling logging allowed far greater performance.
We started a quest to assess the cost of logging.
As a format, JSON is easy to process, and at nearForm we favour it as a logging format, so fast JSON logging had to be the goal.
As in any performance consultancy, we establish a baseline considering the simplest express application (we used node v4 throughout this post):
In order to measure this, we will use autocannon, an HTTP/1.1 benchmarking tool inspired by wrk and built in Node.js:
Let’s see what happens when we add logging (in all the following example, we will be redirecting the output from stdout to
We would expect this to have similar throughput to the first one. However we got some surprising results:
Running a server using bunyan for logging will reduce throughput by almost 80%. Winston yields slightly better results:
Running a server using Winston (version 2) for logging will slow you down by at least 50%.
As part of our consultancy, Dave and myself were asked for a fast alternative, and there wasn’t one. Therefore we set ourselves to the task of writing the fastest possible Node.js logger we could manage. We wanted to build something that could easily replace Winston, Bunyan (or even Bole).