Benchmarks for the fastest Node.js routers.
Routers benchmarked:
Benchmarks run on:
Node 13.0.1 / V8 7.8macOS 10.14.6 MojaveIntel Core i7-4770HQ CPU @ 2.20GHz
anumargak x 317,939 ops/sec Β±0.22% (96 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββ
find-my-way x 303,431 ops/sec Β±0.15% (98 runs sampled)
βββββββββββββββββββββββββββββββββββββββββ
koa-tree-router x 299,203 ops/sec Β±0.40% (92 runs sampled)
βββββββββββββββββββββββββββββββββββββββββ
medley-router x 731,206 ops/sec Β±0.37% (88 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
road-runner x 379,953 ops/sec Β±0.17% (88 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
trek-router x 404,003 ops/sec Β±0.16% (94 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Individual route benchmarks
short static - /user
anumargak x 13,418,550 ops/sec Β±0.32% (92 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
find-my-way x 7,423,956 ops/sec Β±0.52% (94 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
koa-tree-router x 8,830,589 ops/sec Β±0.59% (88 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
medley-router x 13,657,344 ops/sec Β±0.37% (96 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
road-runner x 9,825,708 ops/sec Β±0.41% (92 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
trek-router x 9,737,471 ops/sec Β±0.40% (94 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
short static POST - /user
anumargak x 13,628,944 ops/sec Β±0.18% (92 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
find-my-way x 7,454,900 ops/sec Β±0.52% (92 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββ
koa-tree-router x 13,279,207 ops/sec Β±0.22% (92 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
medley-router x 13,642,027 ops/sec Β±0.42% (92 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
road-runner x 16,047,746 ops/sec Β±0.38% (93 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
trek-router x 9,776,729 ops/sec Β±0.28% (94 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
static with query string - /user?foobar
anumargak x 5,358,210 ops/sec Β±1.11% (92 runs sampled)
βββββββββββββββββββββββββββββββββββββββ
find-my-way x 6,808,709 ops/sec Β±0.36% (91 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββ
koa-tree-router x 5,386,480 ops/sec Β±0.26% (92 runs sampled)
βββββββββββββββββββββββββββββββββββββββ
medley-router x 13,653,037 ops/sec Β±0.49% (93 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
road-runner x 8,780,146 ops/sec Β±0.28% (92 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
trek-router x 8,858,060 ops/sec Β±0.38% (94 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
static with common prefix - /users/all
anumargak x 8,649,398 ops/sec Β±0.45% (91 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
find-my-way x 4,436,718 ops/sec Β±0.39% (92 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββββββ
koa-tree-router x 5,356,739 ops/sec Β±0.44% (93 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
medley-router x 9,346,735 ops/sec Β±0.29% (91 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
road-runner x 6,529,986 ops/sec Β±0.43% (89 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
trek-router x 6,467,729 ops/sec Β±0.31% (94 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
long static - /an/unnecessarily/long/nested/route/here
anumargak x 3,226,983 ops/sec Β±0.56% (88 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββββββ
find-my-way x 2,975,908 ops/sec Β±0.44% (94 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββ
koa-tree-router x 2,887,391 ops/sec Β±0.36% (93 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββ
medley-router x 6,867,557 ops/sec Β±0.40% (94 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
road-runner x 5,739,577 ops/sec Β±0.86% (93 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
trek-router x 6,114,939 ops/sec Β±0.42% (94 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
single parameter - /user/:userID
anumargak x 2,759,486 ops/sec Β±0.47% (91 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββββββ
find-my-way x 2,351,232 ops/sec Β±0.18% (95 runs sampled)
ββββββββββββββββββββββββββββββββββββββββ
koa-tree-router x 2,227,398 ops/sec Β±0.57% (94 runs sampled)
ββββββββββββββββββββββββββββββββββββββ
medley-router x 5,853,986 ops/sec Β±0.18% (94 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
road-runner x 3,249,672 ops/sec Β±0.20% (95 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
trek-router x 3,210,247 ops/sec Β±0.69% (96 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
parameter in the middle - /user/:userID/posts
anumargak x 2,030,705 ops/sec Β±0.18% (95 runs sampled)
βββββββββββββββββββββββββββββββββββββββββ
find-my-way x 1,949,817 ops/sec Β±0.39% (92 runs sampled)
ββββββββββββββββββββββββββββββββββββββββ
koa-tree-router x 1,878,921 ops/sec Β±0.21% (90 runs sampled)
ββββββββββββββββββββββββββββββββββββββ
medley-router x 4,911,325 ops/sec Β±0.21% (93 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
road-runner x 2,505,958 ops/sec Β±0.40% (95 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββββββββββ
trek-router x 2,614,672 ops/sec Β±0.44% (92 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
multiple parameters - /user/:userID/posts/:postID
anumargak x 1,270,940 ops/sec Β±0.41% (91 runs sampled)
βββββββββββββββββββββββββββββββββββ
find-my-way x 1,284,966 ops/sec Β±0.22% (95 runs sampled)
βββββββββββββββββββββββββββββββββββ
koa-tree-router x 1,115,409 ops/sec Β±0.17% (92 runs sampled)
βββββββββββββββββββββββββββββββ
medley-router x 3,656,225 ops/sec Β±0.50% (92 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
road-runner x 1,426,953 ops/sec Β±0.43% (93 runs sampled)
βββββββββββββββββββββββββββββββββββββββ
trek-router x 1,669,680 ops/sec Β±0.56% (91 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββ
wildcard - /static/*
anumargak x 1,758,266 ops/sec Β±0.25% (94 runs sampled)
βββββββββββββββββββββ
find-my-way x 2,204,375 ops/sec Β±0.20% (96 runs sampled)
ββββββββββββββββββββββββββ
koa-tree-router x 2,159,931 ops/sec Β±0.43% (93 runs sampled)
ββββββββββββββββββββββββββ
medley-router x 8,322,187 ops/sec Β±0.25% (94 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
road-runner x 3,002,427 ops/sec Β±0.50% (93 runs sampled)
ββββββββββββββββββββββββββββββββββββ
trek-router x 3,348,716 ops/sec Β±0.13% (94 runs sampled)
ββββββββββββββββββββββββββββββββββββββββ
route not found (404) - /not-found
anumargak x 2,013,173 ops/sec Β±0.24% (93 runs sampled)
βββββββ
find-my-way x 10,368,379 ops/sec Β±0.34% (93 runs sampled)
ββββββββββββββββββββββββββββββββββ
koa-tree-router x 7,648,756 ops/sec Β±0.40% (94 runs sampled)
βββββββββββββββββββββββββ
medley-router x 30,306,800 ops/sec Β±0.46% (93 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
road-runner x 9,930,297 ops/sec Β±0.55% (93 runs sampled)
βββββββββββββββββββββββββββββββββ
trek-router x 10,072,998 ops/sec Β±0.60% (93 runs sampled)
βββββββββββββββββββββββββββββββββ
find-my-way x 1,621 ops/sec Β±0.32% (93 runs sampled)
βββββββββββββββββββββββββββββββββββββββ
medley-router x 4,144 ops/sec Β±0.43% (96 runs sampled)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
trek-router x 2,293 ops/sec Β±0.41% (93 runs sampled)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Some routers are not included in these results because they do not support the route structure of GitHubβs API.
To keep the benchmark comparisons fair, the router implementations are normalized to provide approximately the same set of features. The features that are normalized are how the routers handle query strings and params.
Some of the routers handle being passed the URL with the query string intact while others expect the query string to be removed. The query string gets removed in the benchmark for those that require it to be removed (using the routerβs own code when possible).
Most of the routers return matched URL parameters in an object, however, the
main find() function of both koa-tree-router and trek-router returns
parameters in an array. To normalize this, the benchmark includes converting
the array to an object (which is what koa-tree-router actually does in a
different part of its codebase, so that code is used directly in the benchmark).
There are other differences between the routers that cannot be normalized, though these differences generally have a negligible effect on performance. Some of these differences include:
find-my-wayURI-decodes param values; the other routers do not- The routers support different route path features and syntax
find-my-way,@medley/router, andtrek-routersupport static path parts that overlap dynamic path parts (params/wildcards) whileanumargak,koa-tree-router, androad-runnerdo not support thisanumargakandfind-my-waysupport regex matchersroad-runnersupports wildcards in the middle of the route
anumargak,find-my-way, androad-runnersupport versioned routes