I am new to performance optimization, and while I recognize Node.js may not be the most beginner friendly place to start, it's the task at hand.
The observation: simple JSON API requests take in the order of hundreds of milliseconds on a staging server with no load and <10 users in the database. Particularly, the call to /api/get_user is taking ~300ms.
To execute this code:
exports.get_user = function(req, res) {
return res.json(req.user)
}
(Note: we store our sessions in Redis)
The stack:
- Node.js
- Express
- Redis
- Mongo
Where do I start?
While it might be an overkill for this small scenario, you might want to consider profiling. I found the nodetime.com service quite useful.