These are the slides that were used for my presentation on Node.js in OpenSlava 2013 (October 11th, 2013, Bratislava) and provide an introduction to Node.js as well as analyze the potential effects of introducing Node.js in an enterprise and from an architectural perspective.
6. V8: High Performance JavaScript Engine
•
JIT to native: x86, ARM and MIPS
•
On-the-fly recompilation of “hot” functions with an
optimizing compiler
•
ECMAScript compliant
19. Interesting Projects: Express
•
Minimal web application framework
•
Additional features are provided as modules or
middleware: template engines, models, authentication
and authorization, etc
20. Interesting Projects: Socket.io
•
Provides support for server-initiated push events using
WebSockets, Ajax polling, Iframe, JSONP or Flashbased channels
•
Transparent for both clients and servers
•
Can run standalone or integrated with Express
SERVER
CLIENT
21. Interesting Projects: Meteor
•
Next-gen framework for real-time collaborative web
applications
•
Live page updates
•
Support for offline databases with subsequent
synchronization
22. When to use Node.js
•
REST+JSON APIs
•
Backend for single-page web apps: same language in
client and server
•
Real-time web apps with Socket.io and Meteor
•
Quick prototyping
•
Rapidly evolving applications: media sites, marketing,
etc
23. When not to use Node.js
•
CPU-bound tasks
•
Multi-threaded applications
•
Applications that have to process large amounts of
data
•
Boring CRUD-type web apps
25. Maturity
•
Under development since 2008
•
Node.js 1.0 around the corner
•
Nearly 40000 modules available via npm
•
Awesome community
•
Commercial support
32. JavaScript is quirky different
•
Prototype-based inheritance
•
“==“ versus “===“
•
The meaning of “this”
•
Call, apply and bind in Function.prototype
And more.
34. Toolset
•
Large selection of testing libraries: unit testing,
functional testing, BDD
•
Static code analysis (JsHint)
•
IntelliJ IDEA, Eclipse (Nodeclipse) integration:
highlighting, refactoring, debugging
•
Integration with Jenkins/Hudson, Node.js specific CI
servers
•
NPM supports internal module repositories
35. Architects have a little bit of extra work
Node.js currently lacks standards; extra effort and
care must be paid to
•
application architecture,
•
development lifecycle,
•
code quality,
And many more.
38. Is it commercially supported?
Joyent is the corporate
steward of Node.js, the
world’s best runtime for
today's data-intensive,
real-time applications.
Joyent offers exclusive
debugging and
performance analysis
tools for Node.js
applications.
Other approaches to deal with application parallelism:Onethread per connection – thereisanupperlimittothenumber of concurrentthreads, and thereis a memoryoverhead per threadFork a new process per connection – same as above; limitedbytheoperatingsystemprocessscheduler, and processes are heavierthanthreadsSynchronous – don’tbotherwithparallelprocessingNode.js’ approachtoparallelismscalesbetter and uses lessmemorytoprocess a largeramount of connections – butitrequiresthatwebuildapplicationsthat are not CPU-bound
Node-restifyisusedhere, butit can all be accomplishedwithout a frameworktoo.
JSON is Javascript’s native serialization formatIntegrates very well with things like JSON-based APIs,MongoDB, etc – things that speak JSON natively
http://www.meteor.com
Note on “boring CRUD-type web apps”: Node.jsframeworksdon’tmakeitneithereasiernor more difficulttowritetraditional web apps; Node.js and itsframeworksjustsimplymake no differencehere
Note: Diagram inspired fromhttp://www.slideshare.net/BenLin2/webconf-nodejsproductionarchitectureNode.js processes are single threaded so scalability within the same server is dependent on the number of node processes that we run.In order to load balance the load within the same server, we can use a traditional load balancer running locally.The next step is to scale multiple servers, for which we need an additional load balanced layer on top of the local instances.Database/storage tier can be scaled according to the type of solution in use.