node. js Tutorial (i) Getting Started and learning resources

Source: Internet
Author: User

Change an internship unit, things temporarily not much, learn a new technology, brush the interview questions, the days have been so.

The programming idea of getting into touch with Node.js,node today is different from all the voices I've learned before, and in a nutshell, node. js

node. JS is a development platform that lets JavaScript run on the server


Tutorials Online, personal habits are written from the grassroots to look at, after all, they write more flexible, not like official documents so serious, and not like books so verbose, more suitable for the introduction.

First of all, of course installation, installation on Windows is simple, thank micro~

node. JS Installation Tutorial

The installation is complete, and then the entry level is used.

node. JS Getting Started with

Through the above two steps, I believe that you have a preliminary understanding of node. js, the next is serious time.


Be confident in your English, official documents



Although my English GRE6, but still feel that the Chinese language thinking more suitable for themselves, recommend a book

The node. JS Development Guide



It's very good, and some of the grassroots blogs I've seen before have come from the book.

There is a section about node. js asynchronous I/O and event-driven, personally feel very good

Excerpt as follows

The biggest feature of node. JS is the asynchronous I/O and event-driven architecture design. For highly concurrent solutions, the traditional architecture is a multithreaded model that provides a system thread for each business logic to compensate for the time overhead of synchronous I/O calls through system thread switching. node. JS uses a single-threaded model, with asynchronous requests for all I/O, avoiding frequent context switching. node. JS maintains an event queue during execution, the program enters the event loop at execution time, waits for the next event to arrive, and each asynchronous I/O request is pushed to the event queue for processing by the program process. For example, for simple and common database query operations, the code implemented in the traditional way is as follows: res = Db.query (' SELECT * from some_table '); Res.output (); The above code executes to the first line, the thread blocks, Wait for the database to return the query results before proceeding with processing. However, because database queries may involve disk reads and writes and network traffic, their latency can be quite large (up to several to hundreds of milliseconds, compared to several orders of magnitude of CPU clocks), where threads block waiting results to return. For high-concurrency access, on the one hand, threads are blocked for long periods of time, while threads are constantly being added to cope with new requests, thus wasting a lot of system resources, while increasing the number of threads takes up a significant amount of CPU times to handle memory context switches, and is vulnerable to low-speed connection attacks. See how node. js solves this problem: Db.query (' SELECT * from some_table ', function (res) {res.output ();}); The second parameter of Db.query in this code is a function, which we call a callback function. When the process executes to db.query, it does not wait for the result to return, but proceeds to execute the subsequent statement until it enters the event loop. When the database query results are returned, the event is sent to the event queue until the thread enters the event loop before the previous callback function is called to continue with the subsequent logic. The asynchronous mechanism of node. JS is event-based, and all disk I/O, network traffic, database queries are requested in a non-blocking manner, and the returned results are handled by the event loop. This mechanism is described in Figure 1-1. The node. JS process processes only one event at a time, and immediately enters the event loop to check for and handle subsequent events. The advantage of this is that the CPU and memory concentrate on one thing at the same time, while simultaneously executing the time-consuming I/O operations as much as possible. For low-speed connection attacks, node. js simply increments the request in the event queue, waits for the operating system to respond, and therefore does not have any multi-lineCan greatly improve the robustness of WEB applications and prevent malicious attacks. The drawbacks of this asynchronous event pattern are also obvious, as it does not conform to the usual linear approach of the developer, often requiring a complete logic split into events, which increases the difficulty of development and debugging. For this issue, the node. JS third-party module presents a number of solutions, which we'll discuss in detail in the 6th chapter. node. JS replaces multi-threading with asynchronous I/O and event-driven, resulting in considerable performance gains. In addition to using V8 as the JavaScript Engine, node. JS also uses efficient Libev and LIBEIO libraries to support event-driven and asynchronous I/O.


This is the way to get started. List Resources


node. jsDownload https://nodejs.org/download/

The official API documentation for node. JS https://nodejs.org/api/index.html
Cnodejs Community https://cnodejs.org/
Installation TutorialsHttp://www.cnblogs.com/zhangran/archive/2013/03/25/2980413.html
Beginner Tutorial Http://www.csdn.net/article/2013-08-28/2816731-absolute-beginners-guide-to-nodejs

Start studying in depth tomorrow

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

node. js Tutorial (i) Getting Started and learning resources

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.