This document discusses how to scale and deploy NodeJS applications. It begins with an introduction of the author, Yacobus Reinhart, and then asks what the discussion will be about. It indicates that the talk will cover improving concurrency and deploying with JavaScript. It then asks how NodeJS works and provides a warning about blocking callbacks. It discusses the dangers of long-running callbacks and how NodeJS is single-threaded. It provides four solutions to these issues: making tasks asynchronous, using worker pools, using clusters, and taking a hybrid approach. It asks if there are any questions and shifts to discussing the deployment process, listing deployment alternatives like Capistrano, Mina, Minco, and Mina JS.
1. ““How to scale and deployHow to scale and deploy
NodeJS application”NodeJS application”
JakartaJS, May 2014JakartaJS, May 2014
2. aboutMe: {aboutMe: {
fullName : “ Yacobus Reinhart “,fullName : “ Yacobus Reinhart “,
nickName : “ Jack “,nickName : “ Jack “,
work : “ Domikado ”,work : “ Domikado ”,
living : “ South Jakarta ” ,living : “ South Jakarta ” ,
online : {online : {
github : “ github.com/jackbit “,github : “ github.com/jackbit “,
linkedin : “ id.linkedin.com/in/yreinhart “,linkedin : “ id.linkedin.com/in/yreinhart “,
email : “ yacobus.reinhart@gmail.com “email : “ yacobus.reinhart@gmail.com “
}}
}}
3. What this share about?What this share about?
-> Improving concurency-> Improving concurency
-> Deploy with javascript-> Deploy with javascript
4. How does NodeJS work?How does NodeJS work?
Becarefull here !!
5. Never run blocking or complexNever run blocking or complex
callback herecallback here
6. ““Because Node relies on an event loop to do its work,Because Node relies on an event loop to do its work,
there is the danger that the callback of an event in thethere is the danger that the callback of an event in the
loop could run for a long time.loop could run for a long time.
This means thatThis means that other users of the process are not goingother users of the process are not going
to get their requests met until that long-running event’sto get their requests met until that long-running event’s
callback has concluded.”callback has concluded.”
Is Single-Threaded evil?Is Single-Threaded evil?
14. When worker pool is used?When worker pool is used?
If you want task runs in even operation,
isolate it from parent thread and parallize request.
It is not real parallel process, but enqueued.
Disadvantages of worker pools:Disadvantages of worker pools:
An excessive number of threads will also waste
memory, and context-switching between the
runnable threads also damages performance
If the number of tasks is very large, then creating a
thread for each one may be impractical
20. When cluster is used?When cluster is used?
If you want use multiple processes to handle IO depending
on the availability of cores and share the same IO handle
(or queue)
Disadvantages of cluster:Disadvantages of cluster:
Clustered processes are limited to V8’s maximum memory
per process restrictions
Provides better uptime for the applications. When one of
the running Node.JS instances crash, host process creates
another one
Tools:Tools:
https://github.com/gosquared/clutch
https://github.com/jackbit/node-clustrap/tree/v1
23. When hybrid is used?When hybrid is used?
If you want share the same logic from server to run in client
or browser. It will reduce time computation in server.
Disadvantages of hybrid:Disadvantages of hybrid:
Huge computation will blow up your browser
Not all cpu task in server can be done from browser
Tools:Tools:
https://github.com/substack/node-browserify
https://github.com/azer/onejs
25. Process to release your application into server and start itProcess to release your application into server and start it
D E P L O Y M E N TD E P L O Y M E N T
Part #2Part #2