Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the advantages of choosing Node.js as the server-side running environment

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "what are the advantages of choosing Node.js as a server-side operating environment". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Groupon migrated from Ruby on Rails to Node.js

Why give up the original technology stack?

Groupon currently has two sites around the world-the US website and the European website, and the front end of its US website was originally a single Rails (the most popular Ruby development framework) code base. As to why Rails was chosen to develop the original website, Groupon developers said that Rails is very suitable for small teams to develop quickly, allowing the site to get up and running quickly, which is a very good choice for Groupon, which is constantly changing in its initial features.

With the development of Groupon and the introduction of new products, this code base is getting bigger and bigger, and there are too many developers working in the same code base. It is very difficult for them to run and test the product locally. If there is a problem to roll back, then everyone's work will be wasted.

The Groupon team decided to split the existing single Rails library into smaller, independent, and more manageable libraries.

Why choose Node.js?

The Groupon team evaluated different software stacks to find a solution to these problems-- effectively handling a large number of incoming HTTP requests, making parallel API requests serve each HTTP request, rendering the results to HTML5, and effectively monitoring, deployment, and support.

The team developed prototypes using different software stacks and tested them, and overall, Node.js was found to be a very suitable solution.

How to migrate?

The Groupon team used Node.js to rebuild each major part of the page of the site as a separate Node.js application, and then rebuilt the infrastructure so that all separate applications could work together. After the migration, Groupon has become one of the largest Node.js deployment products in the world.

Benefits of migration

Previously, a single Rails front-end code base was split into 20 separate applications, with the following benefits: pages load faster-50% faster, using fewer hardware resources to handle the same traffic than before. Teams can independently change, deploy their own modules, website functions and design implementations can iterate quickly.

More details can be found on the blog of the Groupon development team.

N reasons for choosing Nodejs

Caleb Madrigal is a software consultant from Milwaukee, USA. Four years ago, when he heard about "using JavaScript as a server-side language," he thought it was an absurd idea. There are so many server-side languages to choose from, why choose JavaScript? That's what he thought at the time. But now he has chosen JavaScript/Node.js in his current project. He recently wrote an article explaining his shift.

First, many top enterprises use Node.js, and it works very well, including PayPal, Walmart, Ebay, Groupon, and LinkedIn. These enterprises make extensive use of Node.js in production environments. Madrigal gives the example of PayPal. PayPal compared its Node.js version with Java version for one of the most popular applications on their site, and found that the former was superior to the latter in many ways, and finally decided to switch from Java to JavaScript. InfoQ has reported on this.

Second, Node.js has a great package management system, NPM. You can install almost any package / library by running npm install package name. In addition, dependencies can be tracked through the package.json file. Therefore, the Node.js library is easy to clone, and running "npm install" installs all the dependencies.

Third, the Node.js community is so active that new libraries are always generated. These libraries are very easy to use, making JavaScript a very efficient platform.

Then there is the REPL (read-evaluate-print loop) command line of Node.js. Developers only need to type "node" into the terminal to test Node.js line by line.

Finally, Node.js has a very important feature: non-blocking functions. That's why we see a lot of callbacks and promises in Node.js 's code. This design pattern brings excellent performance to Node.js.

In addition, one of the biggest advantages of Node.js is that it is JavaScript. Everyone knows JavaScript, so there is no need to learn a new language to use Node.js. With it, developers can use only one language, JavaScript on the browser side and Node.js on the server side. When using document databases such as MongoDB and CouchDB that store JSON objects, this greatly simplifies the task of passing data between the database and the user interface.

This is the end of the introduction to "what are the advantages of choosing Node.js as the server-side running environment". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report