A broad sweep of Node.js with keynote, presenter notes (this file) and demos.
Based heavily on Ryan Dahl's excellent presentations:
- Handle loads of concurrent connections (eg a map tile server)
- Need to do chat
- 'Realtime' interaction (or realtime enough)
- Apache: 1 thread per http request
- Nginx, lighttp: Event Loop
High performance customisable server (not just HTTP)
multiplex IO into single thread
Write high performance servers easily (hard has already been done!)
- use events
- have non-blocking IO
- no shared memory
- If need to handle more traffic, open more event loop processes
- Can handle 20-30k TCP connections per thread. Quite scalable.
* Have abstractions
* 'Green threads' Actually running ontop of a single OS thread and an event loop.
* 'Erlang processes' 'green processes/threads' running in a separate address space + scheduler - multicore happy and allows you to kill an individual process. Still green threads though. Still running on an EL.
* Event loops (eventmachine (Ruby), twisted(Python)).
Abstractions are still EL and non-blocking IO.
- If C, have to write in C
- Everything has to be non-blocking.
- All or nothing. Can't mix libraries (eg. MySQL doesn't have a non-blocking client)
- Performance arms race (Google Apple, Moz, Opera, MS...)
- No preconceived ideas about I/O
- Browsers are single threaded, and non-blocking.
- People already get it (mouseover).
- Fastest scripting language now
- V8 is an optimising compiler to machine code
- graphs
- Set of bindings on top of V8 for non-browser work: sockets, files
- purely non-blocking interfaces, so beginners can achieve decent concurrency
- Only 1 thread, only 1 stack
- lots of low-level features
- Emphasis on networking
- Excellent socket/http support
- Single threaded
- No automatic scaling
- What about multicore?
- Open new processes.
- communicate over sendmessage, or IPC webworkers.
- Node: low level. You have to make your own.
look up on github: https://github.com/joyent/node/wiki/Installation
- REPL
- process object == windows object
- tab completion
- .exit
Work through demo folder
- npm
- http servers
- database drivers etc
- Exceptions - backtraces is only made of the current callback scope