-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
542 lines (462 loc) · 21.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=1024" />
<title>Node.js在花瓣网的应用</title>
<meta name="description" content="Node.js在花瓣网的应用" />
<meta name="author" content="Zola Zhou" />
<!--<link href="css/font.css" rel="stylesheet" />-->
<link href="css/style.css" rel="stylesheet" />
</head>
<body class="impress-not-supported">
<div class="fallback-message">
<p>Your browser <b>doesn't support the features required</b> by impress.js, so you are presented with a simplified version of this presentation.</p>
<p>For the best experience please use the latest <b>Chrome</b>, <b>Safari</b> or <b>Firefox</b> browser.</p>
</div>
<div id="impress">
<div id="title" class="step" data-x="-5000" data-y="-3500" data-z="-10000" data-scale="3">
<!--<span class="sub">简单介绍</span>-->
<span class="sub">Node.js</span>
<h1 class="g"><span>在花瓣网的应用</span></h1>
<p class="footnote">belltoy<br/>2012.12.22</p>
</div>
<div id="intro" class="step big" data-x="-8520" data-y="-4880" data-scale="13">
<h3>花瓣网介绍</h3>
<!--<img class="reflect" src="img/screenshot_huaban_home.png" style="position: absolute; right: 0; top: 0; height: 355px; width: 500px;" />-->
<img class="reflect" src="img/huaban.com.png" style="position: absolute; right: 0; top: 0; height: 355px; width: 500px;" />
</div>
<div class="step" data-x="-11800" data-y="-3200" data-scale="5">
<q>兴趣图谱</q>
</div>
<div class="step" data-x="-11800" data-y="-2200" data-scale="5">
<q>2011.11.11正式上线</q>
</div>
<div class="step" data-x="-11800" data-y="-1200" data-scale="5">
<q>百万用户,千万PV</q>
</div>
<!-- let's build it -->
<div class="step big" data-x="-100" data-y="1000">
<h1 class="g">Let's build it</h1>
</div>
<!-- 选择语言 -->
<div class="step slide" data-x="5000" data-y="2000" data-rotate="90" data-scale="1">
<h3>选择语言</h3>
<dl>
<dt>首先,要满足快速开发的需求</dt>
<dd>
<ul>
<li>团队熟练程度</li>
<li>敏捷性</li>
<li>库支持</li>
</ul>
</dd>
</dl>
</div>
<!-- Node.js of course... -->
<div class="step big" style="width: 1200px;" data-x="1000" data-y="3000" data-z="-2000" data-rotate="245">
<h2>N<span class="g">o</span>de<span class="g">.JS</span> <span class="r">of course</span></h2>
</div>
<!-- why not php -->
<div id="why-not-php" class="step big" data-x="5000" data-y="1000" data-z="3000" data-rotate="180">
<h1 class="g">Why not <span class="php">PHP</span>?</h1>
</div>
<div class="step" data-x="5100" data-y="700" data-z="3000" data-rotate="205">
<li>不喜欢这个语言</li>
</div>
<div class="step" data-x="5250" data-y="500" data-z="3000" data-rotate="230">
<li>需要调用大量外部服务</li>
</div>
<div class="step" data-x="5480" data-y="400" data-z="3000" data-rotate="255">
<li>不适合写长时间运行的任务</li>
</div>
<!-- why node.js -->
<div id="why-node-js" class="step slide" data-x="5000" data-y="5000" data-z="-5000" data-scale="2">
<h3>Why N<span class="g">o</span>de<span class="g">.JS</span>?</h3>
<ul>
<li><span class="b">J</span>ava<span class="r">S</span>cript Language</li>
<li>V8 engine</li>
<li>Non-blocking IO</li>
<li>Express/Connect/jade/socket.io</li>
<li>我们都是前端工程师</li>
</ul>
</div>
<!-- modules -->
<div id="express" class="step big" style="width: 1200px;" data-x="2000" data-y="4600" data-z="-5000" data-rotate="90">
<h3>Web 框架</h3>
<h1><span class="g">Express</span></h1>
</div>
<div class="step big" data-x="1200" data-y="4600" data-z="-5000" data-rotate="180">
<ul>
<li>小巧灵活</li>
<li>工具丰富</li>
<li>容易调教</li>
</ul>
</div>
<div class="step big" data-x="2700" data-y="6600" data-z="-5000" data-rotate="90">
<h1><span class="b">大量中间件</span></h1>
</div>
<div id="jade" class="step big" data-x="2000" data-y="4600" data-z="-10000" data-rotate="180">
<h3>模板引擎</h3>
<h1><span class="jade">Jade</span></h1>
</div>
<div class="step big" data-x="2000" data-y="4000" data-z="-10000" data-rotate="180" data-rotate-x="30">
<h3 class="g">同时支持</h3>
<h2>浏览器端渲染<br/>服务器端渲染</h2>
</div>
<div class="step slide" data-x="2000" data-y="3200" data-z="-10000" data-rotate="180" data-rotate-x="-30">
<h1 class="g">For what purpose ?</h1>
<ul>
<li>前后统一</li>
<li>减少请求</li>
<li><span class="r">富客户端</span></li>
</ul>
</div>
<div class="step big" data-x="200" data-y="1200" data-z="-5000" data-rotate="360">
<h1 class="r">坑</h1>
</div>
<div class="step slide" data-x="200" data-y="1200" data-z="-15000">
<h1 class="r">Jade 模板引擎使用 with 语句</h1>
</div>
<div class="step slide" data-x="1400" data-y="1200" data-z="-15000">
<pre><code><span class="comment">// with 语句</span>
<span class="kw">var</span> user = { <span class="key">name</span>: <span class="str">'foo'</span> };
<span class="r">with</span> (user) {
<span class="kw">var</span> name = <span class="str">'bar'</span>;
}
console.log(user.name);
<span class="comment">// output is 'bar'</span>
</code></pre>
</div>
<div class="step slide" data-x="2600" data-y="1200" data-z="-15000">
<h1 class="r">with 语句的问题</h1>
<ul>
<li>Consused</li>
<li>Slow</li>
<li>Deprecated</li>
</ul>
</div>
<div class="step slide" data-x="3800" data-y="1200" data-z="-15000">
<h1 class="g">解决办法</h1>
<h4 class="r">不使用 with 语句</h4>
</div>
<div class="step slide" data-x="3800" data-y="1200" data-z="-15000" data-rotate-y="90">
<h1>Jade each 语句</h1>
<span class="r">生成的代码太长</span>
</div>
<div class="step slide" data-x="4800" data-y="1200" data-z="-15000" data-rotate-y="90">
<h1 class="g">解决办法</h1>
<span>去掉用不到的</span>
</div>
<!--<div id="mootools" class="step big" data-x="5500" data-y="5600" data-z="-20000" data-rotate="90">-->
<!--<h3>Thank you, <span class="friend">old friend</span></h3>-->
<!--<h1 class="mootools" alt="mootools">mootools</h1>-->
<!--</div>-->
<!-- huaban app server -->
<div id="app" class="step big" data-x="4500" data-y="6600" data-z="-35000">
<h1><span class="r">花瓣</span><br /> <span class="g">App Server</span></h1>
</div>
<div class="step big" style="width: 1200px;" data-x="5500" data-y="6600" data-z="-35000">
<h1>实现</h1>
<h1> = <span class="modules" style="font-size: .7em;">Modules</span> + <span class="r" style="font-size: .7em;">Services</span></h1>
</div>
<div class="step big" style="width: 1200px;" data-x="5500" data-y="7450" data-z="-35000" data-rotate="90">
<h1><span class="g">Faster</span> than <span class="r">C</span> ?</h1>
</div>
<div id="story" class="step big" data-x="-2300" data-y="7450" data-z="-35000" data-rotate="90">
<h1>A story</h1>
</div>
<div class="step big" data-x="-6300" data-y="7450" data-z="-35000" data-rotate="90">
<span>关于</span>
<h1><span class="mysql-my">My</span><span class="mysql-sql">SQL</span> 客户端</h1>
</div>
<div class="step big" data-x="-9300" data-y="7450" data-z="-35000" data-rotate="90">
<img src="img/a-b.png">
</div>
<div class="step big" data-x="-9600" data-y="7450" data-z="-25000" data-rotate="90">
<img src="img/a-b-c.png">
</div>
<div class="step big" data-x="-9900" data-y="7450" data-z="-15000" data-rotate="90">
<img src="img/a-b-c-d.png">
</div>
<div class="step big" data-x="-10200" data-y="7450" data-z="-5000" data-rotate="90">
<img src="img/bar.png">
</div>
<div class="step big" data-x="-10500" data-y="7450" data-z="5000" data-rotate="90">
<h1>mysql<br/>2.0.0-alpha4</h1>
</div>
<div class="step big" data-x="-10200" data-y="7450" data-z="15000" data-rotate="90">
<h1><span class="g">性能很好</span><br/><span class="r">小心有</span><span class="r">坑</span></h1>
</div>
<div class="step slide" data-x="-9300" data-y="7450" data-z="-45000" data-rotate="90">
<!--<div class="step slide" data-x="-10500" data-y="7800" data-z="5000" data-rotate="160">-->
<pre style="font-size: 36px;"><code><span class="comment" style="font-size: 30px;">// node_modules/mysql/lib/protocol/packets/RowDataPacket.js</span>
<span class="kw">var</span> numberString = parser.<strong class="hl">parseLengthCodedString</strong>();
<span class="rt">return</span> (numberString === <span class="kw">null</span>
|| (field.zeroFill && numberString[0] == "0"))
? <strong class="hl">numberString</strong>
: Number(numberString);
</code>
</pre>
</div>
<div id="npm" class="step big" data-x="-25000" data-y="10000" data-z="-12000">
<h3>Thank you! </h3>
<h1 style="margin-top: 0.4em;">
<img src="img/npm.png" alt="npm" />
</h1>
</div>
<div class="step" style="width: 1200px;" data-x="-25000" data-y="10000" data-z="3000" data-rotate="180">
<ul id="modules">
<li class="underscore">Underscore.js</li>
<li class="qs">qs</li>
<li class="jsdom">jsdom</li>
<li class="jade">jade</li>
<li class="should">should</li>
<li class="async">async</li>
<li class="validator">validator</li>
<li class="seq">Seq</li>
<li class="mocha">mocha</li>
<li class="mysql">mysql</li>
<li class="mysql-pool">mysql-pool</li>
<li class="hiredis">hiredis</li>
<li class="memcached">memcached</li>
<li class="express">Express</li>
<li class="connect">Connect</li>
<li class="tunnel">tunnel</li>
<li class="should">should</li>
<li class="supertest">Supertest</li>
<li class="request">request</li>
</ul>
</div>
<!-- pic storage -->
<div id="storage" class="step slide" data-x="5500" data-y="6000" data-z="-15000">
<h3>图片存储服务</h3>
<ul>
<li>安全、稳定</li>
<li>CDN 加速</li>
<li>伸缩自如</li>
<li>动态缩略图</li>
</ul>
</div>
<div id="upyun" class="step big" data-x="7000" data-y="6000" data-z="-35000">
<h1>又拍<span class="b">云存储</span></h1>
</div>
<div class="step big" data-x="7000" data-y="8000" data-z="-35000" data-rotate="225">
<h1>回调多了<br/>难免有<span class="r">坑</span></h1>
</div>
<div id="callback" class="step slide" style="width: 1200px;" data-x="5000" data-y="2000" data-z="-25000" data-rotate="225">
<h3><span class="y">callback function</span></h3>
<pre style="font-size: 40px;"><span class="comment">// e.g. </span>
<code>User.load(user_id, <span class="kw">function</span>(err, user){
Profile.load(user_id, <span class="kw">function</span>(err, profile){
Pin.loadUserPins(user_id, opts, <span class="kw">function</span>(err, pins){
Board.load(pin.board_id, <span class="kw">function</span>(err, board){
<strong class="comment">// <span class="r">坑</span>爹啊,后面都看不见了</strong>
});
});
});
});
</code>
</pre>
</div>
<div id="seq" class="step big" data-x="36500" data-y="8450" data-z="-35000" data-scale="3">
<h1><span class="y">Seq</span></h1>
</div>
<div class="step big" data-x="36500" data-y="9450" data-z="-35000" data-scale="3" data-rotate-x="-90">
<pre style="font-size: 30px;"><code><span class="kw">var</span> Seq = require('seq');
Seq()
.seq(<span class="kw">function</span>(){
<span class="comment">// do something</span>
Pin.loadUserPins(user_id, opts, <span class="kw">this</span>);
})
.flatten()
.parEach(<span class="num">5</span>, <span class="kw">function</span>(pin){
<span class="comment">// do something in parallel</span>
})
.seq(<span class="kw">function</span>(){
<span class="comment">// do something</span>
})
.catch(<span class="kw">function</span>(err){
<span class="comment">// catch exception</span>
});
</code>
</pre>
</div>
<div class="step big" data-x="36500" data-y="11450" data-z="-35000" data-rotate-x="-180">
<h1>又跳进一个<span class="r">坑</span></h1>
</div>
<div class="step big" data-x="36500" data-y="22450" data-z="-35000">
<h1 class="g">大量消耗 CPU</h1>
</div>
<div id="async" class="step big" data-x="38000" data-y="22450" data-z="-35000" data-rotate-y="40">
<h1 class="g">async</h1>
</div>
<div class="step slide" data-x="38000" data-y="22450" data-z="-37000" data-rotate-y="80">
<h3 class="g">CPU 降了,但是 . . .</h3>
</div>
<div class="step slide" data-x="28000" data-y="14450" data-z="-37000">
<pre style="font-size: 40px;"><code><span class="kw">var</span> async = require(<span class="str">'async'</span>);
async.waterfall([
<span class="kw">function</span>(next){
<span class="comment">// e.g. load user</span>
},
<span class="kw">function</span>(user, next){
<span class="comment">// load something</span>
}
], function(err, result){
<span class="kw">if</span> (err) callback(err);
<span class="comment">// return something</span>
});
</code></pre>
</div>
<div class="step big" data-x="28000" data-y="24450" data-z="-8000">
<h1>还 有 <span class="r">坑</span></h1>
</div>
<div class="step slide" data-x="28000" data-y="28450" data-z="-37000">
<pre style="font-size: 36px;"><code><span class="comment">// async.js</span>
<span class="kw">var</span> args = Array.prototype.<strong class="hl">slice</strong>.call(arguments, <span class="num">1</span>);
<span class="kw">var</span> next = iterator.next();
<span class="kw">if</span> (next) {
args.<strong class="hl">push</strong>(wrapIterator(next));
}
<span class="kw">else</span> {
args.<strong class="hl">push</strong>(callback);
}
async.nextTick(<span class="kw">function</span> () {
iterator.apply(null, args);
});
</code></pre>
</div>
<div class="step slide" data-x="28000" data-y="30450" data-z="-37000">
<pre style="font-size: 40px;"><code><span class="kw">var</span> async = require(<span class="str">'async'</span>);
async.waterfall([
<span class="kw">function</span>(next){
<span class="comment">// e.g. load user</span>
},
<span class="kw">function</span>(<strong class="hl">user</strong>, <strong class="hl">next</strong>){
<span class="comment">// 小心!别踩到</span><span class="r">坑</span><span class="comment">里了</span>
<span class="comment">// user may become next callback</span>
<span class="comment">// next may be undefined</span>
}
], function(err, result){
<span class="comment">// return something</span>
});
</code></pre>
</div>
<div class="step slide" data-x="28000" data-y="32050" data-z="-37000">
<h3>强制规范你的代码</h3>
<pre style="font-size: 40px;"><code><span class="kw">function</span> doSomething(arg, callback) {
<span class="comment">// do something</span>
<span class="kw">if</span> (err) <span class="rt">return</span> callback(err);
<span class="kw">if</span> (some_test) {
callback(<strong class="kw">null</strong>, <strong class="kw">null</strong>);
} <span class="kw">else</span> {
callback(<strong class="kw">null</strong>, result);
}
}
</code></pre>
</div>
<div id="testing" class="step big" data-x="28000" data-y="32050" data-z="-30000">
<h1>测试框架</h1>
<ul>
<li>Mocha</li>
<li>Supertest</li>
<li>PhantomJS</li>
<li>Zombie</li>
</ul>
</div>
<!-- tasks -->
<div id="tasks" class="step slide" data-x="28500" data-y="35000" data-z="-25000" data-rotate="90">
<h3 class="g">耗时操作</h3>
<ul>
<li>Timeline pushing</li>
<li><span class="y">Solr</span> indexing</li>
<li>Batch operation: delete board</li>
<li><span class="r">Weibo</span> sharing</li>
</ul>
</div>
<div class="step big bg" data-x="29500" data-y="35000" data-z="-25000" data-rotate="90">
<h1 class="g">必须从请求中脱离出来</h1>
</div>
<div class="step big bg" data-x="30500" data-y="35000" data-z="-25000" data-rotate="90">
<h1 class="g">要有任务系统</h1>
</div>
<div class="step big" data-x="32450" data-y="38000" data-z="-15000" data-rotate="180">
<h2 class="g">什么样的任务系统</h2>
</div>
<div class="step big" data-x="32750" data-y="38600" data-z="-15000" data-rotate="90">
<h4 class="g">它需要满足:</h4>
</div>
<div class="step" style="width: 700px;" data-x="32600" data-y="38600" data-z="-15000" data-rotate="90">
<li>基于事件/消息</li>
</div>
<div class="step" style="width: 700px;" data-x="32500" data-y="38600" data-z="-15000" data-rotate="90">
<li>工作进程管理</li>
</div>
<div class="step" style="width: 700px;" data-x="32400" data-y="38600" data-z="-15000" data-rotate="90">
<li>容错性</li>
</div>
<div class="step" style="width: 700px;" data-x="32300" data-y="38600" data-z="-15000" data-rotate="90">
<li>消息可持久化</li>
</div>
<div class="step" style="width: 700px;" data-x="32200" data-y="38600" data-z="-15000" data-rotate="90">
<li>Cast / Call</li>
</div>
<div class="step" style="width: 700px;" data-x="32100" data-y="38600" data-z="-15000" data-rotate="90">
<li>分布式的</li>
</div>
<div id="petaline" class="step" data-x="34500" data-y="30500" data-z="-10000" data-rotate="90">
<img src="img/petaline_arch.png" style="float: left;" />
<div style="width: 600px;float: right;">
<ul class="small">
<li><span class="b">Erlang/OTP</span></li>
<li><span class="y">Riak Core</span></li>
<li>N<span class="g">o</span>de<span class="g">.JS</span> worker</li>
<li><span class="r">leveldb</span></li>
</ul>
</div>
</div>
<div id="arch" class="step center" data-x="34500" data-y="31500" data-z="-10000" data-rotate="90" data-rotate-x="-50">
<img src="img/arch_overview.png" />
</div>
<div id="todo" class="step slide" data-x="34500" data-y="32500" data-z="-10000">
<h4 class="g">More things TODO:</h4>
<ul>
<li><span class="redis">Redis</span> cluster</li>
<li>Express Session 改进</li>
<li><span class="petal">Petaline</span> 更多语言、协议支持</li>
<li>完善测试</li>
<li>real-time support</li>
</ul>
</div>
<div class="step big" style="width: 1200px;" data-x="34500" data-y="33500" data-z="-10000">
<h3 style="text-align: center;"><span class="b">J</span>ava<span class="r">S</span>cript 强大,但是也有糟粕</h3>
</div>
<div class="step big" style="width: 1200px;" data-x="34500" data-y="34500" data-z="-10000">
<!--<h1>Join us<br/><span class="g">hr</span>@<span class="r">huaban</span>.com</h1>-->
<h3 style="text-align: center;">N<span class="g">o</span>de<span class="g">.JS</span> 好玩,偶尔也挺<span class="r">坑</span>爹</h3>
</div>
<div id="jobs" class="step big" style="width: 1200px;" data-x="34500" data-y="35500" data-z="-10000">
<h3 style="text-align: center;">Join us! 让我们一起来踩<span class="r">坑</span>吧!</h3>
<h1 style="text-align: center;"><span class="g">hr</span>@<span class="r">huaban</span>.com</h1>
</div>
<div id="thanks" class="step big center" data-x="37000" data-y="30500" data-z="-30000" data-rotate="380" data-scale="4">
<h1>谢谢观看</h1>
<img src="img/logo.png" />
</div>
<div id="powerd-by" class="step big" data-x="30000" data-y="53500" data-z="50000">
<h1>Powered by<br/><span class="g">impress.js</span></h1>
</div>
</div>
<div class="hint">
<p>Use a spacebar or arrow keys to navigate</p>
</div>
<script>
if ("ontouchstart" in document.documentElement) {
document.querySelector(".hint").innerHTML = "<p>Tap on the left or right to navigate</p>";
}
</script>
<script src="js/impress.js"></script>
<script>impress().init();</script>
</body>
</html>