`
hanyh
  • 浏览: 228846 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

nodejs使用(1)安装

阅读更多
nodejs试用
===============
1,下载安装
./configure --prefix=/home/god/nodejs
make
make install

2,read doc
简单看一下安装后的目录结构,可以看见有许多python的代码
god@hanyh-laptop:~/nodejs$ ls -R
.:
bin  include  lib  share

./bin:
node  node-repl  node-waf

./include:
node

./include/node:
config.h  ev.h           node_config.h  node.h              node_version.h  v8.h
eio.h     node_buffer.h  node_events.h  node_object_wrap.h  v8-debug.h      v8-profiler.h

./lib:
node

./lib/node:
wafadmin

./lib/node/wafadmin:
ansiterm.py  Configure.py  Environment.py  Logs.py  Options.py  py3kfixes.py  Scripting.py  Task.py  Utils.py
Build.py     Constants.py  __init__.py     Node.py  pproc.py    Runner.py     TaskGen.py    Tools

./lib/node/wafadmin/Tools:
ar.py           compiler_cxx.py  dmd.py  gdc.py       icc.py       libtool.py     osx.py      suncxx.py     xlcxx.py
cc.py           compiler_d.py    d.py    gnu_dirs.py  icpc.py      misc.py        preproc.py  unittestw.py
ccroot.py       config_c.py      gas.py  gob2.py      __init__.py  nasm.py        python.py   winres.py
compiler_cc.py  cxx.py           gcc.py  gxx.py       intltool.py  node_addon.py  suncc.py    xlc.py

./share:
man

./share/man:
man1

./share/man/man1:
node.1


设置路径:
======================================================
export PATH=$PATH:/home/god/nodejs/bin/

写入第一个例子:server1.js

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');

运行:
god@hanyh-laptop:~/nodejs/work$ node server1.js
Server running at http://127.0.0.1:8124/

ab压力测试
====================================================
nodejs的数据
==========================================
god@hanyh-laptop:~/nodejs/work$ ab -c 50 -n 10000 http://127.0.0.1:8124/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:       
Server Hostname:        127.0.0.1
Server Port:            8124

Document Path:          /
Document Length:        12 bytes

Concurrency Level:      50
Time taken for tests:   1.694 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      760000 bytes
HTML transferred:       120000 bytes
Requests per second:    5903.01 [#/sec] (mean)
Time per request:       8.470 [ms] (mean)
Time per request:       0.169 [ms] (mean, across all concurrent requests)
Transfer rate:          438.11 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.5      0       9
Processing:     0    8   4.5      8      37
Waiting:        0    8   4.4      8      37
Total:          1    8   4.4      8      37

Percentage of the requests served within a certain time (ms)
  50%      8
  66%     10
  75%     11
  80%     11
  90%     14
  95%     17
  98%     21
  99%     22
100%     37 (longest request)

nginx的数据
==========================================
god@hanyh-laptop:~/nodejs/work$ ab -c 50 -n 10000 http://127.0.0.1:7000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        nginx/0.7.67
Server Hostname:        127.0.0.1
Server Port:            7000

Document Path:          /
Document Length:        151 bytes

Concurrency Level:      50
Time taken for tests:   1.086 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      3622534 bytes
HTML transferred:       1511057 bytes
Requests per second:    9205.48 [#/sec] (mean)
Time per request:       5.432 [ms] (mean)
Time per request:       0.109 [ms] (mean, across all concurrent requests)
Transfer rate:          3256.56 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    2   1.2      2       9
Processing:     1    3   1.1      3       9
Waiting:        0    2   1.0      2       9
Total:          3    5   2.0      4      14

Percentage of the requests served within a certain time (ms)
  50%      4
  66%      4
  75%      7
  80%      8
  90%      9
  95%      9
  98%      9
  99%     10
100%     14 (longest request)

RPS和nginx相差只30%左右,性能相当惊人

基本设计
=================================
不用线程解决并发问题,线程难度大且有些问题性能不好
简化的事件模型,没有一个显式的start-the-event-loop过程,类似浏览器的一样隐藏事件模型,脚本启动后就自动进入事件模型状态
多核的支持:多进程。The fundamentals of scalable systems are fast networking and non-blocking design—the rest is message passing. In future versions, Node will be able to fork new processes

分享到:
评论

相关推荐

    macbook pro/air m1 nodejs 安装

    macbook pro/air m1 nodejs 安装

    nodejs安装和卸载,超全!

    nodejs安装和卸载 Ubuntu 上安装 上 Node.js ⽅式⼀:直接安装 ⼀、安装 1.$ sudo apt-get install nodejs 2.$ sudo apt-get install npm ⼆、升级 1.升级npm命令如下: $ sudo npm install npm -g /usr/local/bin/...

    【课件】NodeJs 介绍 安装 开发工具配置1

    1、Nodejs 用户量大:我们无法统计 Nodejs 软件的下载量,但是我们可以通过 Nodejs 2、Nodejs 是程序员必备技能:对于前端开发者而言 N

    NodeJs-v18.12.1-x86 Windows安装包

    https://nodejs.org/en/download/ 公司内网打不开这个地址,上传资源 LTS版本

    nodejs-v14.16.1

    由于使用最新版本的nodejs安装,然后再HBuilderX安装npm install时出现,提示如下: npm ERR! gyp ERR! node -v v16.14.2 npmERR! gyp ERR! node-gyp -v v3.8.0 npm ERR! gyp ERR! not ok 原因:由于项目和版本...

    nodejs安装32位及64位

    [1] Node.js是一个基于Chrome JavaScript运行时建立的平台, 用于方便地搭建响应速度快、易于扩展的网络应用。Node.js 使用事件驱动, 非阻塞I/O 模型而得以轻量和高效,非常适合在分布式设备上运行数据密集型的实时...

    nodejs_12.16.3-1_mips64el.deb 龙芯nodeJS

    1

    appium+nodejs+AndroidSDK一套完整安装资源加步骤.rar

    appium自动化测试所需一整套资源包+安装部署配置环境操作过程,...1、nodejs安装包。 2、Appium-windows-1.18.3.exe安装包。 3、AndroidSDK:appium所需的插件资源文件。 4、安装步骤+环境变量配置txt详细说明文档。

    coolnameismy#dev-tips#nodejs安装和卸载1

    nodejs安装nvm安装(推荐)//查看nvm里面nodejs版本//切换nodejs版本//设置默认版本,否则每次关闭终端再打开就要use一次$ nvm a

    rh-nodejs6-nodejs-asn1-0.2.3-2.el7.noarch.rpm

    官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装

    Linux下安装多个版本nodejs并切换使用

    1.安装nodejs管理工具nvm sudo apt install curl git vim curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash 安装nvm后会提示进行下面操作修改环境变量,也可以退出再登陆来跳过...

    nodejs安装及环境配置.docx

    nodejs安装及环境配置 要安装和配置Node.js环境,你可以按照以下步骤进行: ### 1. 下载Node.js安装包: 访问Node.js官方网站(https://nodejs.org/),然后下载适合你操作系统的Node.js安装包。Node.js提供了...

    详解nodejs解压版安装和配置(带有搭建前端项目脚手架)

    1】第一步:下载nodejs 中文官网: https://nodejs.org/zh-cn/download/ 如下图是最新的版本,不用怕这是最新的直接下载就可以了,选择windows版本,LTS是长期支持版本,箭头所示下载64位压缩版;个人觉得压缩版本就...

    JinwenXie#JinwenXie.github.io#2018-12-11-NodeJs以及cnpm安装1

    安装:官网下载,正确会出现版本号设置环境变量:nodejs下建

    win10安装nodejs和npm

    1、下载安装稳定版 2、安装目录D:\Program Files\nodejs下新建两个文件夹node-cache,node-global用来指定npm的模块路径和缓存路径 3、配置环境变量.在系统变量PATH中新增 D:\Program Files\nodejs 和 D:\Program ...

    nodejs 的 imagemin.min.js 模块压缩版,无需安装环境直接使用

    1.由于npm 安装的 imagemin 模块使用 module 和 ES6 类型导致在 CommonJS 环境运行不起来急需快速使用的开发者们 2.又或者缺少 cjpeg、pngquant、库导致运行 ERR 报错,急需要这些缺失库的开发者们 库文件列表如下:...

    详解使用nodeJs安装Vue-cli

    前提:nodeJs本地已安装。 1、执行npm install –global vue-cli ,全局安装vue-cli —-因为默认是从国外服务器下,可以使用阿里巴巴在国内的镜像服务器。 产生通过config命令设置默认下载路径: npm config set ...

    一个NodeJS和redis做的基于http协议的队列

    http: 127 0 0 1:8000 getList queueName"&gt;一个NodeJS和redis做的基于http协议使用的队列 做了点小修改 支持多个队列和post提交 原github地址:https: github com lnmp nodemq 使用方法: 在安装好redis和nodejs...

    NodeJS、NPM安装配置步骤(windows版本) 以及环境变量详解

    1、windows下的NodeJS安装是比较方便的(v0.6.0版本之后,支持windows native),只需要登陆官网(http://nodejs.org/),便可以看到首页的“INSTALL”按钮,直接点击就会自动下载安装了。 2、安装过程基本直接...

Global site tag (gtag.js) - Google Analytics