/
index.html
505 lines (451 loc) · 16.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
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie6" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<html>
<head>
<meta charset="utf-8">
<title>Node.js in the Cloud</title>
<meta name="description" content="NovaNode talk - 'Getting Started with Node.js in the Cloud'">
<meta name="author" content="Ryan Roemer">
<meta name="viewport" content="width=1024, user-scalable=no">
<link rel="stylesheet" href="./slides/core/deck.core.css">
<link rel="stylesheet" href="./slides/extensions/goto/deck.goto.css">
<link rel="stylesheet" href="./slides/extensions/menu/deck.menu.css">
<link rel="stylesheet" href="./slides/extensions/navigation/deck.navigation.css">
<link rel="stylesheet" href="./slides/extensions/status/deck.status.css">
<link rel="stylesheet" href="./slides/extensions/hash/deck.hash.css">
<link rel="stylesheet" href="./slides/themes/transition/horizontal-slide.css">
<link rel="stylesheet" href="./slides/plugins/codemirror/deck.codemirror.css">
<link rel="stylesheet" href="./slides/plugins/codemirror/themes/elegant.css">
<!--
<link rel="stylesheet" href="./slides/plugins/codemirror/themes/cobalt.css">
<link rel="stylesheet" href="./slides/plugins/codemirror/themes/default.css">
<link rel="stylesheet" href="./slides/plugins/codemirror/themes/neat.css">
<link rel="stylesheet" href="./slides/plugins/codemirror/themes/night.css">
-->
<link rel="stylesheet" href="./slides/custom/slides.css">
<script src="http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.5.3/modernizr.min.js"></script>
</head>
<body class="deck-container">
<!-- GitHub Banner -->
<a href="http://github.com/ryan-roemer/novanode-cloud-talk/"><img style="position: fixed; top: 0; right: 0; border: 0;" src="https://a248.e.akamai.net/assets.github.com/img/71eeaab9d563c2b3c590319b398dd35683265e85/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677261795f3664366436642e706e67" alt="Fork me on GitHub"></a>
<section class="slide" id="title-slide">
<h1>Getting Started with Node.js in the Cloud</h1>
</section>
<!--
<section class="slide" id="talk">
<h2>Let's chat...</h2>
<div class="link">
<br />
<a id="talk" href="http://talk.sdsandbox.com">talk.sdsandbox.com</a>
</div>
<br /><br />
<p style="text-align: center"><em>(Thanks to GitHub user
<a href="https://github.com/steffenwt">steffenwt</a><br /> for
<a href="https://github.com/steffenwt/nodejs-pub-sub-chat-demo">nodejs-pub-sub-chat-demo</a>)
</em></p>
</section>
-->
<section class="slide" id="node-introduction">
<h2>Node.js</h2>
<ul>
<li><strong>Evented</strong></li>
<li><strong>Non-blocking</strong></li>
<li><strong>Asynchronous</strong></li>
<li><strong>Lightweight</strong></li>
<li><strong>Scalable</strong></li>
<li><strong>Fast</strong></li>
</ul>
</section>
<section class="slide" id="cloud-introduction">
<h2>The "Cloud"</h2>
<ul>
<li><strong>Scalable</strong></li>
<li><strong>Elastic</strong></li>
<li><strong>Flexible</strong></li>
<li><strong>"Building blocks"</strong> - vast array of services and products</li>
</ul>
</section>
<section class="slide" id="together">
<h2>Node.js in the Cloud</h2>
<p>
We can build <strong>scalable</strong>, <strong>efficient</strong>, and
<strong>fast</strong> web applications and services.
</p>
<p>
At the <em>micro</em>-level, Node.js applications can support large numbers
of connections and glue together many different services.
</p>
<p>
At the <em>macro</em>-level, the cloud allows us to scale out servers, and
provide various backing components.
</p>
</section>
<section class="slide" id="use-cases">
<h2>Use Cases</h2>
<ul>
<li>Real-time web applications.</li>
<li>
Mobile application backends.
(<a href="http://engineering.linkedin.com/tags/nodejs"
>LinkedIn Mobile</a>)
</li>
<li>
API endpoints.
(<a href="http://www.ebaytechblog.com/2011/11/30/announcing-ql-io/"
>eBay + ql.io</a>)
</li>
</ul>
<img class="bordered"
src="./slides/custom/suggest.png" alt="Application traffic" />
</section>
<section class="slide" id="example-app">
<h2>Anti-Use Cases</h2>
<p>Some situations where Node.js <em>may</em> not be the best choice.</p>
<ul>
<li>CPU-bound applications.</li>
<li>Simple CRUD applications.</li>
<li>Need a library in a specific language.</li>
</ul>
</section>
<section class="slide" id="paas-providers">
<h2>PAAS Providers</h2>
<p>Node.js Platform-as-a-Service offerings:</p>
<ul>
<li><strong><a href="http://www.heroku.com/">Heroku</a></strong></li>
<li><strong><a href="http://joyentcloud.com/">Joyent</a></strong></li>
<li><strong><a href="http://www.cloudfoundry.com/">Cloud Foundry</a></strong></li>
<li><strong><a href="http://nodester.com/">Nodester</a></strong></li>
<li><strong><a href="http://nodejitsu.com/">NodeJitsu</a></strong></li>
<li><strong><a href="http://www.windowsazure.com/en-us/develop/nodejs/">Microsoft Azure</a></strong></li>
</ul>
</section>
<section class="slide" id="iaas-providers">
<h2>IAAS Providers</h2>
<p>Infrastructure-as-a-Service providers. Host it yourself!</p>
<ul>
<li><strong><a href="http://aws.amazon.com/">Amazon Web Services</a></strong></li>
<li><strong><a href="http://www.rackspace.com/cloud/">Rackspace Cloud</a></strong></li>
<li><em>... and many others ...</em></li>
</ul>
</section>
<section class="slide" id="heroku-intro">
<h2>Heroku</h2>
<ul>
<li>Deploy Node.js (and other) apps straight from
<a href="http://git-scm.com/">git</a>.</li>
<li>Pay-per-use model.</li>
<li>Scalable web and worker servers.</li>
<li>
Numerous
<a href="https://addons.heroku.com/">add-ons</a>
(database, mail, logging, etc. services).</li>
<li>Integrated in the Amazon Web Services cloud.</li>
</ul>
<img src="./slides/custom/heroku-logo-light-300x100.png" alt="Heroku logo" />
</section>
<section class="slide" id="heroku-setup">
<h2>Hooking up Heroku</h2>
<p>
Heroku provides an excellent Node.js guide that can get you up and running.
(<a href="http://devcenter.heroku.com/articles/nodejs"
>devcenter.heroku.com/articles/nodejs</a>)
</p>
<ul>
<li>
<strong>Sign up</strong>:
<a href="https://api.heroku.com/signup">api.heroku.com/signup</a>
</li>
<li>
<strong>Log in</strong>:
<a href="https://api.heroku.com/login">api.heroku.com/login</a>
</li>
<li>
<strong>Install Heroku</strong>: (<em>See Node guide</em>)
</li>
<li>
<strong>Install NVM</strong>:
<a href="https://github.com/creationix/nvm">github.com/creationix/nvm</a>
(<em>Highly recommended for development</em>)
</li>
</ul>
</section>
<section class="slide" id="hello-app">
<h2>Hello World!</h2>
<p>Here is everyone's <em>first</em> Node.js application:</p>
<div>
<div id="code" name="code" class="code" mode="javascript" style="display: none;"
>// Run with: `node server-hello.js`
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {
'content-type': "text/html"
});
res.end("<h1>Hello World!</h1>")
}).listen(2001);</div>
</div>
<br />
<p>
Let's try it in
<a href="http://127.0.0.1:2001">development</a>...
</p>
<p>
And, let's see a <em>slightly</em> more
<a href="http://127.0.0.1:2002">enhanced version</a>...
</p>
</section>
<section class="slide" id="package-app">
<h2>Package the App</h2>
<p>
We have to package things up appropriately.
</p>
<ul>
<li>
Create a Git repository.
(<a href="https://github.com/ryan-roemer/novanode-cloud-talk"
>github.com/ryan-roemer/novanode-cloud-talk</a>)
</li>
<li>Add a "<code>package.json</code>" file.</li>
<li>Add a Heroku "<code>Procfile</code>" file.</li>
</ul>
<pre><code>web: node server-hello.js</code></pre>
<p>
This tells Heroku to run "<code>server-hello.js</code>"
as a Node.js web application.
</p>
</section>
<section class="slide" id="deploy-app">
<h2>Deployment</h2>
<p>
Now that we've developed our app, we're ready for prime time!
</p>
<span>Create the Heroku application:</span>
<pre><code>$ heroku create --stack cedar</code></pre>
<span>Rename the application:</span>
<pre><code>$ heroku rename novanode</code></pre>
<span>Deploy!</span>
<pre><code>$ git push heroku master</code></pre>
</section>
<section class="slide" id="app-checks">
<h2>We're Live!</h2>
<p>
Get ready for "hello world" goodness at:
<a href="http://novanode.herokuapp.com/">novanode.herokuapp.com</a>
</p>
<span>Check Heroku processes:</span>
<pre><code>$ heroku ps</code></pre>
<span>Review our logs:</span>
<pre><code>$ heroku logs</code></pre>
<span>
... and many other commands. For example, open a server shell:
</span>
<pre><code>$ heroku run bash</code></pre>
</section>
<section class="slide" id="app-scale">
<h2>Let's Scale!</h2>
<p>Scaling with Heroku is incredibly easy and fast.</p>
<span>"<a href="http://en.wikipedia.org/wiki/Up_to_eleven"
>These go to eleven.</a>"</span>
<pre><code>$ heroku ps:scale web=11</code></pre>
<span>Review our massive service:</span>
<pre><code>$ heroku ps</code></pre>
<span>But let's not get carried away:</span>
<pre><code>$ heroku ps:scale web=1</code></pre>
</section>
<section class="slide" id="chat-app">
<h2>Chat Server</h2>
<p>
"Hello world" is scalable, but not useful.
Let's try something that leverages Node.js's strengths:
<strong>chat!</strong>
</p>
<ul>
<li>
<a href="https://github.com/steffenwt/nodejs-pub-sub-chat-demo">nodejs-pub-sub-chat-demo</a>
</li>
<li>
Simple
<a href="https://github.com/ryan-roemer/novanode-cloud-talk/blob/master/chat/index.html">HTML/JS client</a> and
<a href="https://github.com/ryan-roemer/novanode-cloud-talk/blob/master/chat/app_redis.js">Node.js server</a>.
</li>
<li>
Uses <a href="http://redis.io/">Redis</a>'
<a href="http://redis.io/topics/pubsub">Pub/Sub</a> feature to
allow clients to subscribe to channels and publish messages.
</li>
<li>
Lots of connections that we'll leave open.
Clients will use websockets, AJAX long-polling, etc. with
<a href="http://socket.io/">Socket.IO</a>.
</li>
</ul>
<p>
Let's try it out in
<a href="http://127.0.0.1:2000">development</a>...
</p>
</section>
<section class="slide" id="chat-prepare">
<h2>Prepare our Chat App</h2>
<span>
Add the <a href="https://addons.heroku.com/redistogo">Redis To Go</a>
add-on.
</span>
<pre><code>$ heroku addons:add redistogo:nano</code></pre>
<span>
Update our "<code>Procfile</code>" to point to the chat
server:
</span>
<pre><code>web: node chat/app_redis.js</code></pre>
<span>Deploy!</span>
<pre><code>$ git push heroku master</code></pre>
</section>
<section class="slide" id="heroku-chat">
<h2>Heroku Chat</h2>
<p>
And we're up at
<a href="http://novanode.herokuapp.com/">novanode.herokuapp.com</a>.
</p>
<p>
However, we're now using AJAX long-polling, which leads us into...
</p>
</section>
<section class="slide" id="paas-disads">
<h2 style="font-size: 2em;">Heroku / PAAS Gotcha's</h2>
<p>Sometimes you have to go with an IAAS or self-managed system.</p>
<ul>
<li>Lack of <strong>websockets</strong> support.</li>
<li><strong>Expense</strong> of scaling the core service and add-on's.</li>
<li>Outlier request <strong>latencies</strong>.</li>
<li>
<strong>Integrating</strong> Node.js with add-on's / services.
(Memcached).
</li>
<li>Limited monitoring, <strong>system insight</strong>.</li>
</ul>
</section>
<section class="slide" id="paas-advs">
<h2 style="font-size: 2em;">Heroku / PAAS Benefits</h2>
<p>But you can get a lot done in the Node.js PAAS ecosphere.</p>
<ul>
<li>Automatic application restarts on crashes.</li>
<li>Intelligent routing during application upgrades.</li>
<li>Rollback.</li>
<li>Integration with AWS. Runs in AWS, and can directly hook to RDS.</li>
<li>Takes care of virtually all operations issues.</li>
<li>First web server on <em>each</em> application is free!</li>
</ul>
</section>
<section class="slide" id="cloud-wrap-up">
<h2>Wrapping up the Cloud</h2>
<ul>
<li>
For prototyping and lightning speed development, Node.js PAAS
services are often the winning ticket.
</li>
<li>
For production, you'll often need look to IAAS providers.
We run in the Amazon cloud, and our Node.js apps run with low system
resource usage and minimal latency. We have full control over our
systems.
</li>
<li>
But like Node.js itself, offerings in the cloud are evolving at a
rapid pace, so be sure to check your options when you decide where and
how to roll out your Node.js applications.
</li>
</ul>
</section>
<section class="slide" id="example-app">
<h2>Reflections of a Node Developer</h2>
<ul>
<li>
JavaScript has its warts, but you can learn to love it.
</li>
<li>
Asynchronous programming ain't that bad.
(Especially compared to threads and locks).
</li>
<li>
Watch out for blocking code and missed callbacks.
</li>
<li>
The library ecosystem resembles the Wild West.
</li>
<li>
The community is responsive, growing, and eager to help.
</li>
<li>
Give it a try!
</li>
</ul>
</section>
<section class="slide" id="conclusion">
<h2>Thanks!</h2>
<br />
<div>
<strong>slides</strong>:
<a href="http://ryan-roemer.github.com/novanode-cloud-talk"
>bit.ly/novanode-cloud-talk</a>
</div>
<div>
<strong>source</strong>:
<a href="http://github.com/ryan-roemer/novanode-cloud-talk"
>bit.ly/novanode-cloud-source</a>
</div>
<hr />
<div>
<a href="https://twitter.com/#!/ryan_roemer">@ryan_roemer</a>
<span style="border-left: 1px solid #ccc; margin-left: 10px;"> </span>
<a href="mailto:ryan@loose-bits.com">ryan@loose-bits.com</a>
</div>
<div>
<a href="http://www.spanishdict.com/">SpanishDict.com</a> is
<a href="http://www.spanishdict.com/careers">hiring</a>!
</div>
</section>
<!-- deck.navigation snippet -->
<a href="#" class="deck-prev-link" title="Previous">←</a>
<a href="#" class="deck-next-link" title="Next">→</a>
<!-- deck.status snippet -->
<p class="deck-status">
<span class="deck-status-current"></span> /
<span class="deck-status-total"></span>
</p>
<!-- deck.goto snippet -->
<form action="." method="get" class="goto-form">
<label for="goto-slide">Go to slide:</label>
<input type="text" name="slidenum" id="goto-slide" list="goto-datalist">
<datalist id="goto-datalist"></datalist>
<input type="submit" value="Go">
</form>
<!-- deck.hash snippet -->
<a href="." title="Permalink to this slide" class="deck-permalink">#</a>
<!-- Late-bind JavaScript -->
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="./slides/core/deck.core.js"></script>
<script src="./slides/extensions/hash/deck.hash.js"></script>
<script src="./slides/extensions/menu/deck.menu.js"></script>
<script src="./slides/extensions/goto/deck.goto.js"></script>
<script src="./slides/extensions/status/deck.status.js"></script>
<script src="./slides/extensions/navigation/deck.navigation.js"></script>
<script src="./slides/plugins/codemirror/codemirror.js"></script>
<script src="./slides/plugins/codemirror/mode/javascript/javascript.js"></script>
<script src="./slides/plugins/codemirror/deck.codemirror.js"></script>
<!-- Initialize the deck. You can put this in an external file if desired. -->
<script>
$(function() {
$.deck('.slide', {
codemirror: {
lineNumbers: false,
theme: "elegant",
indentUnit: 2,
indentWithTabs: false,
runnable: false
}
});
});
</script>
</body>
</html>