[ANN] light-router, need some feedback and code review :)

173 views
Skip to first unread message

Leo Oshiro

unread,
Jun 16, 2014, 7:40:00 AM6/16/14
to nod...@googlegroups.com
Hello,

I just finished writing this module called light-router. (https://github.com/herenow/light-router)

After profiling a simple Node.js API with a Redis backend, I noticed my API spent most of its time on the Express.js router. I did some tests, and removing the router layer gave my API an average of 40% more req/sec.

So I decided to write my own router, I know there are already a ton of routers, but they all seemed to have a big overhead :(, compared to Golang routers such as this one that I use.

Here are the Node.js routers I tested. (https://github.com/herenow/node-router-benchmarks)

I'm quite satisfied with the performance my router got, but I never really wrote a router and I'm not sure of what things I may have missed. So any feedback and tips is much appreciated :)

Norman Paniagua

unread,
Jun 17, 2014, 12:28:53 AM6/17/14
to nod...@googlegroups.com
Seems interesting, I saw there some routes that are new for me, but maybe some routers cover so much that you don't need in all your applications and thats the cause of their slow responde, don't see really the code but its a possibility.

Try also koa and their routers, seems to be the next gen framework of the creator of express, will be interesting to see if the performance is better or not.

Regards

Leo Oshiro

unread,
Jun 18, 2014, 4:10:02 PM6/18/14
to nod...@googlegroups.com
Just added a koa benchmark, I know it's not fair to benchmark robust frameworks against simple routers, but I think its good to know the overhead you get when using this frameworks (with nothing in front).

Norman Paniagua

unread,
Jun 18, 2014, 6:26:27 PM6/18/14
to nod...@googlegroups.com
Koa isn't not robust, it depends much on middlewares, just like express but uses generators that give you a nice syntax without the callback hell, but thanks to add!

Prajwal Manjunath

unread,
Jun 23, 2014, 2:19:20 AM6/23/14
to nod...@googlegroups.com
Just curious, how likely is it that the average public application would use only singleton routes? I'm considering the reality of a "--singleton" option that might be added to other more popular routers.

Leo Oshiro

unread,
Jun 24, 2014, 8:34:11 AM6/24/14
to nod...@googlegroups.com
I think its a matter of how you will structure you application, the downside is that you can't create base paths, such as `/home/*` and export it to its parent router. So it kinda breaks the express.js app paradigm.

But I generally prefer creating a file with all my routes and requiring each handler the application will use.
Reply all
Reply to author
Forward
0 new messages