Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Node.js那些事儿
Search
Allen Liu
May 27, 2012
Programming
2
1.6k
Node.js那些事儿
课题分享
Allen Liu
May 27, 2012
Tweet
Share
More Decks by Allen Liu
See All by Allen Liu
字符集科普知识
liuxd
1
70
Nginx基础知识
liuxd
5
330
vagrant介绍
liuxd
2
290
PHP5.3、PHP5.4的特性介绍与深度挖掘
liuxd
3
300
Other Decks in Programming
See All in Programming
モビリティSaaSにおけるデータ利活用の発展
nealle
0
500
Designing Repeatable Edits: The Architecture of . in Vim
satorunooshie
0
390
AsyncSequenceとAsyncStreamのプロポーザルを全部読む!!
s_shimotori
1
280
ゼロダウンタイムでミドルウェアの バージョンアップを実現した手法と課題
wind111
0
200
r2-image-worker
yusukebe
1
170
イベントストーミングのはじめかた / Getting Started with Event Storming
nrslib
1
590
Rails Girls Sapporo 2ndの裏側―準備の日々から見えた、私が得たもの / SAPPORO ENGINEER BASE #11
lemonade_37
2
180
Chart.jsで長い項目を表示するときのハマりどころ
yumechi
0
110
カンファレンス遠征を(安く)楽しむ技術
wp_daisuke
0
170
Dive into Triton Internals
appleparan
0
500
What's New in Web AI?
christianliebel
PRO
0
130
CloudNative Days Winter 2025: 一週間で作る低レイヤコンテナランタイム
ternbusty
7
1.5k
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
46
7.8k
Typedesign – Prime Four
hannesfritz
42
2.9k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
Become a Pro
speakerdeck
PRO
29
5.6k
Faster Mobile Websites
deanohume
310
31k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
Why Our Code Smells
bkeepers
PRO
340
57k
Into the Great Unknown - MozCon
thekraken
40
2.2k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
658
61k
Designing for Performance
lara
610
69k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.7k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
Transcript
Node.js 那些事儿 作者:刘喜东
2 Content What Why How Where
Who
3 Content What Why How Where
Who
4 是什么? ➢ 学名: Node.js ➢ 辟谣:核心由 C/C++ 编写 ➢
本质:一个 JavaScript 虚拟机 ➢ 托管: https://github.com/joyent/node ➢ 概括: evented I/O for v8 javascript
5 Content What Why How Where
Who
6 Apache+mod_php
7 Node.js
8 Node.js VS Apache+mod_php ➢ 独立完成 VS 细化分工 ➢ 面向事件编程
VS 面向对象编程 ➢ 英雄主义 VS 人海战术 ➢ 劳模 VS 普通青年
9 Node.js 的优点 学习成本低 内存占用少 CPU 利用率高
10 Content What Why How Where
Who
11 离了模块就活不了 ➢ npm ➢ CommonJS ➢ 核心模块概览
npm ➢ Node Package Manager ➢ pear 、 gem 、
apt ➢ curl http://npmjs.org/install.sh | sudo sh
CommonJS ➢ 它是一套 API 。 ➢ 它要为 Web 服务器 ,
桌面和命令行应用创 建一个完整的 JavaScript 生态系统,不 仅仅只为浏览器。 ➢ 它定义了一组标准和规范,如模块、包、 文件系统等。
核心模块 ➢ http/https ➢ url ➢ os ➢ fs ➢
assert ➢ ... ...
代码示例 ➢ 功能:根据坐标获取小区列表的 API 。 ➢ 方式: POST ➢ 返回:
JSON ➢ 测试: ab -c 100 -n 1000 ➢ 网址: https://github.com/liuxd/MyNodeJS
Apache+mod_php
Node.js
18 Content What Why How Where
Who
19 用武之地 ➢ IO 频繁 ➢ CPU 利用率低 ➢ 内存导致并发瓶颈
20 应用场景 ➢ 聊天系统 ➢ 投票 ➢ 点击量统计 ➢ 秒杀
➢ 业务耦合较低的 api ➢ ... ...
21 Content What Why How Where
Who
22 谁在用? ➢ Instagram—— 基于 Node.js 开发了 node2dm ➢ LinkedIn——
移动应用业务 ➢ Github——NodeLoad, 存档下载服务器 ➢ —— 淘宝 用 Node.js 实现 MyFOX ➢ 微软、雅虎、 ebay
23 By the way ➢ NAE——Node App Engine ➢ http://registry.npmjs.vitecho.com
➢ npm config set registry “XXOO” ➢ PHP 版的 Node.js——React
Thank you very much.