Our mission is to compare the node.js frameworks on performance (completed no of requests per second).
Node.js performance tests were performed on the Ubuntu subsystem(2 core , 2 GB RAM) on a VM provisioned from Digital Ocean. The tests only utilize the most basic capabilities of the frameworks in question, therefore the main goal was to show the relative overhead these frameworks add to the handling of a request. This is not a test of the absolute performance as this will vary greatly depending on the environment and network conditions. This test also doesn’t cover the utility each framework provides and how this enables complex applications to be built with them.
We are doing followings three transactions in each request
- create document in db .
- fetch the same document from db and add new fields and update the document
- update the document’s three field in an audit trail document (nested array)
we are also doing mulptile logging in each transactions.
Data base is mlab data base hosted in same data center where the VM is hosted.
connection string(poolsize etc.) are same for each framework.
There are no caching involved while testing for any of the framework.
Node.js version 6.9 has been used to all three framework.
We are comparing 4 frameworks
- hapi+ mongoose
- express + mongoose
- native(http + mongodb driver for node.js)
We taking following scenarios for each of the framework and comparing them
- single small document(each document size 5 kb)
- single big document(document size 200 kb)
- 100 small documents (each document 5 kb)
- 100 big documents(each document 200 kb)
Understanding the results:-
- Every framework add significant overhead as compare to native calls
- on bigger documents (heavy load) this difference become less significant because operations on the load size negates the overhead
- on small documents both express and node-data outshines the hapi.
- for a single document(small or big) express and node-data are almost equal
- on multiple documents(small),node-data completely outshines both express and hapi and closer to native
- on multiple documents(big size),node-data is performing 4-5 time better than both express and hapi and closer to native
How node-data achieve the performance improvements :-
1.in node-data we make sure that once a document is fetched from DB we don’t do any serialization/transformation over db objects and pass it to application middle wares as it is.
2.we also improve the native db driver code , so it doesn’t impose any performance penalty
3. for multiple documents creation, fetch and update , we have special bulk operations which provide a right balance to batch size and no of concurrent calls to DB.
If you want to know more about node-data check out the our github
Or visit our main page
If you want to try out your self , check out this template
For step by step creation of first node-data application follow this blog.