|
|
|
Fixing the callback spaghetti in node.js
(github.com)
|
|
222 points
by koush
5381 days ago
|
|
node.js is a fantastic platform, but it suffers from your code quickly turning into callback spaghetti and a mess of functions.
I modified the V8 parser to support the await keyword that allows C# to handle this quite elegantly. |
|
I've been using LuaJIT embedded in Nginx (LuaNginxModule). Lua supports coroutines, so a function can just yield. Here's a brief example:
With code like the above I can easily handle into the thousands of concurrent connections per second on the lowest end Linode VPS node available, with barely any load on the box -- and I'm told it should be able to handle 40k+ connections per second, if I were to do any tuning. Oh, and I have only 512Mb of RAM, which it doesn't even get close to under load. And the longest request took less than 500ms at high load.I've been using OpenResty [1] which has the Lua module and a bunch of others all configured together. Works great, and I can't complain about the performance.
Someday I'm sure I'll hand the maintenance of this off, and then I might regret not using one of the "popular" frameworks. But the code is SO straightforward using this stack -- and what I'm using it for is so simple -- I think not.
[1] http://openresty.org/