Bird
0
0

Which of the following is the correct way to create a cluster in Node.js?

easy📝 Syntax Q12 of 15
Node.js - Cluster Module
Which of the following is the correct way to create a cluster in Node.js?
Aconst cluster = require('cluster'); cluster.fork();
Bconst proxy = require('proxy'); proxy.create();
Cconst http = require('http'); http.listenCluster();
Dconst cluster = require('cluster'); cluster.createServer();
Step-by-Step Solution
Solution:
  1. Step 1: Recall Node.js cluster module usage

    The cluster module is required with require('cluster') and workers are created with cluster.fork().
  2. Step 2: Check other options for correctness

    There is no proxy module by default, http.listenCluster() and cluster.createServer() are invalid methods.
  3. Final Answer:

    const cluster = require('cluster'); cluster.fork(); -> Option A
  4. Quick Check:

    cluster.fork() creates workers [OK]
Quick Trick: Use cluster.fork() to create workers in Node.js [OK]
Common Mistakes:
  • Using non-existent methods like cluster.createServer()
  • Confusing proxy module with cluster
  • Trying to call listenCluster() on http

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes