remove CSS from RSS items
[HTML5TV.git] / media / JSConf.eu-Node.js / video.srt.yaml
1 ---
2 - 4.3
3 - 5.3
4 - '[1] node.js'
5 ---
6 - 13.4
7 - 14.4
8 - '[2] node.js in brief: Server-side Javascript Built on Google’s V8 Evented, non-blocking I/O. Similar to EventMachine or Twisted. CommonJS module system. 8000 lines of C/C++, 2000 lines of Javascript, 14 contributors.'
9 ---
10 - 43.0
11 - 44
12 - '[3] I/O needs to be done differently.'
13 ---
14 - 72.0
15 - 73
16 - '[4] Many web applications have code like this:'
17 ---
18 - 95.7
19 - 96.7
20 - '[5] In many cases, just waiting for the response.'
21 ---
22 - 127.2
23 - 128.2
24 - '[6] I/O latency L1: 3 cycles L2: 14 cycles RAM: 250 cycles DISK: 41,000,000 cycles NETWORK: 240,000,000 cycles'
25 ---
26 - 166.4
27 - 167.4
28 - '[7] Better software can multitask. Other threads of execution can run while waiting.'
29 ---
30 - 183.5
31 - 184.5
32 - '[8] Is that the best that can be done? A look at Apache and NGINX.'
33 ---
34 - 203.5
35 - 204.5
36 - '[9] Apache vs NGINX'
37 ---
38 - 243.5
39 - 244.5
40 - '[10] Apache vs NGINX'
41 ---
42 - 307.5
43 - 308.5
44 - '[11] Apache vs NGINX'
45 ---
46 - 322.7
47 - 323.7
48 - '[12] Context switching is not free Execution stacks take up memory For massive concurrency, cannot use an OS thread for each connection.'
49 ---
50 - 391.7
51 - 392.7
52 - '[13] Green threads or coroutines can improve the situation dramatically BUT there is still machinery involved to create the illusion of holding execution on I/O.'
53 ---
54 - 438.0
55 - 439
56 - '[14] Threaded concurrency is a leaky abstraction.'
57 ---
58 - 460.4
59 - 461.4
60 - '[15] Code like this'
61 ---
62 - 496.0
63 - 497
64 - '[16] But a line of code like this'
65 ---
66 - 535.1
67 - 536.1
68 - '[17] db.query("select..", function (result) { // use result });'
69 ---
70 - 547.8
71 - 548.8
72 - '[18] So why isn’t everyone using event loops, callbacks, and non-blocking I/O? For reasons both cultural and infrastructural.'
73 ---
74 - 574.9
75 - 575.9
76 - '[19] Cultural Bias'
77 ---
78 - 609.8
79 - 610.8
80 - '[20] Cultural Bias'
81 ---
82 - 640.9
83 - 641.9
84 - '[21] Missing Infrastructure'
85 ---
86 - 672.4
87 - 673.4
88 - '[22] Missing Infrastructure'
89 ---
90 - 725.1
91 - 726.1
92 - '[23] Too Much Infrastructure'
93 ---
94 - 779.3
95 - 780.3
96 - '[24] Too Much Infrastructure'
97 ---
98 - 796.1
99 - 797.1
100 - '[25] Javascript designed specifically to be used with an event loop: Anonymous functions, closures. Only one callback at a time. I/O through DOM event callbacks.'
101 ---
102 - 832.2
103 - 833.2
104 - '[26] The culture of Javascript is already geared towards evented programming.'
105 ---
106 - 857.9
107 - 858.9
108 - '[27] This is the node.js project: To provide a purely evented, non-blocking infrastructure to script highly concurrent programs.'
109 ---
110 - 888.2
111 - 889.2
112 - '[28] Design Goals'
113 ---
114 - 926.4
115 - 927.4
116 - '[29] Design Goals'
117 ---
118 - 982.7
119 - 983.7
120 - '[30] Design Goals'
121 ---
122 - 1007.0
123 - 1008
124 - '[31] Design Goals'
125 ---
126 - 1041.6
127 - 1042.6
128 - '[32] Design Goals'
129 ---
130 - 1080.6
131 - 1081.6
132 - '[33] Usage and Examples'
133 ---
134 - 1087.0
135 - 1088
136 - '[34] Download, configure, compile, and make install it.'
137 ---
138 - 1107.7
139 - 1108.7
140 - '[35] 1 2 3 4 5 6'
141 ---
142 - 1152.0
143 - 1153
144 - '[36] 1 2 3 4 5 6'
145 ---
146 - 1168.3
147 - 1169.3
148 - '[37] % node hello_world.js hello'
149 ---
150 - 1182.5
151 - 1183.5
152 - '[38] Change the “hello world” program to loop forever, but print an exit message when the user kills it. We will use the special object process and the "SIGINT" signal.'
153 ---
154 - 1212.2
155 - 1213.2
156 - '[39] 1 2 3 4 5 6 7 8 9 10 11'
157 ---
158 - 1263.2
159 - 1264.2
160 - '[40] process.addListener("SIGINT", ...);'
161 ---
162 - 1291.2
163 - 1292.2
164 - '[41] Also:'
165 ---
166 - 1302.4
167 - 1303.4
168 - '[42] Like process, many other objects in Node emit events.'
169 ---
170 - 1318.2
171 - 1319.2
172 - '[43] A TCP server emits a "connection" event each time someone connects. An HTTP upload emits a "body" event on each packet.'
173 ---
174 - 1345.4
175 - 1346.4
176 - '[44] All objects which emit events are are instances of process.EventEmitter.'
177 ---
178 - 1354.8
179 - 1355.8
180 - '[45] Write a program which: starts a TCP server on port 8000 send the peer a message close the connection'
181 ---
182 - 1373.7
183 - 1374.7
184 - '[46] 1 2 3 4 5 6 7 8 9 10'
185 ---
186 - 1404.8
187 - 1405.8
188 - '[47] % node server.js & [1] 9120 % telnet localhost 8000 Trying 127.0.0.1... Connected to localhost. Escape character is ’ˆ]’. hello! Connection closed by foreign host. %'
189 ---
190 - 1425.4
191 - 1426.4
192 - '[48] The "connection" listener can be provided as the first argument to tcp.createServer(), so the program can be simplified:'
193 ---
194 - 1440.9
195 - 1441.9
196 - '[49] 1 2 3 4 5'
197 ---
198 - 1447.0
199 - 1448
200 - '[50] File I/O is non-blocking too. (Something typically hard to do.)'
201 ---
202 - 1471.1
203 - 1472.1
204 - '[51] As an example, a program that outputs the last time /etc/passwd was modified:'
205 ---
206 - 1517.0
207 - 1518
208 - '[52] A promise is a kind of EventEmitter which emits either "success" or "error". (But not both.) All file operations return a promise.'
209 ---
210 - 1563.0
211 - 1564
212 - '[53] promise.addCallback(cb)'
213 ---
214 - 1572.2
215 - 1573.2
216 - '[54] Simple HTTP Server:'
217 ---
218 - 1666.8
219 - 1667.8
220 - '[55] % node http_server.js & [4] 27355 % curl -i http://localhost:8000/ HTTP/1.1 200 OK Content-Type: text/plain Connection: keep-alive Transfer-Encoding: chunked Hello World %'
221 ---
222 - 1680.0
223 - 1681
224 - '[56] Streaming HTTP Server:'
225 ---
226 - 1759.1
227 - 1760.1
228 - '[57] % node http_server2.js & [4] 27355 % curl http://localhost:8000/ Hello'
229 ---
230 - 1773.8
231 - 1774.8
232 - '[58] 1 2 3 4 5'
233 ---
234 - 1815.5
235 - 1816.5
236 - '[59] But Node never forces buffering'
237 ---
238 - 1857.9
239 - 1858.9
240 - '[60] 1 2 3 4 5 6 7 8 9 10 11 12 13'
241 ---
242 - 1918.0
243 - 1919
244 - '[61] Demo / Experiment'
245 ---
246 - 2330.2
247 - 2331.2
248 - '[62] Internal Design'
249 ---
250 - 2336.4
251 - 2337.4
252 - '[63] V8 (Google) libev event loop library (Marc Lehmann) libeio thread pool library (Marc Lehmann) http-parser a ragel HTTP parser (Me) evcom stream socket library on top of libev (Me) udns non-blocking DNS resolver (Michael Tokarev)'
253 ---
254 - 2385.4
255 - 2386.4
256 - '[64] Blocking (or possibly blocking) system calls are executed in the thread pool. Signal handlers and thread pool callbacks are marshaled back into the main thread via a pipe.'
257 ---
258 - 2466.4
259 - 2467.4
260 - '[65] % node myscript.js < hugefile.txt'
261 ---
262 - 2526.8
263 - 2527.8
264 - '[66] Solution: Start a pipe, and a “pumping thread”. Pump data from blocking fd into pipe. Main thread can poll for data on the pipe.'
265 ---
266 - 2564.7
267 - 2565.7
268 - '[67] Future'
269 ---
270 - 2639.0
271 - 2640
272 - '[68] Future'
273 ---
274 - 2675.1
275 - 2676.1
276 - '[69] Questions...?'