Node replaces Nginx? Can someone explain this architecture to me?

Asked

Viewed 1,794 times

7

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

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

Then comes my doubt:

If Node’s big move is the unobtrusive connection to the server, what would be its advantage over Nginx since the latter also allows unobtrusive connections?

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

Someone explains this architecture too.

Disruptive technologies (I don’t know if that’s the good word in English) are on the way, that’s for sure, and the trend of the large data stream both in and out (through Apis) is also right.

But I can’t see what makes Nodejs indispensable, with Nginx available.

  • 2

    It’s like the chat I’ve heard for about 10 years that the web was going to replace the desktop. I said it was nonsense, I see today that it is really bullshit (not that people are not trying insistently, the fact is that the result is always very bad no matter how much they insist). What you said is one more of these fashions, because everything that Ode has, any serious language had in the past. What is new to kids of the web on Node, for example it does not impress much who was already programming for a while. NOTE: It is not a criticism of the product, but the thought that everyone has to change "fashion".

  • Yeah. I’m a back-end developer. I’m replacing apache with Nginx due to some benchmarking results. But I’m still in php. I’m trying to find a reason to replace my old architecture with Nodejs. And I don’t think so.I agree 100%. I don’t run behind fashion. But I wonder if there’s something I’m not seeing.

  • 1

    Exactly, and if you move, what is Node.js for? Why not C# or many others? I’m not saying that this is better than that, nor the other way around. I just want to say that there is and there was a lot on the market before Node.js, and it will continue to be. I remembered the furore of Ruby on Rails, the guys said they were going to end the other Web technologies, and today I hardly see.

  • @zwitterion In terms of performance, other languages (Go, Java, C#, Javascript/Node.js) generally bring more satisfactory results and greater scalability. If I were to choose today, I would focus on Go which, in addition to bringing a better performance than both Node.js and PHP, still has a ridiculously low memory consumption (and a more productive syntax than a C or C++, for example).

  • 1

    @Kazzkiq Precisely, there are a thousand different reasons for each to choose another option. I use PHP for a lot of things, even though PHP is an extremely bad thing. For things I need more performance and stability, I use another language on the same server (which is none of the above) and would not go to Node.js, which was born more limited than what I use today. So, it is not possible to define what the path is, each one has to put all the weights in the balance according to their reality. I believe that despite an interesting discussion, pro formato do site I find complicated the question.

  • @Bacco, I’ve updated my question.

  • 1

    @zwitterion had even edited the previous comment on this. I find it an interesting discussion, but I think that the Q&A format does not work well. If you catch a busy day in the network chat you can go far with the subject (I think it became too wide and runs the risk of turning opinionated debate, to speak the truth).

  • @Kazzkiq, I thought about it. Memory these days, it’s not so scary. 2Semin ago I was doing a job on a computer with 128G of memory RAM and 31 processors. This is something tangible to acceptable nowadays. When performing, you’ve seen the benchmarking of php7? hega to be up to 40%-50% better than traditional languages. http://www.zend.com/en/resources/php7_infographic

  • @Bacco this debate should be held where? Tbm I think it can be barred, but it’s a topic that shouldn’t be outside a community of programmers. After all, we are all living in moments of doubt and running in fashion is the worst thing there is. We have to have solid gasps to decide one architeur and exclude another.

  • 1

    @zwitterion this comparison of the guys was made only with scripting language. Not that I think "unfair", pq PHP is basically a scripting language, that people invented to use in other ways, but if you put any compiled language (or even other based on intermediate Runtime) close, the graph becomes much less attractive pro PHP.

  • 1

    Thanks for the link. I will be aware of everything that this company says. I don’t think I have ever seen anything so serious to talk such nonsense together. All silly assumptions to sell a product. It’s not just biased information, it’s the ingenuity of the author. He understands nothing of the subject and believes in Sací Pererê. Node brings zero innovation. And what they did around the Node, not the Node itself, that worked, is not only copyable for other technologies, but has already been copied, as well as everything, including Node does. I took the illustration, since there is explicitly prohibiting the use.

  • Ok @bigown, I hadn’t even noticed the photo ban. So your comment seems to be in tune with my print. It does seem to be a fad - more of the same at the end of the day.

Show 7 more comments

4 answers

10


I will focus on this answer in your second question, since the first (Node replaces NGINX?) falls into a more opinionated field.

About the Node.js + NGINX architecture

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

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

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

Security

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

In addition, adding a server focused exclusively to deal with requests performatively ahead of your other servers, allows you to have a possible increase in stability and security right away, since a server like NGINX was built exclusively for 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 to accomplish all the tasks in building a home, a specific single server (or language) may also not be the best solution for all parts of your system. With a reverse proxy it is much easier to receive requests and forward them according to the requested task.

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

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

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

Performance

As said before, servers like NGINX were 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 with an approach Event Driven similar to Node.js), and it is no wonder that he performs this role extremely well. This also means that sometimes it can be much more advantageous to use a server like these to serve as an input port to your system, than another newer solution with a very comprehensive focus (as is the case with Node.js). Here we come back to the question of scope: each tool has a focus, and since NGINX’s focus is on performance in the processing of requests, it is no wonder that it serves this purpose better than other solutions without the same focus.

Other answers with more detail about the advantages of using a reverse proxy ahead of Node.js can be found here:

https://stackoverflow.com/questions/16770673

https://stackoverflow.com/questions/9967887

1

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

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

  • Hi Jose, my intention is not to compare nodejs with Nginx. My intention is to try enteder pq using Nodejs to connect to a database for example, and create a page dynamically, if PHP already does this? The argument I have seen is that the Node does not obstructive connection, but the Nginx tbm does. The other explanation I see a lot is the saving of resources, processor and server memory in a scenario of high competition. This tbm is an argument, which in my view does not justify the use of Node. Having memory and processing resources is getting cheaper over time.

  • I don’t think this whole discussion makes sense. Node.js is (primarily) a platform for web development, just as there are other platforms, such as PHP you mentioned, Java, C#, Python, Ruby, Perl, etc. The fact that Node.js uses "unobtrusive connection" (as you say) is just an implementation detail, that’s not going to be a determining fact in choosing Node.js instead of a Java framework, or PHP, or Python, etc. And again I repeat, the scope of Node.js is much larger than the scope of Nginx, so it makes no sense to make comparisons between them.

1

It’s not quite 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 create 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 Fork of C on Unix! Well, these features help to understand that Node.Js best serves the purpose of processing server-side Javascript and Nginx as reverse proxy is a Ferrari! Amzon uses Nginx as well as other high-volume web sites for simultãneas requests. On a distributed architecture, you place an Nginx Master Process coordinated with requests for multiple worker processes running Node.js. That’s performance and scalability.

  • Very good. I keep learning.

-2

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

nodejs I believe to be a platform that helps a Javascript programmer work on Backend. if I’m not mistaken, I believe Nginx is made in Node.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.