Using cluster in an Expressjs app

前端 未结 3 1948
天命终不由人
天命终不由人 2021-01-31 21:07

I\'m doing a little OJT on my first node project and, while I can stand up a simple server, the app is going to get hammered so using cluster seems like a good idea. I\'ve cobbl

3条回答
  •  [愿得一人]
    2021-01-31 21:37

    Also take a look at cluster2. It's used by eBay and has an express example

    var Cluster = require('cluster2'),
        express = require('express');
    
    var app = express.createServer();
    
    app.get('/', function(req, res) {
      res.send('hello');
    });
    
    var c = new Cluster({
      port: 3000,
    });
    
    c.listen(function(cb) {
      cb(app);
    });
    

提交回复
热议问题