SlideShare a Scribd company logo
In Real Time - The Beginning
Kristian Ačkar
A little about me...
Kristian Ačkar - employed in Core Incubator
● “System Analysis & Traffic. With a sparkle in his eye and
passion for football”
“Core Incubator is an angel investor, providing pre-seed
and seed investment of a small scale. We are also a
startup hub offering coworking space and mentorship,
for startups eager to grow and develop.” - www.coreincubator.com
Contact me:
2
What to expect ahead...
● Introduction
● What can you do with Node.js
● When to use Node.js and when not
● Scalability
● Node.js ecosystem
● Socket.io
● Who uses Node.js
● Zdravko Mamić
3
Background
● Node.js is an open-source cross-platform JavaScript runtime built on
Chrome’s V8 JavaScript engine
● Originally written in 2009 by Ryan Dahl
● Latest stable release v5.5.0
4
Introduction: Basic
● Node.js is “server side JavaScript”
● High-performance network applications framework
● Optimized for high concurrent environments
● ~40% written in JavaScript and ~60% in C++
“As an asynchronous event driven framework, Node.js is designed to build
scalable network applications” - from nodejs.org
5
Introduction: Advanced
● Node.js uses an event-driven, non-blocking I/O model
● It makes use of event-loops via JavaScript’s callback functionality to
implement the non-blocking I/O
● Most of familiar JavaScript from browser is ported to Node.js, except the
DOM/BOM implementation
var x = document.getElementsByTagName(“p”)
var y = window.innerWidth
● Everything inside Node.js runs in a single-thread
6
Introduction: Some (confusing) theory (1)
Event-loops
● Core of event-driven programming (almost all the UI programs use event-
loops to track the user event)
● A major usage of JavaScript is to interact with the DOM (browser) - use of
event-based API was natural
7
File System
Database
Network
...
INTENSIVE
OPERATION
EVENT
QUEUE
Register Callback
Operation Complete
Trigger Callback
EVENT LOOP
(single thread)
Introduction: Some (confusing) theory (2)
Non-blocking I/O
fs.unlinkSync(“/tmp/hello”);
console.log(“I was blocked”); // execution is blocked
fs.unlink(“/tmp/hello”, (err) => {
if (err) throw err;
console.log(“/tmp/hello deleted”);
});
console.log(“I wasn’t blocked”); // execution is not blocked
8
What can you do with Node.js
● All kind of servers
○ HTTP server
○ TCP server Example: TCP client - server
○ DNS server
○ Static file server
● Real-time applications
○ Chat
○ Online games
○ Collaboration tools Example: Drawing collaborating tool
○ Anything which sends updates to the user in real-time
● Desktop GUI applications
● Any kind of applications
9
When to use Node.js and when not
Use Node.js
● For applications where you’d like to maintain persistent connection from the
browser back to the server (“long-polling”)
● When you can reuse a lot of code across the client/server gap (Meteor.js)
● For applications that have a lot of concurrent connections and each request
only needs very few CPU cycles (because the event loop is blocked during
execution of a function)
Don’t use Node.js
● When server request is dependant on heavy CPU consuming algorithm/job
10
Scalability
● Horizontal scalability is problem
● Adding more CPU cores won’t increase performance
● SOLUTION
○ Utilize multi-core CPUs e.g. by setting up cluster (nodejs.org/api/cluster.html)
○ Setup a load balancer and spin up more servers
Example: Node.js clustering
11
Scalability: clusters increase performance
● Apache Benchmark
● 8 core CPU
12
Concurrent Connections 1 2 4 8 16
Single Process 654 711 783 776 754
8 Workers 594 1198 2110 3010 3024
Node.js ecosystem (1)
● Node.js framework is structured in modules
○ Core modules (fs, cluster, http, net, dgram, crypto, ...)
○ Custom modules
const PI = Math.PI;
exports.area = function(r) {
return PI * r * r;
}
exports.circumference = function(r) {
return 2 * r * PI;
}
const circle = require(“./circle.js”);
console.log(“The area of a circle of radius 10 is ${circle.area(10)}”);
13
circle.js
demo.js
Node.js ecosystem (2)
Node Package Manager - NPM (www.npmjs.com)
● Node.js packages repository
● Package is custom made module published in the repository (available to community)
● Real power of Node.js (238 635 packages in repository)
○ Production development heavily depends on Node.js packages
● Countless number of downloads
○ 147 308 788 in the last day
○ 816 096 961 in the last week
○ 3 447 929 034 in the last month
● Install local or global
○ npm install -g sails@0.12.0 vs npm install sails@0.12.0
● Node.js project can define list of dependencies in a package.json file (example)
14
Socket.io
● Node.js (JavaScript) is event driven system
○ Usually we handle events immediately - real-time
■ e.g. file watching example - isn’t that example of “real time“ app?
● Most of the time when we talk about “real-time” and Node.js we mean on one
of the most popular Node.js module - socket.io (http://socket.io)
○ Uses websocket protocol to communicate with a server
○ Simple and lightweight
○ Uses “heartbeats” to control connection health
○ Server can separate socket connections into “rooms”
■ Example apps: chat systems with rooms, brazuca
Example: Drawing collaborating tool
15
Who uses Node.js (in production)
16
● Big shots
○ github.com/nodejs/node-v0.x-archive/wiki/Projects,-Applications,-and-Companies-Using-Node
End of presentation…
...start of discussion 17

More Related Content

What's hot

Gluster as Block Store in Containers
Gluster as Block Store in ContainersGluster as Block Store in Containers
Gluster as Block Store in Containers
Gluster.org
 
Minio ♥ Go
Minio ♥ GoMinio ♥ Go
Minio ♥ Go
Minio
 
Arbiter volumes in gluster
Arbiter volumes in glusterArbiter volumes in gluster
Arbiter volumes in gluster
itisravi
 
Object Storage in a Cloud-Native Container Envirnoment
Object Storage in a Cloud-Native Container EnvirnomentObject Storage in a Cloud-Native Container Envirnoment
Object Storage in a Cloud-Native Container Envirnoment
Minio
 
Integrating GlusterFS with iSCSI Target
Integrating GlusterFS with iSCSI TargetIntegrating GlusterFS with iSCSI Target
Integrating GlusterFS with iSCSI Target
ijsrd.com
 
High Performance Scaling Techniques in Golang Using Go Assembly
High Performance Scaling Techniques in Golang Using Go AssemblyHigh Performance Scaling Techniques in Golang Using Go Assembly
High Performance Scaling Techniques in Golang Using Go Assembly
Minio
 
Ansible
AnsibleAnsible
Ansiblegnosek
 
Monitoring your shiny new docker environment
Monitoring your shiny new docker environmentMonitoring your shiny new docker environment
Monitoring your shiny new docker environment
Samuel Vandamme
 
Everyone Loves a Sausage
Everyone Loves a SausageEveryone Loves a Sausage
Everyone Loves a Sausage
Nick Jones
 
Cloud foundry on kubernetes
Cloud foundry on kubernetesCloud foundry on kubernetes
Cloud foundry on kubernetes
상준 윤
 
Game DDOS Prevention
Game DDOS PreventionGame DDOS Prevention
Game DDOS Prevention
Walter Liu
 
Cassandra 2.1 boot camp, exercise
Cassandra 2.1 boot camp, exerciseCassandra 2.1 boot camp, exercise
Cassandra 2.1 boot camp, exercise
Joshua McKenzie
 
CloudModule for Zabbix
CloudModule for ZabbixCloudModule for Zabbix
CloudModule for ZabbixDaisuke Ikeda
 
OSBConf 2015 | Scale out backups with bareos and gluster by niels de vos
OSBConf 2015 | Scale out backups with bareos and gluster by niels de vosOSBConf 2015 | Scale out backups with bareos and gluster by niels de vos
OSBConf 2015 | Scale out backups with bareos and gluster by niels de vos
NETWAYS
 
How to access your FIWARE Lab Instance.
How to access your FIWARE Lab Instance.How to access your FIWARE Lab Instance.
How to access your FIWARE Lab Instance.
José Ignacio Carretero Guarde
 
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur Bittorrent
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur BittorrentOsis18_Cloud : DeepTorrent Stockage distribué perenne basé sur Bittorrent
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur Bittorrent
Pôle Systematic Paris-Region
 
Libcontainer: joining forces under one roof
Libcontainer: joining forces under one roofLibcontainer: joining forces under one roof
Libcontainer: joining forces under one roofAndrey Vagin
 
(WS14) Sasa Matijasic - Node.js i "novi" web
(WS14) Sasa Matijasic - Node.js i "novi" web(WS14) Sasa Matijasic - Node.js i "novi" web
(WS14) Sasa Matijasic - Node.js i "novi" webWeb::Strategija
 
2013 PyCon SG - Building your cloud infrastructure with Python
2013 PyCon SG - Building your cloud infrastructure with Python2013 PyCon SG - Building your cloud infrastructure with Python
2013 PyCon SG - Building your cloud infrastructure with PythonGeorge Goh
 

What's hot (20)

Gluster as Block Store in Containers
Gluster as Block Store in ContainersGluster as Block Store in Containers
Gluster as Block Store in Containers
 
Minio ♥ Go
Minio ♥ GoMinio ♥ Go
Minio ♥ Go
 
Arbiter volumes in gluster
Arbiter volumes in glusterArbiter volumes in gluster
Arbiter volumes in gluster
 
Object Storage in a Cloud-Native Container Envirnoment
Object Storage in a Cloud-Native Container EnvirnomentObject Storage in a Cloud-Native Container Envirnoment
Object Storage in a Cloud-Native Container Envirnoment
 
Integrating GlusterFS with iSCSI Target
Integrating GlusterFS with iSCSI TargetIntegrating GlusterFS with iSCSI Target
Integrating GlusterFS with iSCSI Target
 
High Performance Scaling Techniques in Golang Using Go Assembly
High Performance Scaling Techniques in Golang Using Go AssemblyHigh Performance Scaling Techniques in Golang Using Go Assembly
High Performance Scaling Techniques in Golang Using Go Assembly
 
Ansible
AnsibleAnsible
Ansible
 
Monitoring your shiny new docker environment
Monitoring your shiny new docker environmentMonitoring your shiny new docker environment
Monitoring your shiny new docker environment
 
Everyone Loves a Sausage
Everyone Loves a SausageEveryone Loves a Sausage
Everyone Loves a Sausage
 
Cloud foundry on kubernetes
Cloud foundry on kubernetesCloud foundry on kubernetes
Cloud foundry on kubernetes
 
Game DDOS Prevention
Game DDOS PreventionGame DDOS Prevention
Game DDOS Prevention
 
Cassandra 2.1 boot camp, exercise
Cassandra 2.1 boot camp, exerciseCassandra 2.1 boot camp, exercise
Cassandra 2.1 boot camp, exercise
 
CloudModule for Zabbix
CloudModule for ZabbixCloudModule for Zabbix
CloudModule for Zabbix
 
OSBConf 2015 | Scale out backups with bareos and gluster by niels de vos
OSBConf 2015 | Scale out backups with bareos and gluster by niels de vosOSBConf 2015 | Scale out backups with bareos and gluster by niels de vos
OSBConf 2015 | Scale out backups with bareos and gluster by niels de vos
 
How to access your FIWARE Lab Instance.
How to access your FIWARE Lab Instance.How to access your FIWARE Lab Instance.
How to access your FIWARE Lab Instance.
 
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur Bittorrent
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur BittorrentOsis18_Cloud : DeepTorrent Stockage distribué perenne basé sur Bittorrent
Osis18_Cloud : DeepTorrent Stockage distribué perenne basé sur Bittorrent
 
Libcontainer: joining forces under one roof
Libcontainer: joining forces under one roofLibcontainer: joining forces under one roof
Libcontainer: joining forces under one roof
 
(WS14) Sasa Matijasic - Node.js i "novi" web
(WS14) Sasa Matijasic - Node.js i "novi" web(WS14) Sasa Matijasic - Node.js i "novi" web
(WS14) Sasa Matijasic - Node.js i "novi" web
 
Node js beginner
Node js beginnerNode js beginner
Node js beginner
 
2013 PyCon SG - Building your cloud infrastructure with Python
2013 PyCon SG - Building your cloud infrastructure with Python2013 PyCon SG - Building your cloud infrastructure with Python
2013 PyCon SG - Building your cloud infrastructure with Python
 

Similar to Node in Real Time - The Beginning

Nodejs
NodejsNodejs
New Jersey Red Hat Users Group Presentation: Provisioning anywhere
New Jersey Red Hat Users Group Presentation: Provisioning anywhereNew Jersey Red Hat Users Group Presentation: Provisioning anywhere
New Jersey Red Hat Users Group Presentation: Provisioning anywhere
Rodrique Heron
 
18_Node.js.ppt
18_Node.js.ppt18_Node.js.ppt
18_Node.js.ppt
MaulikShah516542
 
18_Node.js.ppt
18_Node.js.ppt18_Node.js.ppt
18_Node.js.ppt
KhalilSalhi7
 
Netty training
Netty trainingNetty training
Nodejs
NodejsNodejs
Netty training
Netty trainingNetty training
Netty training
Marcelo Serpa
 
Treinamento frontend
Treinamento frontendTreinamento frontend
Treinamento frontend
Adrian Caetano
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
JITENDRA KUMAR PATEL
 
Swarm: Native Docker Clustering
Swarm: Native Docker ClusteringSwarm: Native Docker Clustering
Swarm: Native Docker Clustering
Royee Tager
 
Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6
Ganesh Kondal
 
Node.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleNode.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scale
Dmytro Semenov
 
Introduction to node.js By Ahmed Assaf
Introduction to node.js  By Ahmed AssafIntroduction to node.js  By Ahmed Assaf
Introduction to node.js By Ahmed Assaf
Ahmed Assaf
 
2012-03-15 What's New at Red Hat
2012-03-15 What's New at Red Hat2012-03-15 What's New at Red Hat
2012-03-15 What's New at Red Hat
Shawn Wells
 
Heterogeneous multiprocessing on androd and i.mx7
Heterogeneous multiprocessing on androd and i.mx7Heterogeneous multiprocessing on androd and i.mx7
Heterogeneous multiprocessing on androd and i.mx7
Kynetics
 
Guest Agents: Support & Implementation
Guest Agents: Support & ImplementationGuest Agents: Support & Implementation
Guest Agents: Support & Implementation
Mirantis
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
Apaichon Punopas
 
Kubernetes: My BFF
Kubernetes: My BFFKubernetes: My BFF
Kubernetes: My BFF
Jonathan Yu, P.Eng.
 
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsI Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
Michael Lange
 
NetflixOSS Meetup season 3 episode 1
NetflixOSS Meetup season 3 episode 1NetflixOSS Meetup season 3 episode 1
NetflixOSS Meetup season 3 episode 1
Ruslan Meshenberg
 

Similar to Node in Real Time - The Beginning (20)

Nodejs
NodejsNodejs
Nodejs
 
New Jersey Red Hat Users Group Presentation: Provisioning anywhere
New Jersey Red Hat Users Group Presentation: Provisioning anywhereNew Jersey Red Hat Users Group Presentation: Provisioning anywhere
New Jersey Red Hat Users Group Presentation: Provisioning anywhere
 
18_Node.js.ppt
18_Node.js.ppt18_Node.js.ppt
18_Node.js.ppt
 
18_Node.js.ppt
18_Node.js.ppt18_Node.js.ppt
18_Node.js.ppt
 
Netty training
Netty trainingNetty training
Netty training
 
Nodejs
NodejsNodejs
Nodejs
 
Netty training
Netty trainingNetty training
Netty training
 
Treinamento frontend
Treinamento frontendTreinamento frontend
Treinamento frontend
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
 
Swarm: Native Docker Clustering
Swarm: Native Docker ClusteringSwarm: Native Docker Clustering
Swarm: Native Docker Clustering
 
Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6
 
Node.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleNode.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scale
 
Introduction to node.js By Ahmed Assaf
Introduction to node.js  By Ahmed AssafIntroduction to node.js  By Ahmed Assaf
Introduction to node.js By Ahmed Assaf
 
2012-03-15 What's New at Red Hat
2012-03-15 What's New at Red Hat2012-03-15 What's New at Red Hat
2012-03-15 What's New at Red Hat
 
Heterogeneous multiprocessing on androd and i.mx7
Heterogeneous multiprocessing on androd and i.mx7Heterogeneous multiprocessing on androd and i.mx7
Heterogeneous multiprocessing on androd and i.mx7
 
Guest Agents: Support & Implementation
Guest Agents: Support & ImplementationGuest Agents: Support & Implementation
Guest Agents: Support & Implementation
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
Kubernetes: My BFF
Kubernetes: My BFFKubernetes: My BFF
Kubernetes: My BFF
 
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsI Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
 
NetflixOSS Meetup season 3 episode 1
NetflixOSS Meetup season 3 episode 1NetflixOSS Meetup season 3 episode 1
NetflixOSS Meetup season 3 episode 1
 

More from Axilis

Web App Security for Devs
Web App Security for DevsWeb App Security for Devs
Web App Security for Devs
Axilis
 
React tips
React tipsReact tips
React tips
Axilis
 
Configuring SSL on NGNINX and less tricky servers
Configuring SSL on NGNINX and less tricky serversConfiguring SSL on NGNINX and less tricky servers
Configuring SSL on NGNINX and less tricky servers
Axilis
 
Journey to Microservice architecture via Amazon Lambda
Journey to Microservice architecture via Amazon LambdaJourney to Microservice architecture via Amazon Lambda
Journey to Microservice architecture via Amazon Lambda
Axilis
 
Should you react?
Should you react?Should you react?
Should you react?
Axilis
 
Sweet ES2015 (ES6) Taste
Sweet ES2015 (ES6) TasteSweet ES2015 (ES6) Taste
Sweet ES2015 (ES6) Taste
Axilis
 
NuGet Must Haves for LINQ
NuGet Must Haves for LINQNuGet Must Haves for LINQ
NuGet Must Haves for LINQ
Axilis
 
Quick introduction to zeplin
Quick introduction to zeplinQuick introduction to zeplin
Quick introduction to zeplin
Axilis
 
Diving into Node with Express and Mongo
Diving into Node with Express and MongoDiving into Node with Express and Mongo
Diving into Node with Express and Mongo
Axilis
 
Road to Dynamic LINQ - Part 2
 Road to Dynamic LINQ - Part 2 Road to Dynamic LINQ - Part 2
Road to Dynamic LINQ - Part 2
Axilis
 
Road to Dynamic LINQ Part 1
Road to Dynamic LINQ Part 1Road to Dynamic LINQ Part 1
Road to Dynamic LINQ Part 1
Axilis
 
.NET Core - Sve što trebate znati
.NET Core - Sve što trebate znati.NET Core - Sve što trebate znati
.NET Core - Sve što trebate znati
Axilis
 
Angular Translate
Angular TranslateAngular Translate
Angular Translate
Axilis
 
NPM, Bower and Gulp Kickstart in Visual Studio
 NPM, Bower and Gulp Kickstart in Visual Studio NPM, Bower and Gulp Kickstart in Visual Studio
NPM, Bower and Gulp Kickstart in Visual Studio
Axilis
 
Dive Into Swift
Dive Into SwiftDive Into Swift
Dive Into Swift
Axilis
 
Python Tools for Visual Studio
Python Tools for Visual StudioPython Tools for Visual Studio
Python Tools for Visual Studio
Axilis
 
Python Tools for Visual Studio
Python Tools for Visual StudioPython Tools for Visual Studio
Python Tools for Visual Studio
Axilis
 
Wireframing
WireframingWireframing
Wireframing
Axilis
 
Angular 2.0: Getting ready
Angular 2.0: Getting readyAngular 2.0: Getting ready
Angular 2.0: Getting ready
Axilis
 
Angular JS deep dive
Angular JS deep diveAngular JS deep dive
Angular JS deep dive
Axilis
 

More from Axilis (20)

Web App Security for Devs
Web App Security for DevsWeb App Security for Devs
Web App Security for Devs
 
React tips
React tipsReact tips
React tips
 
Configuring SSL on NGNINX and less tricky servers
Configuring SSL on NGNINX and less tricky serversConfiguring SSL on NGNINX and less tricky servers
Configuring SSL on NGNINX and less tricky servers
 
Journey to Microservice architecture via Amazon Lambda
Journey to Microservice architecture via Amazon LambdaJourney to Microservice architecture via Amazon Lambda
Journey to Microservice architecture via Amazon Lambda
 
Should you react?
Should you react?Should you react?
Should you react?
 
Sweet ES2015 (ES6) Taste
Sweet ES2015 (ES6) TasteSweet ES2015 (ES6) Taste
Sweet ES2015 (ES6) Taste
 
NuGet Must Haves for LINQ
NuGet Must Haves for LINQNuGet Must Haves for LINQ
NuGet Must Haves for LINQ
 
Quick introduction to zeplin
Quick introduction to zeplinQuick introduction to zeplin
Quick introduction to zeplin
 
Diving into Node with Express and Mongo
Diving into Node with Express and MongoDiving into Node with Express and Mongo
Diving into Node with Express and Mongo
 
Road to Dynamic LINQ - Part 2
 Road to Dynamic LINQ - Part 2 Road to Dynamic LINQ - Part 2
Road to Dynamic LINQ - Part 2
 
Road to Dynamic LINQ Part 1
Road to Dynamic LINQ Part 1Road to Dynamic LINQ Part 1
Road to Dynamic LINQ Part 1
 
.NET Core - Sve što trebate znati
.NET Core - Sve što trebate znati.NET Core - Sve što trebate znati
.NET Core - Sve što trebate znati
 
Angular Translate
Angular TranslateAngular Translate
Angular Translate
 
NPM, Bower and Gulp Kickstart in Visual Studio
 NPM, Bower and Gulp Kickstart in Visual Studio NPM, Bower and Gulp Kickstart in Visual Studio
NPM, Bower and Gulp Kickstart in Visual Studio
 
Dive Into Swift
Dive Into SwiftDive Into Swift
Dive Into Swift
 
Python Tools for Visual Studio
Python Tools for Visual StudioPython Tools for Visual Studio
Python Tools for Visual Studio
 
Python Tools for Visual Studio
Python Tools for Visual StudioPython Tools for Visual Studio
Python Tools for Visual Studio
 
Wireframing
WireframingWireframing
Wireframing
 
Angular 2.0: Getting ready
Angular 2.0: Getting readyAngular 2.0: Getting ready
Angular 2.0: Getting ready
 
Angular JS deep dive
Angular JS deep diveAngular JS deep dive
Angular JS deep dive
 

Recently uploaded

Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
Srikant77
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 

Recently uploaded (20)

Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 

Node in Real Time - The Beginning

  • 1. In Real Time - The Beginning Kristian Ačkar
  • 2. A little about me... Kristian Ačkar - employed in Core Incubator ● “System Analysis & Traffic. With a sparkle in his eye and passion for football” “Core Incubator is an angel investor, providing pre-seed and seed investment of a small scale. We are also a startup hub offering coworking space and mentorship, for startups eager to grow and develop.” - www.coreincubator.com Contact me: 2
  • 3. What to expect ahead... ● Introduction ● What can you do with Node.js ● When to use Node.js and when not ● Scalability ● Node.js ecosystem ● Socket.io ● Who uses Node.js ● Zdravko Mamić 3
  • 4. Background ● Node.js is an open-source cross-platform JavaScript runtime built on Chrome’s V8 JavaScript engine ● Originally written in 2009 by Ryan Dahl ● Latest stable release v5.5.0 4
  • 5. Introduction: Basic ● Node.js is “server side JavaScript” ● High-performance network applications framework ● Optimized for high concurrent environments ● ~40% written in JavaScript and ~60% in C++ “As an asynchronous event driven framework, Node.js is designed to build scalable network applications” - from nodejs.org 5
  • 6. Introduction: Advanced ● Node.js uses an event-driven, non-blocking I/O model ● It makes use of event-loops via JavaScript’s callback functionality to implement the non-blocking I/O ● Most of familiar JavaScript from browser is ported to Node.js, except the DOM/BOM implementation var x = document.getElementsByTagName(“p”) var y = window.innerWidth ● Everything inside Node.js runs in a single-thread 6
  • 7. Introduction: Some (confusing) theory (1) Event-loops ● Core of event-driven programming (almost all the UI programs use event- loops to track the user event) ● A major usage of JavaScript is to interact with the DOM (browser) - use of event-based API was natural 7 File System Database Network ... INTENSIVE OPERATION EVENT QUEUE Register Callback Operation Complete Trigger Callback EVENT LOOP (single thread)
  • 8. Introduction: Some (confusing) theory (2) Non-blocking I/O fs.unlinkSync(“/tmp/hello”); console.log(“I was blocked”); // execution is blocked fs.unlink(“/tmp/hello”, (err) => { if (err) throw err; console.log(“/tmp/hello deleted”); }); console.log(“I wasn’t blocked”); // execution is not blocked 8
  • 9. What can you do with Node.js ● All kind of servers ○ HTTP server ○ TCP server Example: TCP client - server ○ DNS server ○ Static file server ● Real-time applications ○ Chat ○ Online games ○ Collaboration tools Example: Drawing collaborating tool ○ Anything which sends updates to the user in real-time ● Desktop GUI applications ● Any kind of applications 9
  • 10. When to use Node.js and when not Use Node.js ● For applications where you’d like to maintain persistent connection from the browser back to the server (“long-polling”) ● When you can reuse a lot of code across the client/server gap (Meteor.js) ● For applications that have a lot of concurrent connections and each request only needs very few CPU cycles (because the event loop is blocked during execution of a function) Don’t use Node.js ● When server request is dependant on heavy CPU consuming algorithm/job 10
  • 11. Scalability ● Horizontal scalability is problem ● Adding more CPU cores won’t increase performance ● SOLUTION ○ Utilize multi-core CPUs e.g. by setting up cluster (nodejs.org/api/cluster.html) ○ Setup a load balancer and spin up more servers Example: Node.js clustering 11
  • 12. Scalability: clusters increase performance ● Apache Benchmark ● 8 core CPU 12 Concurrent Connections 1 2 4 8 16 Single Process 654 711 783 776 754 8 Workers 594 1198 2110 3010 3024
  • 13. Node.js ecosystem (1) ● Node.js framework is structured in modules ○ Core modules (fs, cluster, http, net, dgram, crypto, ...) ○ Custom modules const PI = Math.PI; exports.area = function(r) { return PI * r * r; } exports.circumference = function(r) { return 2 * r * PI; } const circle = require(“./circle.js”); console.log(“The area of a circle of radius 10 is ${circle.area(10)}”); 13 circle.js demo.js
  • 14. Node.js ecosystem (2) Node Package Manager - NPM (www.npmjs.com) ● Node.js packages repository ● Package is custom made module published in the repository (available to community) ● Real power of Node.js (238 635 packages in repository) ○ Production development heavily depends on Node.js packages ● Countless number of downloads ○ 147 308 788 in the last day ○ 816 096 961 in the last week ○ 3 447 929 034 in the last month ● Install local or global ○ npm install -g sails@0.12.0 vs npm install sails@0.12.0 ● Node.js project can define list of dependencies in a package.json file (example) 14
  • 15. Socket.io ● Node.js (JavaScript) is event driven system ○ Usually we handle events immediately - real-time ■ e.g. file watching example - isn’t that example of “real time“ app? ● Most of the time when we talk about “real-time” and Node.js we mean on one of the most popular Node.js module - socket.io (http://socket.io) ○ Uses websocket protocol to communicate with a server ○ Simple and lightweight ○ Uses “heartbeats” to control connection health ○ Server can separate socket connections into “rooms” ■ Example apps: chat systems with rooms, brazuca Example: Drawing collaborating tool 15
  • 16. Who uses Node.js (in production) 16 ● Big shots ○ github.com/nodejs/node-v0.x-archive/wiki/Projects,-Applications,-and-Companies-Using-Node