[Node. js] initial experience

Source: Internet
Author: User

HeardNode. jsRecently, it was very popular. After a brief look on the Internet, it was about an engine that executes Js in a non-browser environment (based on V8 engine extension) and comes with the Web server function. Using js to replace other traditional server-side scripts has a powerful "Everything is JS" architecture. I recently learned something about Linux, so I tried to install a node on centos.

 

SlaveSource codeInstallation and testing

Find the download Source Code address from the http://nodejs.org: http://nodejs.org/dist/v0.8.14/node-v0.8.14.tar.gz with wget command download:

 
Wget http://nodejs.org/dist/v0.8.14/node-v0.8.14.tar.gz
    • Extract
 
Tar-zxf node-v0.8.14.tar.gz
    • CD to the node-v0.8.14, execute configure \ make install in sequence, compile the library to be dependent on: Yum install gcc-C ++ OpenSSL-devel
 
./Configuremakemake install
    • Write TestCode, Save as test-web-server.js
 
VaR HTTP = require ('http'); http. createserver (function (req, Res) {res. writehead (200, {'content-type': 'text/plain '}); Res. end ('Hello node. JS \ n ');}). listen (8081, "192.168.1.102"); console. log ('server running at http: // 192.168.1.102: 8081 /');
    • Run
Node test-web-server.js &
    • Open and save firewall settings
 
Iptables-I input 2-P TCP -- dport 8081-J acceptservice iptables save
    • Test with a browser

    • Using http_load for a simple stress test, we can see that there are also 10000 requests. When the number of concurrent requests is 50, the throughput is 2869. When the number of concurrent requests is 500, the throughput is 1935, the decline trend is obvious ~

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.