Node.js ट्यूटोरियल

Node.js होम Node.js परिचय Node.js प्रारंभ करें Node.js मॉड्यूल Node.js HTTP मॉड्यूल Node.js फ़ाइल सिस्टम Node.js URL मॉड्यूल Node.js एनपीएम Node.js घटनाएँ Node.js फ़ाइलें अपलोड करें Node.js ईमेल

Node.js MySQL

MySQL प्रारंभ करें MySQL डेटाबेस बनाएँ MySQL तालिका बनाएँ MySQL सम्मिलित करें MySQL से चुनें MySQL कहाँ MySQL ऑर्डर बाय MySQL हटाएं MySQL ड्रॉप टेबल MySQL अद्यतन MySQL सीमा मायएसक्यूएल जॉइन

Node.js MongoDB

मोंगोडीबी आरंभ करें MongoDB डेटाबेस बनाएँ MongoDB संग्रह बनाएँ मोंगोडीबी डालें मोंगोडीबी खोजें मोंगोडीबी क्वेरी मोंगोडीबी सॉर्ट मोंगोडीबी हटाएं MongoDB ड्रॉप संग्रह मोंगोडीबी अपडेट मोंगोडीबी सीमा मोंगोडीबी शामिल हों

रास्पबेरी पाई

रासपी आरंभ करें रासपी जीपीआईओ परिचय रासपी ब्लिंकिंग एलईडी रासपी एलईडी और पुशबटन रासपी बहने वाली एल ई डी रासपी वेबसाकेट रासपी आरजीबी एलईडी वेबसाकेट रास्पी अवयव

Node.js संदर्भ

अंतर्निहित मॉड्यूल

Node.js क्लस्टर प्रक्रिया मॉड्यूल

अंतर्निहित मॉड्यूल


उदाहरण

कोड को तीन बार चलाएं, पहली बार मास्टर के रूप में, फिर श्रमिकों के रूप में:
var cluster = require('cluster');

if (cluster.isWorker) {
  console.log('I am a worker');
} else {
  console.log('I am a master');
  cluster.fork();
  cluster.fork();
}

परिभाषा और उपयोग

क्लस्टर मॉड्यूल चाइल्ड प्रोसेस बनाने का एक तरीका प्रदान करता है जो एक साथ चलता है और एक ही सर्वर पोर्ट साझा करता है।

Node.js सिंगल थ्रेडेड प्रोग्रामिंग चलाता है, जो बहुत मेमोरी कुशल है, लेकिन कंप्यूटर मल्टी-कोर सिस्टम का लाभ उठाने के लिए, क्लस्टर मॉड्यूल आपको आसानी से चाइल्ड प्रोसेस बनाने की अनुमति देता है, जो लोड को संभालने के लिए प्रत्येक अपने सिंगल थ्रेड पर चलता है।


वाक्य - विन्यास

आपके आवेदन में क्लस्टर मॉड्यूल को शामिल करने के लिए सिंटैक्स:

var cluster = require('cluster');

क्लस्टर गुण और तरीके

Method Description
disconnect() Disconnects all workers
exitedAfterDisconnect Returns true if a worker was exited after disconnect, or the kill method
fork() Creates a new worker, from a master
id A unique id for a worker
isConnected Returns true if the worker is connected to its master, otherwise false
isDead Returns true if the worker's process is dead, otherwise false
isMaster Returns true if the current process is master, otherwise false
isWorker Returns true if the current process is worker, otherwise false
kill() Kills the current worker
process Returns the global Child Process
schedulingPolicy Sets or gets the schedulingPolicy
send() sends a message to a master or a worker
settings Returns an object containing the cluster's settings
setupMaster() Changes the settings of a cluster
worker Returns the current worker object
workers Returns all workers of a master

अंतर्निहित मॉड्यूल