SlideShare a Scribd company logo
1 of 23
Download to read offline
REAL-TIME WEB
Medhat Dawoud
www.medhatdawoud.net
@Med7atDawoud
What is Real-time web
• The meaning is that: users can see the contents
as fast as the author publish it (like chat
applications)
• A lot of technologies are used to implement the
Real-time systems.
• Today I’m interested in a technology that do that
for us in an easy, reliable, and fantastic way
To create Real-time system on web we need ..
• Very fast web server.
• Very very fast I/O operations (Non-blocking).
• System that depend on event-driven(event-loops).
• Flexible tool to handle all of this in a simple way.
Some technologies for Real-time systems
Python [ twisted ]
Ruby [ EventMachine ]
Perl [ AnyEvent ]
If you deal with one of them, this presentation will be really understood at once.
Finally , The Magic Technology Appears
• 2009 - this guy “Ryan Dahl” releases something
that support the highly-performance
concurrent applications.
• It’s called Node.js
What is Node.js ?
• In simple words Node.js is ‘server-side JavaScript’.
• In not-so-simple words Node.js is a high-performance
network applications framework, well optimized for high
concurrent environments.
• It’s Open Source. It runs well on Linux systems, can
also run on Windows systems.
• uses an asynchronous event-driven model.
What is Node.js ?
• Built and run on V8 JavaScript engine.
• In ‘Node.js’ , ‘.js’ doesn’t mean that its solely written
JavaScript. It is 40% JS and 60% C++.
• is now the most followed project on Github,
exceeding Ruby on Rails .. woooooo
• From the official site:
‘Node's goal is to provide an easy way to build scalable
network programs’ - (from nodejs.org!)
Google V8 engine
• V8 is an open source JavaScript engine
developed by Google. It’s written in C++ and is
used in Google Chrome Browser.
• Faster than SpiderMonkey (used in firefox) over
4 times ( when V8 was invented ) 
- from an expert on stakoverflow -
Theory 1 : Event-loops
Event-loops are the core of event-driven programming, almost
all the UI programs use event-loops to track the user event, for
example: Clicks, Ajax Requests etc.
Client
Event loop
(main thread)
C++ Threadpool
(worker threads)
Clients send HTTP requests
to Node.js server
An Event-loop is woken up by OS,
passes request and response objects
to the thread-pool
Long-running jobs run
on worker threads
Response is sent
back to main thread
via callback
Event loop returns
result to client
Theory 2 : Non-blocking I/O
• Traditional I/O
var result = db.query(“select x from table_Y”);
doSomethingWith(result); //wait for result!
doSomethingWithOutResult(); //execution is blocked!
• Non-traditional, Non-blocking I/O
db.query(“select x from table_Y”,function (result){
doSomethingWith(result); //wait for result!
});
doSomethingWithOutResult(); //executes without any delay!
Natural & Features of Node.js ( some confusing )
• Apply it in the coolest, sexiest, most popular
language on the planet.
• Node.js uses an event-driven, non-blocking I/O
model, which makes it lightweight.
• The big support of V8 from Google is a great power.
Why JavaScript was suitable for that ?
• JavaScript Callbacks feature that solve the problem of
event-loops.
• The great NPM (Node Package Manager).
• Node.js JavaScript quite different : there is no DOM
implementation provided by Node.js,
• i.e. you can not do this:
var element = document.getElementById(“elementId”);
• Everything inside Node.js runs in a single-thread.
Natural & Features of Node.js ( some confusing )
What can we do with Node.js
• You can create an HTTP server and print ‘hello world’
on the browser in just 4 lines of JavaScript.
• You can create a DNS server.
• You can create a Web Chat Application like GTalk in the
browser.
• Node.js can also be used for creating online games,
collaboration tools or anything which sends updates to
the user in Real-time.
Example: Creating Http server
When to use Node.js ?
• streaming based Real-time services, online
games, web chat applications,..etc.
• If you need high level concurrency and not
worried about CPU-cycles.
• If you are good at JavaScript code.
• You will develop the front-end and back-end in the same
language, what a triumph 
Some Benchmarks (proof of power)
Taken from:
http://code.google.com/p/node-js-vs-apache-
php-benchmark/wiki/Tests
A benchmark between Apache+PHP
and node.js, shows the response time
for 1000 concurrent connections
making 10,000 requests each, for 5
tests.
Some Benchmarks (proof of power)
Taken from:
http://nodejs.org/jsconf2010.pdf
The benchmark shows the
response time in milli-secs for 4
evented servers.
Who is using Node.js
Complete list can be found at: https://github.com/joyent/node/wiki/Projects,-Applications,-and-Companies-Using-Node
Some Modules you will love them
• Express– to make things simpler e.g. syntax, DB connections.
• Jade – HTML template system
• Socket.IO– to create real-time apps
• CoffeeScript – for easier JavaScript development
Find out more about some widely used Node.js modules at:
http://blog.nodejitsu.com/top-node-module-creators
The last thing to say (How to start ?!)
• Try to explore the rest of Node.js your self.
• I recommend a free book to start called
• ( O’raily Book : Up and Running With Node.js)
• Tutorial sites:
• Nodejs.org
• Letsnode.com
• Google.com
• The series of articles in arabic isA on ( medhatdawoud.net)
Medhat Dawoud
www.medhatdawoud.net
Twitter: @Med7atdawoud
Thanks

More Related Content

What's hot

Programming WebSockets - April 20 2010
Programming WebSockets - April 20 2010Programming WebSockets - April 20 2010
Programming WebSockets - April 20 2010
sullis
 

What's hot (20)

How we use Bitbucket to build Bitbucket
How we use Bitbucket to build BitbucketHow we use Bitbucket to build Bitbucket
How we use Bitbucket to build Bitbucket
 
High Productivity Web Development Workflow
High Productivity Web Development WorkflowHigh Productivity Web Development Workflow
High Productivity Web Development Workflow
 
"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk
"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk
"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk
 
Microservices in Golang
Microservices in GolangMicroservices in Golang
Microservices in Golang
 
Gradle : An introduction
Gradle : An introduction Gradle : An introduction
Gradle : An introduction
 
Difference between gitlab vs github vs bitbucket
Difference between gitlab vs github vs bitbucketDifference between gitlab vs github vs bitbucket
Difference between gitlab vs github vs bitbucket
 
Github PowerPoint Final
Github PowerPoint FinalGithub PowerPoint Final
Github PowerPoint Final
 
Nodejs
NodejsNodejs
Nodejs
 
Blazor, lo sapevi che...
Blazor, lo sapevi che...Blazor, lo sapevi che...
Blazor, lo sapevi che...
 
Firebase Code Lab - 2015 GDG Buffalo DevFest
Firebase Code Lab - 2015 GDG Buffalo DevFestFirebase Code Lab - 2015 GDG Buffalo DevFest
Firebase Code Lab - 2015 GDG Buffalo DevFest
 
Programming WebSockets - April 20 2010
Programming WebSockets - April 20 2010Programming WebSockets - April 20 2010
Programming WebSockets - April 20 2010
 
Meetup React Sanca - 29/11/18 - React Testing
Meetup React Sanca - 29/11/18 - React TestingMeetup React Sanca - 29/11/18 - React Testing
Meetup React Sanca - 29/11/18 - React Testing
 
The New York Times: Sustainable Systems, Powered by Python
The New York Times: Sustainable Systems, Powered by PythonThe New York Times: Sustainable Systems, Powered by Python
The New York Times: Sustainable Systems, Powered by Python
 
Node js
Node jsNode js
Node js
 
Using the GitHub App to Connect to Bitbucket
Using the GitHub App to Connect to BitbucketUsing the GitHub App to Connect to Bitbucket
Using the GitHub App to Connect to Bitbucket
 
React Faceoff at Philly.NET
React Faceoff at Philly.NETReact Faceoff at Philly.NET
React Faceoff at Philly.NET
 
Webkit Chromium Contribution Process
Webkit Chromium Contribution ProcessWebkit Chromium Contribution Process
Webkit Chromium Contribution Process
 
Git
GitGit
Git
 
How Git and Gerrit make you more productive
How Git and Gerrit make you more productiveHow Git and Gerrit make you more productive
How Git and Gerrit make you more productive
 
Intro to meteor @py gotham Aug 15-16 2015
Intro to meteor @py gotham Aug 15-16 2015Intro to meteor @py gotham Aug 15-16 2015
Intro to meteor @py gotham Aug 15-16 2015
 

Viewers also liked (9)

Thread
ThreadThread
Thread
 
Threading
ThreadingThreading
Threading
 
Multi threading design pattern
Multi threading design patternMulti threading design pattern
Multi threading design pattern
 
multi threading
multi threadingmulti threading
multi threading
 
Threads c sharp
Threads c sharpThreads c sharp
Threads c sharp
 
C# Advanced L04-Threading
C# Advanced L04-ThreadingC# Advanced L04-Threading
C# Advanced L04-Threading
 
Threading in C#
Threading in C#Threading in C#
Threading in C#
 
Threads c sharp
Threads c sharpThreads c sharp
Threads c sharp
 
Threading in c#
Threading in c#Threading in c#
Threading in c#
 

Similar to Real time web

Similar to Real time web (20)

Beginners Node.js
Beginners Node.jsBeginners Node.js
Beginners Node.js
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Node.js for beginner
Node.js for beginnerNode.js for beginner
Node.js for beginner
 
Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6
 
Proposal
ProposalProposal
Proposal
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect Guide
 
What is Node.js
What is Node.jsWhat is Node.js
What is Node.js
 
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
 
Nodejs
NodejsNodejs
Nodejs
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
 
Node
NodeNode
Node
 
Node js internal
Node js internalNode js internal
Node js internal
 
NodeJS and what is actually does
NodeJS and what is actually doesNodeJS and what is actually does
NodeJS and what is actually does
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
 
Tech Thursdays: Building Products
Tech Thursdays: Building ProductsTech Thursdays: Building Products
Tech Thursdays: Building Products
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
An overview of node.js
An overview of node.jsAn overview of node.js
An overview of node.js
 
Node
NodeNode
Node
 

More from Medhat Dawoud (12)

Using Git and BitBucket
Using Git and BitBucketUsing Git and BitBucket
Using Git and BitBucket
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linux
 
Select your career
Select your careerSelect your career
Select your career
 
Intro to t sql – 3rd session
Intro to t sql – 3rd sessionIntro to t sql – 3rd session
Intro to t sql – 3rd session
 
Intro to T-SQL - 1st session
Intro to T-SQL - 1st sessionIntro to T-SQL - 1st session
Intro to T-SQL - 1st session
 
Intro to T-SQL – 2nd session
Intro to T-SQL – 2nd sessionIntro to T-SQL – 2nd session
Intro to T-SQL – 2nd session
 
Mesh cloud (road to mongoDB)
Mesh cloud (road to mongoDB)Mesh cloud (road to mongoDB)
Mesh cloud (road to mongoDB)
 
Before start
Before startBefore start
Before start
 
DevMix Startup
DevMix StartupDevMix Startup
DevMix Startup
 
How to python
How to pythonHow to python
How to python
 
Program threats
Program threatsProgram threats
Program threats
 
Unusual C# - OOP
Unusual C# - OOPUnusual C# - OOP
Unusual C# - OOP
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

Real time web

  • 2.
  • 3. What is Real-time web • The meaning is that: users can see the contents as fast as the author publish it (like chat applications) • A lot of technologies are used to implement the Real-time systems. • Today I’m interested in a technology that do that for us in an easy, reliable, and fantastic way
  • 4. To create Real-time system on web we need .. • Very fast web server. • Very very fast I/O operations (Non-blocking). • System that depend on event-driven(event-loops). • Flexible tool to handle all of this in a simple way.
  • 5. Some technologies for Real-time systems Python [ twisted ] Ruby [ EventMachine ] Perl [ AnyEvent ] If you deal with one of them, this presentation will be really understood at once.
  • 6. Finally , The Magic Technology Appears • 2009 - this guy “Ryan Dahl” releases something that support the highly-performance concurrent applications. • It’s called Node.js
  • 7. What is Node.js ? • In simple words Node.js is ‘server-side JavaScript’. • In not-so-simple words Node.js is a high-performance network applications framework, well optimized for high concurrent environments. • It’s Open Source. It runs well on Linux systems, can also run on Windows systems. • uses an asynchronous event-driven model.
  • 8. What is Node.js ? • Built and run on V8 JavaScript engine. • In ‘Node.js’ , ‘.js’ doesn’t mean that its solely written JavaScript. It is 40% JS and 60% C++. • is now the most followed project on Github, exceeding Ruby on Rails .. woooooo • From the official site: ‘Node's goal is to provide an easy way to build scalable network programs’ - (from nodejs.org!)
  • 9. Google V8 engine • V8 is an open source JavaScript engine developed by Google. It’s written in C++ and is used in Google Chrome Browser. • Faster than SpiderMonkey (used in firefox) over 4 times ( when V8 was invented )  - from an expert on stakoverflow -
  • 10.
  • 11. Theory 1 : Event-loops Event-loops are the core of event-driven programming, almost all the UI programs use event-loops to track the user event, for example: Clicks, Ajax Requests etc. Client Event loop (main thread) C++ Threadpool (worker threads) Clients send HTTP requests to Node.js server An Event-loop is woken up by OS, passes request and response objects to the thread-pool Long-running jobs run on worker threads Response is sent back to main thread via callback Event loop returns result to client
  • 12. Theory 2 : Non-blocking I/O • Traditional I/O var result = db.query(“select x from table_Y”); doSomethingWith(result); //wait for result! doSomethingWithOutResult(); //execution is blocked! • Non-traditional, Non-blocking I/O db.query(“select x from table_Y”,function (result){ doSomethingWith(result); //wait for result! }); doSomethingWithOutResult(); //executes without any delay!
  • 13. Natural & Features of Node.js ( some confusing ) • Apply it in the coolest, sexiest, most popular language on the planet. • Node.js uses an event-driven, non-blocking I/O model, which makes it lightweight. • The big support of V8 from Google is a great power.
  • 14. Why JavaScript was suitable for that ? • JavaScript Callbacks feature that solve the problem of event-loops. • The great NPM (Node Package Manager). • Node.js JavaScript quite different : there is no DOM implementation provided by Node.js, • i.e. you can not do this: var element = document.getElementById(“elementId”); • Everything inside Node.js runs in a single-thread. Natural & Features of Node.js ( some confusing )
  • 15. What can we do with Node.js • You can create an HTTP server and print ‘hello world’ on the browser in just 4 lines of JavaScript. • You can create a DNS server. • You can create a Web Chat Application like GTalk in the browser. • Node.js can also be used for creating online games, collaboration tools or anything which sends updates to the user in Real-time.
  • 17. When to use Node.js ? • streaming based Real-time services, online games, web chat applications,..etc. • If you need high level concurrency and not worried about CPU-cycles. • If you are good at JavaScript code. • You will develop the front-end and back-end in the same language, what a triumph 
  • 18. Some Benchmarks (proof of power) Taken from: http://code.google.com/p/node-js-vs-apache- php-benchmark/wiki/Tests A benchmark between Apache+PHP and node.js, shows the response time for 1000 concurrent connections making 10,000 requests each, for 5 tests.
  • 19. Some Benchmarks (proof of power) Taken from: http://nodejs.org/jsconf2010.pdf The benchmark shows the response time in milli-secs for 4 evented servers.
  • 20. Who is using Node.js Complete list can be found at: https://github.com/joyent/node/wiki/Projects,-Applications,-and-Companies-Using-Node
  • 21. Some Modules you will love them • Express– to make things simpler e.g. syntax, DB connections. • Jade – HTML template system • Socket.IO– to create real-time apps • CoffeeScript – for easier JavaScript development Find out more about some widely used Node.js modules at: http://blog.nodejitsu.com/top-node-module-creators
  • 22. The last thing to say (How to start ?!) • Try to explore the rest of Node.js your self. • I recommend a free book to start called • ( O’raily Book : Up and Running With Node.js) • Tutorial sites: • Nodejs.org • Letsnode.com • Google.com • The series of articles in arabic isA on ( medhatdawoud.net)