Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Scalability using Node.js
1. Enhancing scalability
using Node.js
Team 15 - Enlighten
Ratan Kadam - ratan.kadam@gmail.com
Monil Shah - monil.shaah@gmail.com
Akshay Jarandikar - akshayjaradikar@gmail.com
Swapnil Joshi - swapnil.joshi1590@gmail.com
2. Scalability
WhyWhat is scalability?
do we need scalability?
Current industry solutions -
• Horizontal Scaling
• Vertical Scaling
• Multi-threading
• Cloud Computing
3. Horizontal vs Vertical Scaling
Horizontal Scaling
Adds extra identical boxes to
server.
Issues:
• Requires Load balancer for
managing connection.
• Distribution of work within the
units becomes overhead.
• Additional investment.
Vertical Scaling
Increases the power of existing
system by adding more powerful
hardware.
Issues:
• Additional Investment
• Single point of failure
(SPOF)
4. Multi-threading & Cloud Computing
Multi-threading
Issues:
-High chances of deadlock if
application is not designed
properly.
-Web-servers need to handle
thousands of HTTP requests. This
may cause many threads to wait
for network operations.
-For thousands of simultaneous
requests, spawning threads for all
processes would not achieve the
desired scalability.
Cloud Computing
Issues:
-Application architecture may or
may not be suited for Cloud
Computing
-Application and Data Security in
the Cloud
-Lack of skilled resources;
external training is required
-If application is not designed
properly for cloud platform;
difficult to yield benefits
-Again, substantial additional
investment
5. So the challenge…
The challenge is to scale the web
application without major re-engineering
and buying new hardware while keeping
its architecture simple and easy to
manage.
7. Proposed Architecture
Proxy Middleware, Entry point for real
world access, Security, Caching
Nginx Server Serves static content, Caching
Load Balancer connects multithreaded
node.js instances and handles load distribution
V8 JavaScript engine handles compilation and
execution of JavaScript
Event loop Handles events in program
during execution of asynchronous operations.
10. Nginx server
Nginx server stores static data in hierarchical cache. Thus reduces the latency.
Also supports compression format to reduce response size.
12. When request is made to server, instead of waiting for the request to complete,
server continues to process other requests.
When request processing completes, the response is sent to caller using
callback mechanism.
Event listener listens to the events and determines the flow of program.
There is an event loop that listens to events and then triggers callback functions.
13. Non-blocking I/O
Non-blocking I/O supports the execution of system to be continued
without waiting for I/O operations to complete.
This enables the architecture to have asynchronous request
processing.
14. Event loop
Event loop is a programming construct that waits for and dispatches events in a
program once their asynchronous operation completes.
15. Node Load Balancer Working
Load balancer
distributes the
workload among
available servers.
Load Balancer sends
periodic heartbeat to
check server status.
If one of the servers is
down then the load
balancer distributes
the request queue
among the available
servers.
16. V8 JavaScript Engine
When V8 receives script source code, it parses it to create abstract
syntax tree.
Then this AST is fed into the byte code generator to produce byte
code of the source.
V8 execution environment then interprets this byte code and with the
help of JIT compiler it produces the native machine code that gets
executed.
It uses techniques such as in-lining, elision of expensive runtime
properties, and inline caching are used for optimization
17. CASE STUDY
PayPal & eBay with Node.Js
Changes from development
perspective -
The development time was almost
half that with fewer people.
Number of files that were
constructed reduced to 40%.
The number of lines of code was
reduced by 33%.
Changes from performance
perspective
The number of requests per
second is doubled compared to Java
application.
The response time is decreased
by 35% compared to Java
application.
19. Advantages
1. Asynchronous
2. Event driven programming
3. Multithreading
4. Scalability
5. High throughput
6. High Performance
7. Cost effective
8.Minimum Latency
9. Efficient Resource Consumption
10. Set of Standard Libraries
20. Conclusion
Scalability is next decade challenge for enterprise community
as more than 7.1 billion people are using internet.
Most of the vendors use solutions like Horizontal, vertical &
single threaded node.js. However, these single threaded
architectures may not be able to fix the next generation scalable
issues.
Solution to the problem is defined in our proposed architecture –
multithreaded node.js where multiple node.js instances are bind
to the fixed number of threads to boost the power of existing
Node JS.
So multithreaded node.js can be a cost effective, software based
scalable solution for next decade challenges for Enterprise
industries.
21. References
Web application performance and scalability
http://www.webforefront.com/performance/scaling101.html
Node.js at PayPal
https://www.paypal-engineering.com/2013/11/22/node-js-at-paypal/
Nginx
http://www.aosabook.org/en/nginx.html
Ebay’s first node.js application
http://www.ebaytechblog.com/2013/05/17/how-we-built-ebays-first-node-
js-application/#.VHLrNIvF9hw
Node.js architecture diagram
http://blog.cloudfoundry.org/2012/06/27/future-proofing-your-apps-cloud-
foundry-and-node-js/