Lessons learned from node.js. Node.js methodology, working with callbacks, using promises. If you ever decide to one day sit down and write in node.js just remember to use promises.
Instead of calling a passed callback, return a promise.
16. A theoretical request.
Request Process Results
Query DB or Web Service Write to log file
Format Response
= blocking / waiting
Tuesday, October 8, 13
17. Scale with Threads
Scale with Processes
Thread 1
Thread 2
Thread 3
Thread 4
Process 1
Process 2
Process 3
Process 4
Tuesday, October 8, 13
18. Scale with Event Loop
Handles many concurrent requests in a single
process / thread
Process 1
Thread Pool
Tuesday, October 8, 13
28. What are promises?
A promise is an object that represents a one-time
event, typically the outcome of an async task like an
AJAX call. When a promise is returned, at first it is in a
pending state.
Eventually it’s either:
1. resolved - The promise is fulfilled with a value
2. rejected - The promise is broken
Tuesday, October 8, 13
29. Instead of calling a
passed callback,
return a promise.
Tuesday, October 8, 13