September 2020 – Brain Mentors Skip to content


Nginx has a master process and as many worker processes as the admin/user of Nginx wants. Master process manages the worker process. It read the configuration file. It evaluate the configuration file and accordingly update the active services. Now all the incoming requests will be processed by these worker thread. nginx uses event-based model and OS-dependent mechanisms for the requests distribution to worker threads. Basic Nginx Commands Start the Server by running the executable file in Nginx folder. nginx -s stop => for fast shutdown nginx -s quit => for graceful shutdown i.e., first let the worker thread finish the work, who are currently executing and then stop the execution of the server. nginx -s reload => for reloading the configuration file i.e., if changes are made to the configuration file and now they are to be reflected by the nginx server, use reload command. The validity, semantics and syntax of the config


What is RabbitMQ? RabbitMQ is an open-source message-broker software. It has implemented the Advanced Message Queuing Protocol. RabbitMQ works very similar to a post box. The producer i.e., the originator of a message will send the message to post box and than the message will reside inside post box until the message is handed over to the consumer/receiver. In rabbitMq instead of a postBox we will use a queue. This queue will retain the messages until taken by the consumer. The main benefit of using this message broker is that the producer and the consumer don’t need to understand each other language. that is a consumer can be written in javascript and a consumer could be a java program. They just should know how to connect with RabbitMQ queue. For example : here is a simple program to show a producer, consumer and a queue. This is a sender program.

Micro Services

What, how and why of microservices? So, before understanding microservices we should be aware of the fact that these are also a type of web services. What are web services? , Web Service is an interface which expose a service on HTTP/ HTTPS/SOAP protocol for communication, exchanging data b/w different technologies. Let’s understand this concept using trivago. So here trivago is very known hotel booking sites. You need to enter the hotel name or the place where you want to have a booking, enter the check in and out time etc and click search. On that search button clicked you are shown with multiple options available for your search. So what happens internally, where does trivago gets its data from? Actually trivago collects its data from several places like Airbnb, oyo, etc. Now trivago collects all the data using the provided web services and fetch the result in different formats.

Worker Thread in NodeJs

Worker Thread in NodeJs The Basic idea behind worker thread is to do cpu intensive work without blocking the main thread. As we know that node js run on a single thread (event loop) hence using it for some highly cpu centric job would not be a good idea. As it will increase the request processing time. And user/clients of the applications will get the result in more time. Now having a worker thread would look something like the below diagram. Now unused part of cpu will have a thread running onto them and without mingling with the main thread execution and a code piece can be executed. Lets start with the main.js program(below). Here, a main thread will start to execute the code when we will run this particular file i.e., main.js. IsMainthread will return either true or false based on who is executing the if condition. So right

Sign Up and Start Learning