SlideShare a Scribd company logo
Developing realtime apps with Drupal and NodeJS
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

More Related Content

What's hot (20)

PDF
Introduction to Generative Adversarial Networks
BennoG1
 
PDF
Công nghệ yêu cầu requirements engineering (re)
nataliej4
 
PDF
Giáo trình xử lý ảnh
Tùng Trần
 
PPTX
Introduction to CNN
Shuai Zhang
 
PPTX
Federated Learning
University of Oslo
 
PDF
Đề tài: Xây dựng hệ thống quản lý kinh doanh cho công ty dược
Dịch vụ viết bài trọn gói ZALO: 0909232620
 
DOCX
BÁO CÁO ĐỒ ÁN đề tài bán website bán đồ nông sản
Solomon430779
 
PPTX
Convolutional Neural Network (CNN) presentation from theory to code in Theano
Seongwon Hwang
 
PDF
Simulation of Direct Sequence Spread Spectrum for Wireless Communication Syst...
ijtsrd
 
PDF
Efficient Neural Architecture Search via Parameter Sharing
Jinwon Lee
 
PDF
Luận án: Phân lớp dữ liệu bằng cây quyết định mờ, HAY
Dịch vụ viết bài trọn gói ZALO 0917193864
 
PPTX
Что такое Docker
Pavel Klimiankou
 
PDF
Lập trình hướng đối tượng trong PHP
Jino Hoàng
 
PPTX
181123 poseest101 devfest_pangyo_jwkang
Jaewook. Kang
 
DOC
Thiết kế hệ thống mạng nội bộ cho cty vn transport
Hate To Love
 
PDF
Recommender systems
S.M. Mahdi Seyednezhad, Ph.D.
 
PDF
Deep Learning - Overview of my work II
Mohamed Loey
 
PPTX
Web technology Unit-I Part D - message format
SSN College of Engineering, Kalavakkam
 
PDF
Tài liệu HTML5-CSS3
Lương Bá Hợp
 
PPTX
No sql distilled-distilled
rICh morrow
 
Introduction to Generative Adversarial Networks
BennoG1
 
Công nghệ yêu cầu requirements engineering (re)
nataliej4
 
Giáo trình xử lý ảnh
Tùng Trần
 
Introduction to CNN
Shuai Zhang
 
Federated Learning
University of Oslo
 
Đề tài: Xây dựng hệ thống quản lý kinh doanh cho công ty dược
Dịch vụ viết bài trọn gói ZALO: 0909232620
 
BÁO CÁO ĐỒ ÁN đề tài bán website bán đồ nông sản
Solomon430779
 
Convolutional Neural Network (CNN) presentation from theory to code in Theano
Seongwon Hwang
 
Simulation of Direct Sequence Spread Spectrum for Wireless Communication Syst...
ijtsrd
 
Efficient Neural Architecture Search via Parameter Sharing
Jinwon Lee
 
Luận án: Phân lớp dữ liệu bằng cây quyết định mờ, HAY
Dịch vụ viết bài trọn gói ZALO 0917193864
 
Что такое Docker
Pavel Klimiankou
 
Lập trình hướng đối tượng trong PHP
Jino Hoàng
 
181123 poseest101 devfest_pangyo_jwkang
Jaewook. Kang
 
Thiết kế hệ thống mạng nội bộ cho cty vn transport
Hate To Love
 
Recommender systems
S.M. Mahdi Seyednezhad, Ph.D.
 
Deep Learning - Overview of my work II
Mohamed Loey
 
Web technology Unit-I Part D - message format
SSN College of Engineering, Kalavakkam
 
Tài liệu HTML5-CSS3
Lương Bá Hợp
 
No sql distilled-distilled
rICh morrow
 

Similar to Developing realtime apps with Drupal and NodeJS (20)

PPT
Node js
Chirag Parmar
 
PPTX
GeekCampSG - Nodejs , Websockets and Realtime Web
Bhagaban Behera
 
PDF
Why Node.js
guileen
 
PDF
Why Nodejs Guilin Shanghai
Jackson Tian
 
KEY
Practical Use of MongoDB for Node.js
async_io
 
PPTX
Nodejs
Bhushan Patil
 
PPTX
Nodejs
Vinod Kumar Marupu
 
PPTX
Introduction to node.js by jiban
Jibanananda Sana
 
PPTX
Beginners Node.js
Khaled Mosharraf
 
PDF
End-to-end HTML5 APIs - The Geek Gathering 2013
Alexandre Morgaut
 
PPTX
Nodejs overview
Nicola Del Gobbo
 
KEY
20120306 dublin js
Richard Rodger
 
PPTX
Kalp Corporate Node JS Perfect Guide
Kalp Corporate
 
PPTX
Introduction to Node.js
Vikash Singh
 
PDF
Node azure
Emanuele DelBono
 
PPTX
JavaScript on the server - Node.js
Rody Middelkoop
 
PPTX
Node.js: A Guided Tour
cacois
 
KEY
node.js: Javascript's in your backend
David Padbury
 
PPTX
Node.js on Azure
Sasha Goldshtein
 
PPTX
introduction to node.js
orkaplan
 
Node js
Chirag Parmar
 
GeekCampSG - Nodejs , Websockets and Realtime Web
Bhagaban Behera
 
Why Node.js
guileen
 
Why Nodejs Guilin Shanghai
Jackson Tian
 
Practical Use of MongoDB for Node.js
async_io
 
Introduction to node.js by jiban
Jibanananda Sana
 
Beginners Node.js
Khaled Mosharraf
 
End-to-end HTML5 APIs - The Geek Gathering 2013
Alexandre Morgaut
 
Nodejs overview
Nicola Del Gobbo
 
20120306 dublin js
Richard Rodger
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate
 
Introduction to Node.js
Vikash Singh
 
Node azure
Emanuele DelBono
 
JavaScript on the server - Node.js
Rody Middelkoop
 
Node.js: A Guided Tour
cacois
 
node.js: Javascript's in your backend
David Padbury
 
Node.js on Azure
Sasha Goldshtein
 
introduction to node.js
orkaplan
 
Ad

More from drupalcampest (11)

PDF
Advanced theming
drupalcampest
 
PDF
Welcome to Drupalcamp Estonia 2012
drupalcampest
 
PDF
Implementing Drupalcamp sites
drupalcampest
 
PDF
Designing Drupalcamp sites
drupalcampest
 
PDF
Drupal vs. the Others
drupalcampest
 
PDF
Migrating University of Tartu websites to Drupal
drupalcampest
 
PDF
Drupalcamp Tallinn - Drupal 8
drupalcampest
 
PPT
Drupalcamp Estonia - High Performance Sites
drupalcampest
 
PDF
Drupalcamp Estonia - Drupal 7
drupalcampest
 
PDF
Drupalcamp Estonia - Introduction to Drupal
drupalcampest
 
PPT
Drupalcamp Estonia 2011 - Welcome
drupalcampest
 
Advanced theming
drupalcampest
 
Welcome to Drupalcamp Estonia 2012
drupalcampest
 
Implementing Drupalcamp sites
drupalcampest
 
Designing Drupalcamp sites
drupalcampest
 
Drupal vs. the Others
drupalcampest
 
Migrating University of Tartu websites to Drupal
drupalcampest
 
Drupalcamp Tallinn - Drupal 8
drupalcampest
 
Drupalcamp Estonia - High Performance Sites
drupalcampest
 
Drupalcamp Estonia - Drupal 7
drupalcampest
 
Drupalcamp Estonia - Introduction to Drupal
drupalcampest
 
Drupalcamp Estonia 2011 - Welcome
drupalcampest
 
Ad

Recently uploaded (20)

PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 

Developing realtime apps with Drupal and NodeJS

  • 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 [email protected]
  • 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); } } }