What in the hell packages/architecture are you guys using for performant RESTful APIs?
Some background: the organization I work for has begun developing a RESTful API to replace our many Event Management Systems. Our initial prototype looked something like this:
- Node.js
- Express
- Sequelize
This was pretty nice and got us a working prototype fairly quickly. However, we needed to do some authentication, and since we had an existing LDAP server, we chose to use that.
- Node.js
- Express (w/ express-sessions)
- Passport (passport-ldapauth)
- Sequelize
We weren't in love with this (but, in retrospect, I'm willing to reconsider it), so we tried something else. We used JWTs whose payload contained a document UUID in a Couchbase cluster. That document contained session information and user permissions.
- Node.js
- Express
- Passport (jwt, passport-ldapauth)
- Sequelize
It was at this point we finally started doing some load testing with wrk. The results were awful. Response times > 300ms, requests/s < 100 in some cases. We're now stuck and looking for answers:
- Using WebStorm's debugger/spy-js, we saw a lot of CPU time being eaten up by Sequelize's deduplication (a result of the fact that it only wants to send one mega-query per request).
- When we disabled the call to Couchbase, we saw a decent performance improvement, but not much.
We've begun looking into options to remedy this, but we're not sure how to proceed. We know we can't be the only organization in the world using node.js with N:M relations and token-based auth, yet we haven't heard a peep elsewhere about performance. Some options we looked into:
- Abandoning the ORM for a DAO architecture
- Using StrongLoop's Loopback
- Trying a different ORM (Bookshelf, in this case, which somehow performed worse)
I would really like to hear from the node community about this project, common design patterns, and if there's something just patently obvious that we're missing.
Posted Jul 31, 2015, 1:17 PM UTC
We just migrated away from strongloop to Hapi. Give hapi a look.
How is Hapi going to solve his ORM issues?
+1 to this. Been using hapi for a couple of months for a full rewrite of our API. SO happy with their approach to modules.
I was eyeballing Hapi myself. Looked promising. Mind if I ask you what kind of data stores you're using and how you're interacting with them?
If you go the Hapi route, take a look at https://github.com/devinivy/dogwater, it should help a lot here.
To the top. I ran into limitations when using Express, as soon as my application began to take shape and features were being added. So far I'm loving it. Configuration over convention, think of Ruby on Rails, but now it's Javascript with 100% code coverage and perfectly maintained core and plugins.