Skip to content
This repository
Newer
Older
100644 241 lines (214 sloc) 9.286 kb
565becb8 » Urban Hafner
2009-06-05 XHTML compliant HTML and a few spelling fixes
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <style type="text/css">
5 ul {
6 padding: 0;
7 margin: 0;
8 }
9 </style>
10 <script type="text/javascript" src="sh_main.js"></script>
11 <script type="text/javascript" src="sh_javascript.min.js"></script>
12 <link type="text/css" rel="stylesheet" href="style.css" />
13 <link type="text/css" rel="stylesheet" href="sh_vim-dark.css" />
14 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
15 <title>node.js</title>
16 </head>
17 <body onload="sh_highlightDocument();">
18 <div id="toc">
19 <ol>
20 <li><a href="#audience">Audience</a></li>
21 <li><a href="#about">About</a></li>
22 <li><a href="#download">Download</a></li>
23 <li><a href="#build">Build</a></li>
b77e603e » ry
2009-06-27 add irc channel to website
24 <li><a href="#demo">Demo</a></li>
565becb8 » Urban Hafner
2009-06-05 XHTML compliant HTML and a few spelling fixes
25 <li><a href="#community">Community</a></li>
26 <li><a href="api.html">Documentation</a></li>
27 </ol>
28 </div>
29 <div id="content">
30
31 <h1><a href="http://tinyclouds.org/node">Node</a></h1>
32
33 <p id="introduction">
34 Purely event-based I/O for
35 <a href="http://code.google.com/p/v8/">V8 javascript</a>.
36 </p>
37
38 <p>
39 An example of a web server written with Node which responds with
40 "Hello World" after waiting two seconds:
41 </p>
42
43 <pre>
0640517a » ry
2009-06-30 fix example on website
44 node.http.createServer(function (req, res) {
b34792a4 » ry
2009-05-13 Add webpage. Very incomplete.
45 setTimeout(function () {
d0b59619 » ry
2009-05-17 Work on website styling.
46 res.sendHeader(200, [["Content-Type", "text/plain"]]);
47 res.sendBody("Hello World");
48 res.finish();
b34792a4 » ry
2009-05-13 Add webpage. Very incomplete.
49 }, 2000);
d0b59619 » ry
2009-05-17 Work on website styling.
50 }).listen(8000);
565becb8 » Urban Hafner
2009-06-05 XHTML compliant HTML and a few spelling fixes
51 puts("Server running at http://127.0.0.1:8000/");</pre>
52
53 <p>
54 To run the server, put the code into a file
55 <code>example.js</code> and execute it with the <code>node</code>
56 program
57 </p>
58 <pre class="sh_none">
59 % /usr/local/bin/node example.js
60 Server running at http://127.0.0.1:8000/</pre>
61
62 <p>
63 See the <a href="api.html">API documentation</a> for more
64 examples.
65 </p>
66
67 <h2 id="audience">Audience</h2>
68
69 <p>This project is for those interested in</p>
70 <ul>
71 <li>server-side javascript</li>
72 <li>developing evented servers</li>
73 <li>developing new web frameworks</li>
74 </ul>
75
76 <h2 id="about">About</h2>
77
78 <p>
79 Node's goal is to provide an easy way to build scalable network
80 programs. In the above example, the 2 second delay does not
81 prevent the server from handling new requests. Node tells the
82 operating system (through <code>epoll</code>, <code>kqueue</code>,
83 <code class="sh_none">/dev/poll</code>, or <code>select</code>)
84 that it should be notified when the 2 seconds are up or if a new
85 connection is made&mdash;then it goes to sleep. If someone new
86 connects, then it executes the callback, if the timeout expires,
87 it executes the inner callback. Each connection is only a small
88 heap allocation.
89 </p>
90
91 <p>
92 This is in contrast to today's more common model where OS threads
93 are employed for concurrency. Thread-based networking
94 <a href="http://www.sics.se/~joe/apachevsyaws.html">is</a>
95 <a href="http://www.kegel.com/c10k.html">relatively</a>
96 <a href="http://bulk.fefe.de/scalable-networking.pdf">inefficient</a>
97 <!-- TODO needs links -->
98 and very difficult to use.
99
100 Node will show much better memory efficiency under high-loads
101 <!-- TODO benchmark -->
102 than systems which allocate 2mb thread stacks for each connection.
103
104 Furthermore, users of Node are free from worries of dead-locking
105 the process&mdash;there are no locks. No function in Node
106 directly performs I/O, so the process never blocks. Because
107 nothing blocks, less-than-expert programmers are able to develop
108 fast systems.
109 </p>
110
111 <p>
112 Node is similar in design to systems like Ruby's
113 <a href="http://rubyeventmachine.com/">Event Machine</a>
114 or Python's <a href="http://twistedmatrix.com/">Twisted</a>.
115 Node takes the event model a bit further. For example, in other
116 systems there is always a blocking call to start the event-loop.
117 Typically one defines behavior through callbacks at the beginning
118 of a script and at the end starts a server through a call like
119 <code>EventMachine::run()</code>. In Node it works differently.
120 By default Node enters the event loop after executing the input
121 script. Node exits the event loop when there are no more callbacks
122 to perform. Like in traditional browser javascript, the event loop
123 is hidden from the user.
124 </p>
125
126 <p>
127 Node's HTTP API has grown out of my difficulties developing and
128 working with web servers. For example, streaming data through
129 most web frameworks is impossible. Or the oft-made false
130 assumption that all message headers have unique fields. Node
131 attempts to correct these and other problems in its API. Coupled
132 with Node's purely evented infrastructure, it will make a more
133 comprehensive foundation for future web libraries/frameworks.
134 </p>
135
136 <p>
137 <i>
138 But what about multiple-processor concurrency? Threads are
139 necessary to scale programs to multi-core computers.
140 </i>
141 The name <i>Node</i> should give some hint at how it is envisioned
142 being used. Processes are necessary to scale to multi-core
143 computers, not memory-sharing threads. The fundamentals of scalable
144 systems are fast networking and non-blocking design&mdash;the rest
1ec9f821 » ry
2009-06-12 fix typo
145 is message passing. In the future, I'd like Node to be able to
565becb8 » Urban Hafner
2009-06-05 XHTML compliant HTML and a few spelling fixes
146 spawn new processes (probably using the
147 <a href="http://www.whatwg.org/specs/web-workers/current-work/">
148 Web Workers API
149 </a>), but this is something that fits well into the current design.
150 </p>
151
152 <h2 id="download">Download</h2>
153
154 <p>
4cfc982c » ry
2009-06-11 bump version
155 <a href="http://github.com/ry/node/tree/master">git repo</a>
565becb8 » Urban Hafner
2009-06-05 XHTML compliant HTML and a few spelling fixes
156 </p>
157 <ul>
158 <li>
e10fbab0 » ry
2009-08-01 bump version
159 2009.08.01
160 <a href="http://s3.amazonaws.com/four.livejournal/20090801/node-0.1.2.tar.gz">node-0.1.2.tar.gz</a>
161 </li>
162 <li>
77d407df » ry
2009-07-27 bump version
163 2009.07.27
164 <a href="http://s3.amazonaws.com/four.livejournal/20090727/node-0.1.1.tar.gz">node-0.1.1.tar.gz</a>
165 </li>
166 <li>
813b5393 » ry
2009-06-30 bump version
167 2009.06.30
168 <a href="http://s3.amazonaws.com/four.livejournal/20090630/node-0.1.0.tar.gz">node-0.1.0.tar.gz</a>
169 </li>
170 <li>
fbe0be19 » ry
2009-06-24 bump version
171 2009.06.24
172 <a href="http://s3.amazonaws.com/four.livejournal/20090624/node-0.0.6.tar.gz">node-0.0.6.tar.gz</a>
173 </li>
174 <li>
ec5f3dba » ry
2009-06-18 bump version
175 2009.06.18
176 <a href="http://s3.amazonaws.com/four.livejournal/20090618/node-0.0.5.tar.gz">node-0.0.5.tar.gz</a>
177 </li>
178 <li>
f76c3dc3 » ry
2009-06-13 bump version
179 2009.06.13
180 <a href="http://s3.amazonaws.com/four.livejournal/20090613/node-0.0.4.tar.gz">node-0.0.4.tar.gz</a>
181 </li>
182 <li>
4cfc982c » ry
2009-06-11 bump version
183 2009.06.11
184 <a href="http://s3.amazonaws.com/four.livejournal/20090611/node-0.0.3.tar.gz">node-0.0.3.tar.gz</a>
185 </li>
186 <li>
565becb8 » Urban Hafner
2009-06-05 XHTML compliant HTML and a few spelling fixes
187 2009.05.31
188 <a href="http://s3.amazonaws.com/four.livejournal/20090531/node-0.0.2.tar.gz">node-0.0.2.tar.gz</a>
189 </li>
190 <li>
191 2009.05.27
192 <a href="http://s3.amazonaws.com/four.livejournal/20090527/node-0.0.1.tar.gz">node-0.0.1.tar.gz</a>
193 </li>
194 </ul>
195
196 <h2 id="build">Build</h2>
197
198 <p>
199 Node eventually wants to support all POSIX operating systems
200 (including Windows with MinGW) but at the moment it is only being
201 tested on <b>Linux</b>, <b>Macintosh</b>, and <b>FreeBSD</b>. The
728af1fa » ry
2009-06-11 add note about python versions
202 build system requires Python 2.4 or better. V8, on which Node is
203 built, supports only IA-32 and ARM processors. V8 is included in the
204 Node distribution. There are no dependencies.
565becb8 » Urban Hafner
2009-06-05 XHTML compliant HTML and a few spelling fixes
205 </p>
206
207 <pre class="sh_none">
1d8c4659 » ry
2009-05-27 Just twiddling with the webpage
208 ./configure
028c278a » ry
2009-05-14 Add HTTP Server documentation.
209 make
565becb8 » Urban Hafner
2009-06-05 XHTML compliant HTML and a few spelling fixes
210 make install</pre>
b34792a4 » ry
2009-05-13 Add webpage. Very incomplete.
211
565becb8 » Urban Hafner
2009-06-05 XHTML compliant HTML and a few spelling fixes
212 <p>
213 Then have a look at the <a href="api.html">API documentation</a>.
214 </p>
3c701cb5 » ry
2009-05-28 add long description to website
215
565becb8 » Urban Hafner
2009-06-05 XHTML compliant HTML and a few spelling fixes
216 <p>To run the tests</p>
b34792a4 » ry
2009-05-13 Add webpage. Very incomplete.
217
27b268b8 » ry
2009-06-17 Clean ups
218 <pre class="sh_none">make test</pre>
b77e603e » ry
2009-06-27 add irc channel to website
219
220 <h2 id="demo">Demo</h2>
221 <p>
222 A chat room demo is running at <a
223 href="http://chat.tinyclouds.org">chat.tinyclouds.org</a>. The
224 source code for the chat room is at <a
225 href="http://github.com/ry/node_chat/tree/master">http://github.com/ry/node_chat</a>.
226 The chat room is not stable and might occasionally be down.
227 </p>
28f86c7a » ry
2009-05-14 update node.html
228
565becb8 » Urban Hafner
2009-06-05 XHTML compliant HTML and a few spelling fixes
229 <h2 id="community">Community</h2>
230 <p>
231 For help and discussion subscribe to the mailing list at
232 <a href="http://groups.google.com/group/nodejs">http://groups.google.com/group/nodejs</a>
233 or send an email to <a href="mailto:nodejs+subscribe@googlegroups.com">nodejs+subscribe@googlegroups.com</a>.
234 </p>
b77e603e » ry
2009-06-27 add irc channel to website
235
d04ef897 » Urban Hafner
2009-06-05 Mention node_chat
236 <p>
b77e603e » ry
2009-06-27 add irc channel to website
237 For real-time discussion, check irc.freenode.net #node.js.
d04ef897 » Urban Hafner
2009-06-05 Mention node_chat
238 </p>
565becb8 » Urban Hafner
2009-06-05 XHTML compliant HTML and a few spelling fixes
239 </div>
240 </body>
b34792a4 » ry
2009-05-13 Add webpage. Very incomplete.
241 </html>
Something went wrong with that request. Please try again.