Node replaces Nginx? Does anyone explain this architecture to me?

4

I was reading a article about the "dawn" of JavaScript companies. The "dawn" in the sense that things are only beginning. That is, according to the author, the future is JavaScript with NodeJS, and companies will sooner or later have to replace their .net and java technologies with a client-side processing solution.

And to go further, the author mixes Nginx in this architecture by interacting with the Node.

So here's my question:

If the big Node move is the non-obstructive connection to the server, what would be its advantage over NginX since NginX also allows non-obstructive connections?

Below, in the photo, the author places Nginx as the first access layer and the one doing Node queries. I was confused.

Someone explains this architecture too.

Disruptive Technologies (I do not know if this is the good word in Portuguese) are on the way, that's for sure, and the trend of large data flowing both in and out (via APIs) is also right.

But I can not see what makes NodeJS indispensable, with Nginx available.

    
asked by anonymous 09.09.2016 / 04:07

4 answers

5

I'm going to focus this answer on your second question, since the first Node replaces NGINX? ) falls into a more opinionated field.

About the architecture Node.js + NGINX

The approach of deploying a network server in front of other servers can bring some advantages both in terms of security and performance depending on the architecture of your system.

The concept is relatively simple: you add a server that is responsible for receiving and forwarding the incoming requests from outside (this server is usually called a reverse proxy ), reverse these requests internally for the other servers to process the related tasks.

This means that servers that actually run tasks are never directly exposed to the external network. Every request that arrives at them before had to go through the reverse proxy. But what are the advantages of this?

Security

Mature and "caged" servers over years of real-world testing such as NGINX have numerous built-in features that make it easy to protect your server against possible external attacks using a few configuration lines (the http_limit_request , http_limit_conn and client_header_timeout are some examples of this).

In addition, by adding a server that is exclusively focused on dealing with requests on a performative basis in front of your other servers, you have a possible stability and security increase right away, since a server like NGINX was built exclusively with this purpose in mind (unlike Node.js for example, which has an infinitely more comprehensive focus and often may not have been optimized especially for this specific task).

Scope separation

Just as a hammer does not serve all the tasks in building a home, a single server (or language) may not be the best solution for all parts of your system. With a reverse proxy it is much easier to receive the requests and pass them on according to the requested task.

This allows you to achieve greater modularity in your application, so that each server has a specific focus, eg:

  • C module : Responsible for processing tasks where performance is crucial,
  • Module in PHP : Remaining application where productivity is more important than performance

If your application was split into the modules above, using a reverse proxy that redirects the requests to their respective modules would make the scope very well separated and organized.

Performance

As said before, servers like NGINX have been built from the first line of code with performance and scalability in mind. This type of server is focused exclusively on processing network requests (including an Event Driven similar to Node.js), and it's no wonder they play that role extremely well. This also means that sometimes it can be much more advantageous to use a server like these to serve as a gateway to your system than a newer, more comprehensive solution (such as Node.js) . Here we come back to the question of scope: each tool has a focus, and since NGINX's focus is on processing requests, it is no wonder that it serves this purpose better than other solutions without the same focus. >

Further answers in greater detail about the advantages of using a reverse proxy in front of Node.js can be found here:

link

link

    
09.09.2016 / 05:33
1

To sum up: node.js is a software development platform primarily for the internet, and preferably for the web (http protocol). Nginx is an http server.

The two products (software products) are not comparable. To compare them is to compare garlic with buckwheat, oranges with bananas.

    
09.09.2016 / 04:19
1

Not right there!

Nginx was created before Node.js. Ngix was created by a Russian in 2002 and is a reverse proxy, which works process oriented rather than threads like Apache. In addition it has a model where we created a Master Process, which controls several Worker process. This architecture is supported by an event loop mechanism, but not in a single thread as in Node.Js, but with this concept of processes. Reminds me of C's on Unix! Well, these features help to understand that Node.Js best serves the purpose of processing server-side JavaScript code and Nginx as a reverse proxy gets a ferrari! Amzon uses nginx as well as other high-volume sites for concurrent requests. In a distributed architecture, you put a Master Process from Nginx coordinated the requests to several worker process executing Node.Js. This is performance and scalability.

    
16.10.2017 / 05:24
-2

nginx does exactly the same thing as apache does, it is simply an http server that works with the common gateway interface (CGI) protocol that is used on dynamic pages, the CGI's job is to invoke an interpreter or system to run a web application done in any backend programming language!

nodeJS I believe is a platform that helps a JavaScript programmer work on the Backend. if I'm not mistaken, I believe that nginx is done in node.

    
09.09.2016 / 05:20