SlideShare uma empresa Scribd logo
1 de 33
Baixar para ler offline
About myself
Ivo Nellis
CTO, Fenomen Veebiagentuur

● Working with Drupal since 2007
● Contributed mostly to Estonian translations
● Main focus: Drupal, Node.js, MongoDB

                                   Skype: ivonellis
                                  Twitter: ivonellis
                                 ivo@fenomen.ee
Developing realtime apps
 with Node.js and Drupal
           Ivo Nellis
     Fenomen veebiagentuur
With Node.js, you can
  write web applications
Perfect for fast, scalable, light-weight data-
 intensive and real-time web applications
Node.js project is new
       Relatively...
1990                 2000                                  2010


                                                             Node.js


                                             Ruby on Rails



                                        ASP.NET

                          Java


                    PHP


       Python



Perl




                   Created 2009 by Ryan Dahl
With node, you can write
      in JavaScript
  or in something that compiles to JS
           (CoffeeScript, ...)
Server-side JavaScript is great!
● JavaScript is the core of modern Web
   ○ A lot of existing JS developers
   ○ Familiarity with asynchronous programming model
● Share code between client and server
   ○ Can use existing libraries on server side as well.
● It's fast ... and it's getting faster every day
   ○ Huge competition between browser vendors
But SSJS has been done before..

 Jaxer Rhino Ringo
Ejscript Spludo LiveWire
Node.js is built on
 Google V8 JS engine
Fast, Single runtime = less compability
                issues
Node.js is asynchronous
    & event driven
   and it's great for real-time apps
Apache request lifecycle


 Incoming requests




                     Child processes / threads
The cost of I/O
L1-cache                                                      3 cycles
L2-cache                                                   14 cycles
RAM                                                      250 cycles
Disk                                     41 000 000 cycles
Network                               240 000 000 cycles
           http://blog.mixu.net/2011/02/01/understanding-the-node-js-event-loop/

           http://duartes.org/gustavo/blog/post/what-your-computer-does-while-you-wait
Node.js event loop


 Incoming requests




                     I/O callback



                           I/O request




                           Single process
Hello World!
var http = require('http');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': text/plain'});
  res.end('Hello Worldn');
}).listen(8000);

                        ●   Node itself does not provide much
                        ●   No "standard" webserver features:
                        ●   No authentication
                        ●   No session handling
                        ●   No cookies
                        ●   No email
                        ●   No templating system
                        ●   No MVC or framework layer
You need to extend
●   Active community
●   Node package manager (npm) is great
●   10913 packages as of 06/2012
●   Simple one-line installation
●   Manages all the dependencies for you

$ npm install express
var express = require("express");
express                            mongodb-native

connect           socket.io                              redis

 request             nodemailer
                                                         jquery
   underscore                  calipso
           async
           https://github.com/joyent/node/wiki/Modules
                       search.npmjs.org
                           github.com
Node.js vs Drupal
  CMS                  Modules, themes, ...      Libraries ...


                                                Calipso / etc...


  Framework                  Drupal           Express.js
                                                                 LIB
                                              Connect.js


  Scripting language          PHP
                                                   Node.js
  Web Server
                             Apache
Web sockets
  and socket.io
Realtime communication
 over HTTP is difficult
 HTTP is request - response by nature
 No good solutions (ajax, long polling)
Solution: Web sockets
●   Websocket API is a part of HTML5 spec
●   New protocol: ws:// & wss://
●   Persistant connection
●   Both parties can send data at any time
●   Native support in Chrome, Firefox, IE10
●   With node.js and socket.io you can use Web
    Sockets today

                http://socket.io/
Socket.io client & server
<script src="/socket.io/socket.io.js"></script>
<script>
  var socket = io.connect('http://localhost');
  socket.on('news', function (data) {
    console.log(data);
  });
</script>
------------------------------------------------
-
var io = require('socket.io').listen(80);

io.sockets.on('connection', function (socket) {
  socket.emit('news', { hello: 'world' });
});
Combining Drupal, Node.
  js and Web sockets
       When and how?
When should I consider it?
● Doing it all on Apache & Drupal becomes too
  expensive and unscalable
  ○   Chat, messaging
  ○   Liveblog
  ○   Streaming data (logs, etc...)
  ○   API layer for a mobile app
  ○   Realtime widgets (sports, stocks)
  ○   Games
  ○   etc...
How?
● A: Write your own Node server
  ○ Write your own module code for Drupal
  ○ Write your own client code


● B: Build on the existing Drupal nodejs
  module
  ○ provides node.js server with socket.io support
  ○ provides a drupal module that integrates with it
  ○ focuses mainly on realtime updates

            http://drupal.org/project/nodejs
nodejs module for Drupal
Enables realtime communication
  Provides a module



    Drupal                                           Client
                                                     Clients



                      Node.js & socket.io
                          Provides a server script
Broadcast messages
Update Watchdog page realtime
Your custom module
 $message = (object) array(
    'broadcast' => TRUE,
    'data' => (object) array(
       'subject' => 'Hi!',
       'body' => 'An important message!',
    ),
    'channel' => 'my_channel',
 );
 nodejs_enqueue_message($message);
And the client side implementation
Drupal.nodejs.callbacks.example = {
  callback: function(message) {
    if (message.channel == "my_channel") {
      alert(message.data);
    }
  }
}
Thank you!
Developing realtime apps with Drupal and NodeJS

Mais conteúdo relacionado

Mais procurados

Presentation 22@Barcelona The Innovation District
Presentation 22@Barcelona The Innovation DistrictPresentation 22@Barcelona The Innovation District
Presentation 22@Barcelona The Innovation District22arrobabcn
 
Untold story of chandigarh
Untold story of chandigarhUntold story of chandigarh
Untold story of chandigarhJIT KUMAR GUPTA
 
Concept of town planning development
Concept of town planning developmentConcept of town planning development
Concept of town planning developmentAlin Amalin
 
Planning concepts
Planning conceptsPlanning concepts
Planning conceptsctlachu
 
Ekistics - Defining What is a Polis? What does it consist of
Ekistics - Defining What is a Polis?  What does it consist ofEkistics - Defining What is a Polis?  What does it consist of
Ekistics - Defining What is a Polis? What does it consist ofYaryalitsa
 
Spatial planning india
Spatial planning indiaSpatial planning india
Spatial planning indiaDelhi2050
 
Planning for Open Spaces to make cities Healthy
Planning for Open  Spaces to make cities HealthyPlanning for Open  Spaces to make cities Healthy
Planning for Open Spaces to make cities HealthyJIT KUMAR GUPTA
 
ANCHORUNG THE HARBOUR (FISHING AND MARKETING PORT).pdf
ANCHORUNG THE HARBOUR (FISHING AND MARKETING PORT).pdfANCHORUNG THE HARBOUR (FISHING AND MARKETING PORT).pdf
ANCHORUNG THE HARBOUR (FISHING AND MARKETING PORT).pdfAtharv Mehta
 
The goa land development and building 2010.
The goa land development and building 2010.The goa land development and building 2010.
The goa land development and building 2010.Joel Manoj
 
Development Plan of Mehsana, Gujarat
Development Plan of Mehsana, GujaratDevelopment Plan of Mehsana, Gujarat
Development Plan of Mehsana, GujaratPratham Pincha
 
Town planning (3)
Town planning (3)Town planning (3)
Town planning (3)Dhruv Seth
 
Transformations @ CEPT University
Transformations @ CEPT UniversityTransformations @ CEPT University
Transformations @ CEPT UniversityCEPT University
 
Dissertation-Minimalism in Architecture
Dissertation-Minimalism in ArchitectureDissertation-Minimalism in Architecture
Dissertation-Minimalism in ArchitectureKriti Bafna
 
The Punjab Regional and Town Planning and Development Act,1995
The Punjab Regional and Town Planning and Development Act,1995The Punjab Regional and Town Planning and Development Act,1995
The Punjab Regional and Town Planning and Development Act,1995JIT KUMAR GUPTA
 
Programming for Design EDITH CHERRY - Chapter 1
Programming for Design EDITH CHERRY - Chapter 1Programming for Design EDITH CHERRY - Chapter 1
Programming for Design EDITH CHERRY - Chapter 1Galala University
 
Options for Cost- Effective Housing
Options for Cost- Effective HousingOptions for Cost- Effective Housing
Options for Cost- Effective HousingJIT KUMAR GUPTA
 
Gujarat Development Control Regulations
Gujarat Development Control RegulationsGujarat Development Control Regulations
Gujarat Development Control RegulationsVishal Dedhia
 

Mais procurados (20)

Presentation 22@Barcelona The Innovation District
Presentation 22@Barcelona The Innovation DistrictPresentation 22@Barcelona The Innovation District
Presentation 22@Barcelona The Innovation District
 
library for public.ppt
library for public.pptlibrary for public.ppt
library for public.ppt
 
Untold story of chandigarh
Untold story of chandigarhUntold story of chandigarh
Untold story of chandigarh
 
Concept of town planning development
Concept of town planning developmentConcept of town planning development
Concept of town planning development
 
Planning concepts
Planning conceptsPlanning concepts
Planning concepts
 
Ekistics - Defining What is a Polis? What does it consist of
Ekistics - Defining What is a Polis?  What does it consist ofEkistics - Defining What is a Polis?  What does it consist of
Ekistics - Defining What is a Polis? What does it consist of
 
Spatial planning india
Spatial planning indiaSpatial planning india
Spatial planning india
 
Planning for Open Spaces to make cities Healthy
Planning for Open  Spaces to make cities HealthyPlanning for Open  Spaces to make cities Healthy
Planning for Open Spaces to make cities Healthy
 
ANCHORUNG THE HARBOUR (FISHING AND MARKETING PORT).pdf
ANCHORUNG THE HARBOUR (FISHING AND MARKETING PORT).pdfANCHORUNG THE HARBOUR (FISHING AND MARKETING PORT).pdf
ANCHORUNG THE HARBOUR (FISHING AND MARKETING PORT).pdf
 
The goa land development and building 2010.
The goa land development and building 2010.The goa land development and building 2010.
The goa land development and building 2010.
 
Development Plan of Mehsana, Gujarat
Development Plan of Mehsana, GujaratDevelopment Plan of Mehsana, Gujarat
Development Plan of Mehsana, Gujarat
 
Town planning (3)
Town planning (3)Town planning (3)
Town planning (3)
 
Transformations @ CEPT University
Transformations @ CEPT UniversityTransformations @ CEPT University
Transformations @ CEPT University
 
Urban and regional planning
Urban and regional planning  Urban and regional planning
Urban and regional planning
 
Dissertation-Minimalism in Architecture
Dissertation-Minimalism in ArchitectureDissertation-Minimalism in Architecture
Dissertation-Minimalism in Architecture
 
The Punjab Regional and Town Planning and Development Act,1995
The Punjab Regional and Town Planning and Development Act,1995The Punjab Regional and Town Planning and Development Act,1995
The Punjab Regional and Town Planning and Development Act,1995
 
Programming for Design EDITH CHERRY - Chapter 1
Programming for Design EDITH CHERRY - Chapter 1Programming for Design EDITH CHERRY - Chapter 1
Programming for Design EDITH CHERRY - Chapter 1
 
Nanded City Presentation
Nanded City PresentationNanded City Presentation
Nanded City Presentation
 
Options for Cost- Effective Housing
Options for Cost- Effective HousingOptions for Cost- Effective Housing
Options for Cost- Effective Housing
 
Gujarat Development Control Regulations
Gujarat Development Control RegulationsGujarat Development Control Regulations
Gujarat Development Control Regulations
 

Semelhante a Developing realtime apps with Drupal and NodeJS

GeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime WebGeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime WebBhagaban Behera
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiJackson Tian
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.jsguileen
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsasync_io
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jibanJibanananda Sana
 
End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013Alexandre Morgaut
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsVikash Singh
 
JavaScript on the server - Node.js
JavaScript on the server - Node.jsJavaScript on the server - Node.js
JavaScript on the server - Node.jsRody Middelkoop
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tourcacois
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backendDavid Padbury
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 

Semelhante a Developing realtime apps with Drupal and NodeJS (20)

Node js
Node jsNode js
Node js
 
GeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime WebGeekCampSG - Nodejs , Websockets and Realtime Web
GeekCampSG - Nodejs , Websockets and Realtime Web
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin Shanghai
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.js
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
Nodejs
NodejsNodejs
Nodejs
 
Nodejs
NodejsNodejs
Nodejs
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jiban
 
Beginners Node.js
Beginners Node.jsBeginners Node.js
Beginners Node.js
 
End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013End-to-end HTML5 APIs - The Geek Gathering 2013
End-to-end HTML5 APIs - The Geek Gathering 2013
 
Nodejs overview
Nodejs overviewNodejs overview
Nodejs overview
 
20120306 dublin js
20120306 dublin js20120306 dublin js
20120306 dublin js
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect Guide
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Node azure
Node azureNode azure
Node azure
 
JavaScript on the server - Node.js
JavaScript on the server - Node.jsJavaScript on the server - Node.js
JavaScript on the server - Node.js
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tour
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
Node.js on Azure
Node.js on AzureNode.js on Azure
Node.js on Azure
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 

Mais de drupalcampest

Welcome to Drupalcamp Estonia 2012
Welcome to Drupalcamp Estonia 2012Welcome to Drupalcamp Estonia 2012
Welcome to Drupalcamp Estonia 2012drupalcampest
 
Implementing Drupalcamp sites
Implementing Drupalcamp sitesImplementing Drupalcamp sites
Implementing Drupalcamp sitesdrupalcampest
 
Designing Drupalcamp sites
Designing Drupalcamp sitesDesigning Drupalcamp sites
Designing Drupalcamp sitesdrupalcampest
 
Drupal vs. the Others
Drupal vs. the OthersDrupal vs. the Others
Drupal vs. the Othersdrupalcampest
 
Migrating University of Tartu websites to Drupal
Migrating University of Tartu websites to DrupalMigrating University of Tartu websites to Drupal
Migrating University of Tartu websites to Drupaldrupalcampest
 
Drupalcamp Tallinn - Drupal 8
Drupalcamp Tallinn - Drupal 8Drupalcamp Tallinn - Drupal 8
Drupalcamp Tallinn - Drupal 8drupalcampest
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sitesdrupalcampest
 
Drupalcamp Estonia - Drupal 7
Drupalcamp Estonia - Drupal 7Drupalcamp Estonia - Drupal 7
Drupalcamp Estonia - Drupal 7drupalcampest
 
Drupalcamp Estonia - Introduction to Drupal
Drupalcamp Estonia - Introduction to DrupalDrupalcamp Estonia - Introduction to Drupal
Drupalcamp Estonia - Introduction to Drupaldrupalcampest
 
Drupalcamp Estonia 2011 - Welcome
Drupalcamp Estonia 2011 - WelcomeDrupalcamp Estonia 2011 - Welcome
Drupalcamp Estonia 2011 - Welcomedrupalcampest
 

Mais de drupalcampest (11)

Advanced theming
Advanced themingAdvanced theming
Advanced theming
 
Welcome to Drupalcamp Estonia 2012
Welcome to Drupalcamp Estonia 2012Welcome to Drupalcamp Estonia 2012
Welcome to Drupalcamp Estonia 2012
 
Implementing Drupalcamp sites
Implementing Drupalcamp sitesImplementing Drupalcamp sites
Implementing Drupalcamp sites
 
Designing Drupalcamp sites
Designing Drupalcamp sitesDesigning Drupalcamp sites
Designing Drupalcamp sites
 
Drupal vs. the Others
Drupal vs. the OthersDrupal vs. the Others
Drupal vs. the Others
 
Migrating University of Tartu websites to Drupal
Migrating University of Tartu websites to DrupalMigrating University of Tartu websites to Drupal
Migrating University of Tartu websites to Drupal
 
Drupalcamp Tallinn - Drupal 8
Drupalcamp Tallinn - Drupal 8Drupalcamp Tallinn - Drupal 8
Drupalcamp Tallinn - Drupal 8
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sites
 
Drupalcamp Estonia - Drupal 7
Drupalcamp Estonia - Drupal 7Drupalcamp Estonia - Drupal 7
Drupalcamp Estonia - Drupal 7
 
Drupalcamp Estonia - Introduction to Drupal
Drupalcamp Estonia - Introduction to DrupalDrupalcamp Estonia - Introduction to Drupal
Drupalcamp Estonia - Introduction to Drupal
 
Drupalcamp Estonia 2011 - Welcome
Drupalcamp Estonia 2011 - WelcomeDrupalcamp Estonia 2011 - Welcome
Drupalcamp Estonia 2011 - Welcome
 

Último

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Último (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Developing realtime apps with Drupal and NodeJS

  • 1.
  • 2. About myself Ivo Nellis CTO, Fenomen Veebiagentuur ● Working with Drupal since 2007 ● Contributed mostly to Estonian translations ● Main focus: Drupal, Node.js, MongoDB Skype: ivonellis Twitter: ivonellis ivo@fenomen.ee
  • 3. Developing realtime apps with Node.js and Drupal Ivo Nellis Fenomen veebiagentuur
  • 4. With Node.js, you can write web applications Perfect for fast, scalable, light-weight data- intensive and real-time web applications
  • 5. Node.js project is new Relatively...
  • 6. 1990 2000 2010 Node.js Ruby on Rails ASP.NET Java PHP Python Perl Created 2009 by Ryan Dahl
  • 7. With node, you can write in JavaScript or in something that compiles to JS (CoffeeScript, ...)
  • 8. Server-side JavaScript is great! ● JavaScript is the core of modern Web ○ A lot of existing JS developers ○ Familiarity with asynchronous programming model ● Share code between client and server ○ Can use existing libraries on server side as well. ● It's fast ... and it's getting faster every day ○ Huge competition between browser vendors
  • 9. But SSJS has been done before.. Jaxer Rhino Ringo Ejscript Spludo LiveWire
  • 10. Node.js is built on Google V8 JS engine Fast, Single runtime = less compability issues
  • 11. Node.js is asynchronous & event driven and it's great for real-time apps
  • 12. Apache request lifecycle Incoming requests Child processes / threads
  • 13. The cost of I/O L1-cache 3 cycles L2-cache 14 cycles RAM 250 cycles Disk 41 000 000 cycles Network 240 000 000 cycles http://blog.mixu.net/2011/02/01/understanding-the-node-js-event-loop/ http://duartes.org/gustavo/blog/post/what-your-computer-does-while-you-wait
  • 14. Node.js event loop Incoming requests I/O callback I/O request Single process
  • 15. Hello World! var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': text/plain'}); res.end('Hello Worldn'); }).listen(8000); ● Node itself does not provide much ● No "standard" webserver features: ● No authentication ● No session handling ● No cookies ● No email ● No templating system ● No MVC or framework layer
  • 16. You need to extend ● Active community ● Node package manager (npm) is great ● 10913 packages as of 06/2012 ● Simple one-line installation ● Manages all the dependencies for you $ npm install express var express = require("express");
  • 17. express mongodb-native connect socket.io redis request nodemailer jquery underscore calipso async https://github.com/joyent/node/wiki/Modules search.npmjs.org github.com
  • 18. Node.js vs Drupal CMS Modules, themes, ... Libraries ... Calipso / etc... Framework Drupal Express.js LIB Connect.js Scripting language PHP Node.js Web Server Apache
  • 19. Web sockets and socket.io
  • 20. Realtime communication over HTTP is difficult HTTP is request - response by nature No good solutions (ajax, long polling)
  • 21. Solution: Web sockets ● Websocket API is a part of HTML5 spec ● New protocol: ws:// & wss:// ● Persistant connection ● Both parties can send data at any time ● Native support in Chrome, Firefox, IE10 ● With node.js and socket.io you can use Web Sockets today http://socket.io/
  • 22. Socket.io client & server <script src="/socket.io/socket.io.js"></script> <script> var socket = io.connect('http://localhost'); socket.on('news', function (data) { console.log(data); }); </script> ------------------------------------------------ - var io = require('socket.io').listen(80); io.sockets.on('connection', function (socket) { socket.emit('news', { hello: 'world' }); });
  • 23. Combining Drupal, Node. js and Web sockets When and how?
  • 24. When should I consider it? ● Doing it all on Apache & Drupal becomes too expensive and unscalable ○ Chat, messaging ○ Liveblog ○ Streaming data (logs, etc...) ○ API layer for a mobile app ○ Realtime widgets (sports, stocks) ○ Games ○ etc...
  • 25. How? ● A: Write your own Node server ○ Write your own module code for Drupal ○ Write your own client code ● B: Build on the existing Drupal nodejs module ○ provides node.js server with socket.io support ○ provides a drupal module that integrates with it ○ focuses mainly on realtime updates http://drupal.org/project/nodejs
  • 27. Enables realtime communication Provides a module Drupal Client Clients Node.js & socket.io Provides a server script
  • 30. Your custom module $message = (object) array( 'broadcast' => TRUE, 'data' => (object) array( 'subject' => 'Hi!', 'body' => 'An important message!', ), 'channel' => 'my_channel', ); nodejs_enqueue_message($message);
  • 31. And the client side implementation Drupal.nodejs.callbacks.example = { callback: function(message) { if (message.channel == "my_channel") { alert(message.data); } } }