2

I am new to performance optimization, and while I recognize nodejs 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:

  • Nodejs
  • Express
  • Redis
  • Mongo

Where do I start?

4

2 回答 2

1

虽然对于这个小场景来说这可能有点过头了,但您可能需要考虑进行分析。我发现 nodetime.com 服务非常有用。

于 2013-12-20T07:00:33.160 回答
1

传递–-nouse_idle_notification标志将告诉 V8 忽略来自 Node 的空闲通知调用,这是对 V8 要求它立即运行 GC 的请求,因为 Node 进程当前处于空闲状态。因为 Node 对这些调用非常激进(效率会产生干净的状态),所以过多的 GC 可能会减慢您的应用程序。请注意,使用此标志不会禁用 GC;GC 只是运行频率较低。在适当的情况下,这种技术可以提高性能。

于 2015-10-28T16:48:32.303 回答