The baby names analyzer is used to demonstrate the abilities of performance tuning and benchmarking in node.js.
- provides count of names beginning with a certain prefix
- eslint
The goal is to run three different experiments on how to tune the performance of this simple application. 0. Establish baseline of initial implementation.
- Add a cache for the data lookup. Baseline.
- Try re-writing the processing logic for the filter using
map
andreduce
. Baseline. - See if adding a data structure would improve performance further. Baseline.
Sample baselines can be found under /performance-metrics
.
npm i
- Ensure that
autocannon
is installed (npm i -g autocannon
). This tool is used for load testing. - Ensure that
0x
is installed (npm i -g 0x
). This tool captures flamegraphs for performance tuning.
- Set
NODE_ENV=production npm start
to begin the application in production mode. There are some times production optimizations in node. The application is now started. - Run the autocannon tool to establish a baseline for performance:
autocannon -c 100 http://localhost:3000/filter?prefix=a
- Run the application using
0x
:NODE_ENV=production 0x index.js
- Run the autocannon tool:
autocannon -c 100 http://localhost:3000/filter?prefix=a
- Send a SIGEXIT when the autocannon process is complete:
Ctrl+C
From Government Catalog
- columns in data set:
- Year of Birth
- Gender
- Ethnicity
- Child's First Name
- Count
- Rank