Writing code that runs continuously on one thread, but which supports potentially many hundreds or thousands of concurrent requests means you have to structure your application very carefully. State is the enemy here, especially in the context of wanting to write performant, non-blocking asynchronous code.
In my talk, I'd like to present where state comes from in HTTP-centric applications, some common gotchas around where state is mutated and retained in node, how this can provide a source of fun and fascinating race conditions for all the family, and discuss techniques which can be used to mitigate the horror of all this, in an idiomatic, scalable and easily abstracted way.
I'm going to touch on:
- how call stacks are unwound
- differences between sync and async code (deferred calls)
- how to leverage domains to capture errors gracefully across async boundaries
- implications for performance
- do a whirlwind cruise through browserify & npm for frontend
..and.. discuss our use of a new, under-development node package, continuation local storage, which will be the focus of the talk after establishing the context.
Any questions, please feel free to ask below!