Whenever we come across something, we always do have a lot of question about it and confusions, Here we will cover most of the questions that I have had and you also might have had.
Most of the questions that we cover are smaller questions, you can use this article as a reference while debugging nginx.
So, let's not be this way and fix our bugs sooner, (PS: I does the same thing as well ;))
Shall we start seeing those questions one by one?
Do you have to pay for nginx?
No, you don't have to pay for using nginx unless you want to use their nginx plus service, nginx and nginx plus service is completely different.
Nginx is an open source web server that anyone can use anytime and change it according to their needs by even adding third party modules and it's always for free.
Nginx plus is a service provided by the nginx creators, they manage the server and infrastructure of your app from load balancing to everything, you are not paying for nginx, you are paying for the service that they have provided for you.
This is the website url of nginx nginx.org, they are an organization and nginx plus nginx.com it is commercial one, don't confuse between both.
Can you use nginx for free?
Nginx is completely free and it is open sourced which means you can see their source code and also even change it,
But nginx plus is a different thing it is a service provided by nginx.com to manage and configure your nginx routing and load balancing,
Don't confuse it, moreover most of the people and developers uses only nginx not nginx plus.
How many request can Nginx handle?
10000 Requests Per Second, is the max you can achieve with nginx if you are using 1gb of ram and 1 core of processor. In case if you are using nginx as a reverse proxy to proxy back into localhost, it depends on your code and framework that you use will limit nginx
We have seen a lot of these things in our performance comparion series, click here. Here you can find a lot about how much a framework like expressjs, flask, fastify, fastAPI and alot more is in there.
We compare performance and there is a lot of content still on the way.
How much RAM does Nginx need?
128MB Of RAM is enough for maintaining upto 5000 requests per second if you are serving static content but if you use reverse proxy in the same server then it might take upto 256 MB for 5000 requests per second
Nginx is really cautious at using resources, so as far I could think you don't have anything to worry about the nginx ram usage and cpu usage. Most probably the issue will be from your codebase if you use reverse proxy and proxy to the same server.
Is Nginx a firewall?
Nginx is a webserver and you might have seen somewhere like welcome to nginx, because of the owner of the site or ip has not configured nginx, you can use ufw as a firewall. Nginx is only a web server
If you use ufw you can block incoming outgoing connections to any ip address and ports,
Can Nginx be bottleneck?
Nginx is a web server but mostly used as a reverse proxy, so it make sures the server is not having bottleneck by sending out the requests that it received to multiple server but it can also be limited or bottleneck by the among of requests it receives
If the server recieves more than the amount of requests in should recieve then the nginx may get bottleneck.
How much RAM do I need for reverse proxy?
You might need up to 128 MB for nginx alone to reverse proxy but if you also run the process in the background then you will need a minimum of 256 MB of ram.
But it is the minimum requirement, I would recommend you to have a minimum of 512 MB of RAM which is really cheap these days.
How many threads does Nginx use?
It is upto you to configure nginx to use specific number of nodes or all of the nodes in nginx and you can configure that in the events block with worker_process to be auto to use all the nodes.
You can mostly use all of the threads that is available in the machine.
Do I need to restart Nginx after config change?
In most of the cases you don't need to restart your nginx server after configuration, you can just reload nginx but even after you reloaded no changes has appeared then you can try restarting it
How do I know which port nginx is running?
With nginx you can specify it to listen on any port and you can see that in your configuration file, but mostly we use port 80 for all the stuffs.
If you want to know what port does it listen to open your configuration.
sudo nano /etc/nginx/nginx.conf
With this command you can use your terminal to edit it, then.
events {}
http {
server { listen 80;
location / {
proxy\_pass http://localhost:3000/;
}
}
}
You should see something like this, now here you can see the listen keyword right next to that you have 80 which is the port it is listening on
How do I run Nginx as a Windows service?
You can easily run it via the cmd in windows, go to the directory and in the directory path type cmd and it will open a commandline for that folder and type "start nginx". which will do the job for you.