Please enable JavaScript.
Coggle requires JavaScript to display documents.
Node JS (Node Cluster (Node is single threaded and has a memory limit of 1…
Node JS
Node Cluster
Node is single threaded and has a memory limit of 1.5GB allowing it to support thousands of concurrent connections
-
The Cluster module fixes this by forking multiple child processes which communicate with the Parent process
'Master' process controls the workers and all incoming connections and distributed across the workers in a round robin fashion
-
-
-
SSL
-
-
Example
`const https = require('https"), fs = require("fs");
const options = {
key: fs.readFileSync("/path/to/key"),
cert:fs.readFileSync("/path/to/cert")
};
const app = express();
app.use((req,res) => {
res.writehHead(200);
});
app.list(8000);
https.createServer(options,app).listen(443);`
-
Basic Steps: 1.Get .key and .cert and put in project root
- Use https module
https.createServer(credentials,app).listen()
-
Heavy computations
-
Better to deploy tasks as micro services and deploy them asa separate node apps - use message queue like RabbitMQ to communicate with these micro services
-
Reverse Proxy
-
-
Will protect application servers from direct exposure to internet traffic and help scale and load balance traffic
-
-
-
-
-
Debug
Get rid of all console.log statements - will block CPU time and waste resources - use debug module - so unless start your with environment variable DEBUG nothing will be printed to the console
-