What is node. js suitable for? Where are the benefits of using node. js?

Source: Internet
Author: User
Tags php server
This article focuses on the appropriate direction of node. js, what is node. js suitable for? And what are the benefits of node. js? Please see the article for more detailed details.

First, let's talk about what node. js is suitable for:

First of all, Nodejs is the cornerstone of the front-end full stack, its application scenario has been from the front-end tool scaffolding, auxiliary tools, development to the API middle tier, Agent layer, as well as professional back-end development.

One of the most valuable of these is the API middle tier. The big trend now is that more and more businesses are pushed to the front end, and the backend is focused on serving only. A typical and common work scenario is when the front and back end collaborate, because the progress is different sometimes the frontend needs to wait for the backend interface.

At such times, Nodejs's middle-tier application can solve this problem very well. Front-end through Nodejs can contract the format of the data, according to the requirements of the front-end to customize their own interface, self-encapsulation of the database CRUD operations, create their own proxy and gateway server and so on. These things in the past can only wait for the backend to do, but now through the Nodejs front-end can be done by themselves, which makes the process of the work more controllable.

Of course, this also to the front-end developers put forward higher requirements, at least database, architecture design, system structure, network applications these short boards need to be slowly filled.

It is said that AH I am not sure, nodejs the beginning is to the back end, only for simple, asynchronous, large concurrency and choose the Java language, quirks under the front-end discovery and flourish.

So the front-end Nodejs must be back-end erosion, the development structure of the back end, the technology stack has been very complete, so the back end is generally reluctant to change, so many times for the Nodejs resistance, in fact, is from the back-end of the conservative. Of course, this is also a certain reason, because the backend is mainly services, data, low-level applications, these things are stable, security, and some historical problems left, so they do not like new things.

So at this stage, many Nodejs applications are the bridge between the front end and the back end. Generally speaking, there is no historical burden of the new company Ah, start-up companies ah, incubation projects and other more willing to use Nodejs, fast and efficient.

Now basically all front-end applications have Nodejs shadow, what react, vue, angular, and so on, its application scenarios and the job market are also very large, so Nodejs learning is not what you can do, but let you more a display of space. (For more information about node. js, come to Topic.alibabacloud.com's node. js Video Tutorial section)

Second, now say the benefits of using node. JS:

As you've seen before, Node is well-suited for scenarios where you expect a high level of traffic before responding to a client, but not necessarily a lot of server-side logic and processing required. We've summed up node's three-point benefit, or a typical example of outstanding performance:

1.RESTful API

WEB services that provide RESTful APIs receive several parameters, parse them, combine a response, and return a response (usually less text) to the user. This is ideal for Node, because you can build it to handle tens of thousands of connections. It still does not require a lot of logic; it essentially simply looks up some values from a database and makes them a response. Because the response is small text, inbound requests are also small amounts of text, so traffic is not high, and a machine can even handle the API needs of the busiest companies.

2.Twitter queues

Imagine a company like Twitter that must receive tweets and write it to the database. In fact, almost thousands of tweets per second are achieved, and the database is not able to handle the number of writes required during peak hours in time. Node becomes an important part of the solution to this problem. As you can see, Node handles tens of thousands of inbound tweets. It can quickly and easily write them to a memory queueing mechanism (such as memcached), where another individual process can write them to the database. Node's role here is to quickly gather tweets and pass this information to another process responsible for writing. Imagine another design (the regular PHP server will try to handle writes to the database itself): Each tweet will cause a short delay when writing to the database because the database call is blocking the channel. Due to database latency, a machine of this design may only handle 2000 inbound tweets per second. 500 servers are required to process 1 million tweets per second. Instead, Node can handle each connection without blocking the channel, which can capture as many tweets as possible. A Node machine that can handle 50,000 tweets requires only 20 servers.

3. Video game Stats

If you've played the Call of Duty game online, when you look at the game stats, you're immediately aware of the problem: to generate that level of statistics, you have to keep track of massive amounts of information. In this way, if millions of players play the game online at the same time, and they are in different places in the game, they will soon generate a huge amount of information. Node is a good solution for this scenario because it captures the game-generated data, merges the data in a minimal amount, and then queues the data to write them to the database. Using the entire server to track how many bullets the player has fired in the game looks foolish, and there may be some useful restrictions if you use a server like Apache, but instead, if you use a server specifically to track all the stats for a game, as you would with a server running Node , it seems like a smart move.

The above is an introduction to the usefulness of node. JS and the benefits of node. JS (see the Topic.alibabacloud.comnode.js Chinese Reference manual section for more content), questions can be asked below

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.