Thread per connection VS Event loop
Advantage:
more memory consumption thread blocked waiting for I/O operation
- Q: So why not Event loop, callbacks, non-blocking I/O
- A: cultural and infrastructural.
- cultural, we thought that the I/O should be blocking.
- infrastructural
- single threaded event loops require I/O to be non-blocking, but most libraries are not.
- too much options: EventMachine, Twisted
- Q: Why javascript?
- A: javascript has the following features:
- Anonymous functions, closures. – easy to create callback
- Only one callback at a time. – only one callback at a time
- I/O through DOM event callbacks –non-blocking
- promise: a promise is a kind of EventEmitter which emits either “success” or “error”. (But not both.)