Search code examples
javascriptnode.jsexpressfaye

Express.js application maxing CPU


I have built an Express.js application, running on Ubuntu with a Intel Xeon CPU E5540 2.53Ghz.

The application uses MongoDB for session storage (express-session-mongo), EJS for view rendering, MySQL for data storage and Faye for internal messaging. All static files are served by Apache on a different port.

It is a real-time application with a lot of long-polling, where Faye helps a lot. It needs to scale up to at least 500 concurrent users, who will be listening to two different long-polling connections each.

The application maxes CPU around 80-100 users though, which causes 500 errors.

Any ideas about what could be the problem or any general advice about how to debug and fix an issue like this?


Solution

  • You need profile your application to find the bottleneck. You can use look or nodetime to collect CPU profile and find hot spots in your code.