SlideShare a Scribd company logo
Implementing real time web
                          applications with Django
                                 Kristian Øllegaard




                                         1
onsdag den 6. juni 12
About me


                  •     Software Developer/System Administrator at Divio

                  •     Django since 0.96

                  •     Danish, lived in Zurich 1,5 year



                                                                                            @oellegaard
                                                                           github.com/KristianOellegaard
                                                           2
onsdag den 6. juni 12
Why real time?

                  •     Better user experience

                  •     More options in front end

                  •     Make the web feel like native apps

                  •     Showing live data.

                  •     Collaboration is much easier.

                                                                              @oellegaard
                                                             github.com/KristianOellegaard
                                                         3
onsdag den 6. juni 12
Finding the right tool
                  •     Criteria's

                        •   Use websockets, but have fallbacks

                        •   Good browser support (incl. old IE)

                        •   Should be usable from python

                        •   Does not require extensive changes in frontend

                        •   “As fast as it can be”
                                                                                              @oellegaard
                                                                             github.com/KristianOellegaard
                                                           4
onsdag den 6. juni 12
The tools you want


                        Node.js + Socket.io

                                                                @oellegaard
                                               github.com/KristianOellegaard
                                  5
onsdag den 6. juni 12
The tools you want


                                 Node.js + Socket.io
                        (well, we don’t want this, but socket.io needs it)




                                                                                                  @oellegaard
                                                                                 github.com/KristianOellegaard
                                                                             5
onsdag den 6. juni 12
The tools you want
                  •     Node.js

                        •   Built on Chrome's JavaScript runtime

                        •   Uses an event-driven, non-blocking I/O model

                  •     Socket.io

                        •   One interface for all transport methods (sockets, polling, etc.)

                        •   Compatible with almost everything
                                                                                                                @oellegaard
                                                                                               github.com/KristianOellegaard
                                                            6
onsdag den 6. juni 12
Why not implement it in Python?

                  •     Already active community

                  •     Can be used from python without too much trouble

                  •     Most people know very basic javascript

                  •     More importantly, frontend engineers, knows javascript and can
                        therefore contribute to the different browser-specific
                        implementations.

                                                                                                          @oellegaard
                                                                                         github.com/KristianOellegaard
                                                        7
onsdag den 6. juni 12
Using redis for cross-language
                                communication
                  •     Support for many datatypes

                  •     Can be used both as storage and as a queue

                  •     Implemented in many different languages

                  •     For the usage in this talk, any other queue could have been used as
                        well.

                                                                                                          @oellegaard
                                                                                         github.com/KristianOellegaard
                                                         8
onsdag den 6. juni 12
Basic concept
                  •     Something happens, the user
                                                                                  Redis
                        must be notified in real time               publish                publish




                        •
                                                                             subscribe

                            From e.g. django we insert the
                                                                                           E.g.
                            new value into the queue             Django         Node.js
                                                                                          Celery

                        •   Node.js listens on the queue                     subscribe



                            and emits any content directly                     Browser
                            to the browser via socket.io

                        •   This is btw. very fast!
                                                                                                                     @oellegaard
                                                                                                    github.com/KristianOellegaard
                                                             9
onsdag den 6. juni 12
Sample node.js app

                        var io = require('socket.io').listen(8001);
                        var redis = require('redis').createClient();

                        redis.psubscribe("socketio_*"); // Could be any pattern

                        io.sockets.on('connection', function (socket) {
                            redis.on('pmessage', function(pattern, channel, key){
                                socket.emit(channel, key);
                            });
                        });



                                                                                                     @oellegaard
                                                                                    github.com/KristianOellegaard
                                                          10
onsdag den 6. juni 12
Sample HTML/JS

                        <script src="http://localhost:8001/socket.io/socket.io.js"></script>
                        <script>
                          var socket = io.connect('http://localhost:8001/');
                          socket.on('socketio_news', function (data) {
                            console.log(data);
                          });
                        </script>




                                                                                                            @oellegaard
                                                                                           github.com/KristianOellegaard
                                                          11
onsdag den 6. juni 12
Sample usage from Python


                        import redis
                        import json
                        redis_subscribe = redis.StrictRedis()
                        redis_subscribe.publish("socketio_news", json.dumps({
                           'title': 'Djangocon 2012',
                        }))




                                                                                                 @oellegaard
                                                                                github.com/KristianOellegaard
                                                          12
onsdag den 6. juni 12
Short demo




                                                      @oellegaard
                                     github.com/KristianOellegaard
                            13
onsdag den 6. juni 12
Hosting socket.io

                  •     Nginx does not support websockets!

                  •     Needs its own app, if hosted on an application cloud (e.g. heroku)

                  •     Recommended to expose the node server directly

                        •   But hey, it’s node.js, it scales!


                                                                                                          @oellegaard
                                                                                         github.com/KristianOellegaard
                                                                14
onsdag den 6. juni 12
Can I use this today?


                  •     Yes

                  •     But, please don’t




                                                                             @oellegaard
                                                            github.com/KristianOellegaard
                                              15
onsdag den 6. juni 12
Client Authentication

                  •     Socket.io handles authentication from node -> client

                  •     Currently no authentication between django and node.

                  •     Could possibly be solved by storing your sessions in redis and
                        checking them on connection.


                                                                                                          @oellegaard
                                                                                         github.com/KristianOellegaard
                                                        16
onsdag den 6. juni 12
Notes


                  •     Concept should work with any language/framework

                        •   E.g. communicating between ruby and python




                                                                                           @oellegaard
                                                                          github.com/KristianOellegaard
                                                         17
onsdag den 6. juni 12
Questions?

                        http://kristian.io
                         @oellegaard


                                                              @oellegaard
                                             github.com/KristianOellegaard
                                18
onsdag den 6. juni 12
Ad

More Related Content

What's hot (20)

Dcjq node.js presentation
Dcjq node.js presentationDcjq node.js presentation
Dcjq node.js presentation
async_io
 
Owasp tools - OWASP Serbia
Owasp tools - OWASP SerbiaOwasp tools - OWASP Serbia
Owasp tools - OWASP Serbia
Nikola Milosevic
 
Vladimir Ulogov - Beyond the Loadable Module
Vladimir Ulogov - Beyond the Loadable ModuleVladimir Ulogov - Beyond the Loadable Module
Vladimir Ulogov - Beyond the Loadable Module
Zabbix
 
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAPVirtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
Michael Coates
 
OWASP 2012 AppSec Dublin ZAP Intro
OWASP 2012 AppSec Dublin ZAP IntroOWASP 2012 AppSec Dublin ZAP Intro
OWASP 2012 AppSec Dublin ZAP Intro
Simon Bennetts
 
OWASP 2013 AppSec EU Hamburg - ZAP Innovations
OWASP 2013 AppSec EU Hamburg - ZAP InnovationsOWASP 2013 AppSec EU Hamburg - ZAP Innovations
OWASP 2013 AppSec EU Hamburg - ZAP Innovations
Simon Bennetts
 
Csp and http headers
Csp and http headersCsp and http headers
Csp and http headers
ColdFusionConference
 
WebRTC & Asterisk 11
WebRTC & Asterisk 11WebRTC & Asterisk 11
WebRTC & Asterisk 11
Sanjay Willie
 
Dimitri Bellini and Pietro Antonacci - Manage Zabbix Proxies in Remote Networ...
Dimitri Bellini and Pietro Antonacci - Manage Zabbix Proxies in Remote Networ...Dimitri Bellini and Pietro Antonacci - Manage Zabbix Proxies in Remote Networ...
Dimitri Bellini and Pietro Antonacci - Manage Zabbix Proxies in Remote Networ...
Zabbix
 
Zabbix conference2015 daisukeikeda
Zabbix conference2015 daisukeikedaZabbix conference2015 daisukeikeda
Zabbix conference2015 daisukeikeda
Daisuke Ikeda
 
Zabbix - an important part of your IT infrastructure
Zabbix - an important part of your IT infrastructureZabbix - an important part of your IT infrastructure
Zabbix - an important part of your IT infrastructure
Arvids Godjuks
 
OWASP 2013 APPSEC USA Talk - OWASP ZAP
OWASP 2013 APPSEC USA Talk - OWASP ZAPOWASP 2013 APPSEC USA Talk - OWASP ZAP
OWASP 2013 APPSEC USA Talk - OWASP ZAP
Simon Bennetts
 
OWASP 2013 EU Tour Amsterdam ZAP Intro
OWASP 2013 EU Tour Amsterdam ZAP IntroOWASP 2013 EU Tour Amsterdam ZAP Intro
OWASP 2013 EU Tour Amsterdam ZAP Intro
Simon Bennetts
 
JavaOne 2014 Security Testing for Developers using OWASP ZAP
JavaOne 2014 Security Testing for Developers using OWASP ZAPJavaOne 2014 Security Testing for Developers using OWASP ZAP
JavaOne 2014 Security Testing for Developers using OWASP ZAP
Simon Bennetts
 
AWS Survival Guide
AWS Survival GuideAWS Survival Guide
AWS Survival Guide
Ken Johnson
 
OWASP 2014 AppSec EU ZAP Advanced Features
OWASP 2014 AppSec EU ZAP Advanced FeaturesOWASP 2014 AppSec EU ZAP Advanced Features
OWASP 2014 AppSec EU ZAP Advanced Features
Simon Bennetts
 
You'll Never Look at Developer Support the Same Way Again
You'll Never Look at Developer Support the Same Way AgainYou'll Never Look at Developer Support the Same Way Again
You'll Never Look at Developer Support the Same Way Again
Anne Gentle
 
OWASP 2013 APPSEC USA ZAP Hackathon
OWASP 2013 APPSEC USA ZAP HackathonOWASP 2013 APPSEC USA ZAP Hackathon
OWASP 2013 APPSEC USA ZAP Hackathon
Simon Bennetts
 
Florian Koch - Monitoring CoreOS with Zabbix
Florian Koch - Monitoring CoreOS with ZabbixFlorian Koch - Monitoring CoreOS with Zabbix
Florian Koch - Monitoring CoreOS with Zabbix
Zabbix
 
LasCon 2014 DevOoops
LasCon 2014 DevOoops LasCon 2014 DevOoops
LasCon 2014 DevOoops
Chris Gates
 
Dcjq node.js presentation
Dcjq node.js presentationDcjq node.js presentation
Dcjq node.js presentation
async_io
 
Owasp tools - OWASP Serbia
Owasp tools - OWASP SerbiaOwasp tools - OWASP Serbia
Owasp tools - OWASP Serbia
Nikola Milosevic
 
Vladimir Ulogov - Beyond the Loadable Module
Vladimir Ulogov - Beyond the Loadable ModuleVladimir Ulogov - Beyond the Loadable Module
Vladimir Ulogov - Beyond the Loadable Module
Zabbix
 
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAPVirtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
Virtual Security Lab Setup - OWASP Broken Web Apps, Webgoat, & ZAP
Michael Coates
 
OWASP 2012 AppSec Dublin ZAP Intro
OWASP 2012 AppSec Dublin ZAP IntroOWASP 2012 AppSec Dublin ZAP Intro
OWASP 2012 AppSec Dublin ZAP Intro
Simon Bennetts
 
OWASP 2013 AppSec EU Hamburg - ZAP Innovations
OWASP 2013 AppSec EU Hamburg - ZAP InnovationsOWASP 2013 AppSec EU Hamburg - ZAP Innovations
OWASP 2013 AppSec EU Hamburg - ZAP Innovations
Simon Bennetts
 
WebRTC & Asterisk 11
WebRTC & Asterisk 11WebRTC & Asterisk 11
WebRTC & Asterisk 11
Sanjay Willie
 
Dimitri Bellini and Pietro Antonacci - Manage Zabbix Proxies in Remote Networ...
Dimitri Bellini and Pietro Antonacci - Manage Zabbix Proxies in Remote Networ...Dimitri Bellini and Pietro Antonacci - Manage Zabbix Proxies in Remote Networ...
Dimitri Bellini and Pietro Antonacci - Manage Zabbix Proxies in Remote Networ...
Zabbix
 
Zabbix conference2015 daisukeikeda
Zabbix conference2015 daisukeikedaZabbix conference2015 daisukeikeda
Zabbix conference2015 daisukeikeda
Daisuke Ikeda
 
Zabbix - an important part of your IT infrastructure
Zabbix - an important part of your IT infrastructureZabbix - an important part of your IT infrastructure
Zabbix - an important part of your IT infrastructure
Arvids Godjuks
 
OWASP 2013 APPSEC USA Talk - OWASP ZAP
OWASP 2013 APPSEC USA Talk - OWASP ZAPOWASP 2013 APPSEC USA Talk - OWASP ZAP
OWASP 2013 APPSEC USA Talk - OWASP ZAP
Simon Bennetts
 
OWASP 2013 EU Tour Amsterdam ZAP Intro
OWASP 2013 EU Tour Amsterdam ZAP IntroOWASP 2013 EU Tour Amsterdam ZAP Intro
OWASP 2013 EU Tour Amsterdam ZAP Intro
Simon Bennetts
 
JavaOne 2014 Security Testing for Developers using OWASP ZAP
JavaOne 2014 Security Testing for Developers using OWASP ZAPJavaOne 2014 Security Testing for Developers using OWASP ZAP
JavaOne 2014 Security Testing for Developers using OWASP ZAP
Simon Bennetts
 
AWS Survival Guide
AWS Survival GuideAWS Survival Guide
AWS Survival Guide
Ken Johnson
 
OWASP 2014 AppSec EU ZAP Advanced Features
OWASP 2014 AppSec EU ZAP Advanced FeaturesOWASP 2014 AppSec EU ZAP Advanced Features
OWASP 2014 AppSec EU ZAP Advanced Features
Simon Bennetts
 
You'll Never Look at Developer Support the Same Way Again
You'll Never Look at Developer Support the Same Way AgainYou'll Never Look at Developer Support the Same Way Again
You'll Never Look at Developer Support the Same Way Again
Anne Gentle
 
OWASP 2013 APPSEC USA ZAP Hackathon
OWASP 2013 APPSEC USA ZAP HackathonOWASP 2013 APPSEC USA ZAP Hackathon
OWASP 2013 APPSEC USA ZAP Hackathon
Simon Bennetts
 
Florian Koch - Monitoring CoreOS with Zabbix
Florian Koch - Monitoring CoreOS with ZabbixFlorian Koch - Monitoring CoreOS with Zabbix
Florian Koch - Monitoring CoreOS with Zabbix
Zabbix
 
LasCon 2014 DevOoops
LasCon 2014 DevOoops LasCon 2014 DevOoops
LasCon 2014 DevOoops
Chris Gates
 

Similar to Implementing real time web applications with Django (20)

How we build project for Open Source
How we build project for Open SourceHow we build project for Open Source
How we build project for Open Source
Alexander Zayats
 
Mortar: Hadoop-as-a-Service + Open Source Framework | AWS re: Invent public …
Mortar: Hadoop-as-a-Service + Open Source Framework | AWS re: Invent public …Mortar: Hadoop-as-a-Service + Open Source Framework | AWS re: Invent public …
Mortar: Hadoop-as-a-Service + Open Source Framework | AWS re: Invent public …
mortardata
 
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012
kennethaliu
 
Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
elliando dias
 
Intro to Python for C# Developers
Intro to Python for C# DevelopersIntro to Python for C# Developers
Intro to Python for C# Developers
Sarah Dutkiewicz
 
13 practical tips for writing secure golang applications
13 practical tips for writing secure golang applications13 practical tips for writing secure golang applications
13 practical tips for writing secure golang applications
Karthik Gaekwad
 
Introducing Hydra – An Open Source Document Processing Framework
Introducing Hydra – An Open Source Document Processing FrameworkIntroducing Hydra – An Open Source Document Processing Framework
Introducing Hydra – An Open Source Document Processing Framework
lucenerevolution
 
Evolution of NuGet
Evolution of NuGetEvolution of NuGet
Evolution of NuGet
Jeff Handley
 
IoT is Something to Figure Out
IoT is Something to Figure OutIoT is Something to Figure Out
IoT is Something to Figure Out
Peter Hoddie
 
Open sourcery
Open sourceryOpen sourcery
Open sourcery
Alex Meade
 
Que nos espera a los ALM Dudes para el 2013?
Que nos espera a los ALM Dudes para el 2013?Que nos espera a los ALM Dudes para el 2013?
Que nos espera a los ALM Dudes para el 2013?
Bruno Capuano
 
Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...
SQALab
 
Gradle 2.Breaking stereotypes
Gradle 2.Breaking stereotypesGradle 2.Breaking stereotypes
Gradle 2.Breaking stereotypes
Strannik_2013
 
Why use Go for web development?
Why use Go for web development?Why use Go for web development?
Why use Go for web development?
Weng Wei
 
Rapid Application Development on Google App Engine for Java
Rapid Application Development on Google App Engine for JavaRapid Application Development on Google App Engine for Java
Rapid Application Development on Google App Engine for Java
Kunal Dabir
 
Foundation Comparison
Foundation ComparisonFoundation Comparison
Foundation Comparison
Jody Garnett
 
GoLang - Why It Matters
GoLang -  Why It MattersGoLang -  Why It Matters
GoLang - Why It Matters
rahul
 
Orthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable CodeOrthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable Code
rsebbe
 
javerosmx-2015-marzo-groovy-java8-comparison
javerosmx-2015-marzo-groovy-java8-comparisonjaverosmx-2015-marzo-groovy-java8-comparison
javerosmx-2015-marzo-groovy-java8-comparison
Domingo Suarez Torres
 
SF Gradle Meetup - Netflix OSS
SF Gradle Meetup - Netflix OSSSF Gradle Meetup - Netflix OSS
SF Gradle Meetup - Netflix OSS
Justin Ryan
 
How we build project for Open Source
How we build project for Open SourceHow we build project for Open Source
How we build project for Open Source
Alexander Zayats
 
Mortar: Hadoop-as-a-Service + Open Source Framework | AWS re: Invent public …
Mortar: Hadoop-as-a-Service + Open Source Framework | AWS re: Invent public …Mortar: Hadoop-as-a-Service + Open Source Framework | AWS re: Invent public …
Mortar: Hadoop-as-a-Service + Open Source Framework | AWS re: Invent public …
mortardata
 
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012
kennethaliu
 
Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
elliando dias
 
Intro to Python for C# Developers
Intro to Python for C# DevelopersIntro to Python for C# Developers
Intro to Python for C# Developers
Sarah Dutkiewicz
 
13 practical tips for writing secure golang applications
13 practical tips for writing secure golang applications13 practical tips for writing secure golang applications
13 practical tips for writing secure golang applications
Karthik Gaekwad
 
Introducing Hydra – An Open Source Document Processing Framework
Introducing Hydra – An Open Source Document Processing FrameworkIntroducing Hydra – An Open Source Document Processing Framework
Introducing Hydra – An Open Source Document Processing Framework
lucenerevolution
 
Evolution of NuGet
Evolution of NuGetEvolution of NuGet
Evolution of NuGet
Jeff Handley
 
IoT is Something to Figure Out
IoT is Something to Figure OutIoT is Something to Figure Out
IoT is Something to Figure Out
Peter Hoddie
 
Que nos espera a los ALM Dudes para el 2013?
Que nos espera a los ALM Dudes para el 2013?Que nos espera a los ALM Dudes para el 2013?
Que nos espera a los ALM Dudes para el 2013?
Bruno Capuano
 
Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...
SQALab
 
Gradle 2.Breaking stereotypes
Gradle 2.Breaking stereotypesGradle 2.Breaking stereotypes
Gradle 2.Breaking stereotypes
Strannik_2013
 
Why use Go for web development?
Why use Go for web development?Why use Go for web development?
Why use Go for web development?
Weng Wei
 
Rapid Application Development on Google App Engine for Java
Rapid Application Development on Google App Engine for JavaRapid Application Development on Google App Engine for Java
Rapid Application Development on Google App Engine for Java
Kunal Dabir
 
Foundation Comparison
Foundation ComparisonFoundation Comparison
Foundation Comparison
Jody Garnett
 
GoLang - Why It Matters
GoLang -  Why It MattersGoLang -  Why It Matters
GoLang - Why It Matters
rahul
 
Orthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable CodeOrthogonality: A Strategy for Reusable Code
Orthogonality: A Strategy for Reusable Code
rsebbe
 
javerosmx-2015-marzo-groovy-java8-comparison
javerosmx-2015-marzo-groovy-java8-comparisonjaverosmx-2015-marzo-groovy-java8-comparison
javerosmx-2015-marzo-groovy-java8-comparison
Domingo Suarez Torres
 
SF Gradle Meetup - Netflix OSS
SF Gradle Meetup - Netflix OSSSF Gradle Meetup - Netflix OSS
SF Gradle Meetup - Netflix OSS
Justin Ryan
 
Ad

Recently uploaded (20)

Social Media App Development Company-EmizenTech
Social Media App Development Company-EmizenTechSocial Media App Development Company-EmizenTech
Social Media App Development Company-EmizenTech
Steve Jonas
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Top 10 IT Help Desk Outsourcing Services
Top 10 IT Help Desk Outsourcing ServicesTop 10 IT Help Desk Outsourcing Services
Top 10 IT Help Desk Outsourcing Services
Infrassist Technologies Pvt. Ltd.
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Mastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdfMastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdf
Spiral Mantra
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Social Media App Development Company-EmizenTech
Social Media App Development Company-EmizenTechSocial Media App Development Company-EmizenTech
Social Media App Development Company-EmizenTech
Steve Jonas
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Mastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdfMastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdf
Spiral Mantra
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Ad

Implementing real time web applications with Django

  • 1. Implementing real time web applications with Django Kristian Øllegaard 1 onsdag den 6. juni 12
  • 2. About me • Software Developer/System Administrator at Divio • Django since 0.96 • Danish, lived in Zurich 1,5 year @oellegaard github.com/KristianOellegaard 2 onsdag den 6. juni 12
  • 3. Why real time? • Better user experience • More options in front end • Make the web feel like native apps • Showing live data. • Collaboration is much easier. @oellegaard github.com/KristianOellegaard 3 onsdag den 6. juni 12
  • 4. Finding the right tool • Criteria's • Use websockets, but have fallbacks • Good browser support (incl. old IE) • Should be usable from python • Does not require extensive changes in frontend • “As fast as it can be” @oellegaard github.com/KristianOellegaard 4 onsdag den 6. juni 12
  • 5. The tools you want Node.js + Socket.io @oellegaard github.com/KristianOellegaard 5 onsdag den 6. juni 12
  • 6. The tools you want Node.js + Socket.io (well, we don’t want this, but socket.io needs it) @oellegaard github.com/KristianOellegaard 5 onsdag den 6. juni 12
  • 7. The tools you want • Node.js • Built on Chrome's JavaScript runtime • Uses an event-driven, non-blocking I/O model • Socket.io • One interface for all transport methods (sockets, polling, etc.) • Compatible with almost everything @oellegaard github.com/KristianOellegaard 6 onsdag den 6. juni 12
  • 8. Why not implement it in Python? • Already active community • Can be used from python without too much trouble • Most people know very basic javascript • More importantly, frontend engineers, knows javascript and can therefore contribute to the different browser-specific implementations. @oellegaard github.com/KristianOellegaard 7 onsdag den 6. juni 12
  • 9. Using redis for cross-language communication • Support for many datatypes • Can be used both as storage and as a queue • Implemented in many different languages • For the usage in this talk, any other queue could have been used as well. @oellegaard github.com/KristianOellegaard 8 onsdag den 6. juni 12
  • 10. Basic concept • Something happens, the user Redis must be notified in real time publish publish • subscribe From e.g. django we insert the E.g. new value into the queue Django Node.js Celery • Node.js listens on the queue subscribe and emits any content directly Browser to the browser via socket.io • This is btw. very fast! @oellegaard github.com/KristianOellegaard 9 onsdag den 6. juni 12
  • 11. Sample node.js app var io = require('socket.io').listen(8001); var redis = require('redis').createClient(); redis.psubscribe("socketio_*"); // Could be any pattern io.sockets.on('connection', function (socket) {     redis.on('pmessage', function(pattern, channel, key){         socket.emit(channel, key);     }); }); @oellegaard github.com/KristianOellegaard 10 onsdag den 6. juni 12
  • 12. Sample HTML/JS <script src="http://localhost:8001/socket.io/socket.io.js"></script> <script>   var socket = io.connect('http://localhost:8001/');   socket.on('socketio_news', function (data) {     console.log(data);   }); </script> @oellegaard github.com/KristianOellegaard 11 onsdag den 6. juni 12
  • 13. Sample usage from Python import redis import json redis_subscribe = redis.StrictRedis() redis_subscribe.publish("socketio_news", json.dumps({    'title': 'Djangocon 2012', })) @oellegaard github.com/KristianOellegaard 12 onsdag den 6. juni 12
  • 14. Short demo @oellegaard github.com/KristianOellegaard 13 onsdag den 6. juni 12
  • 15. Hosting socket.io • Nginx does not support websockets! • Needs its own app, if hosted on an application cloud (e.g. heroku) • Recommended to expose the node server directly • But hey, it’s node.js, it scales! @oellegaard github.com/KristianOellegaard 14 onsdag den 6. juni 12
  • 16. Can I use this today? • Yes • But, please don’t @oellegaard github.com/KristianOellegaard 15 onsdag den 6. juni 12
  • 17. Client Authentication • Socket.io handles authentication from node -> client • Currently no authentication between django and node. • Could possibly be solved by storing your sessions in redis and checking them on connection. @oellegaard github.com/KristianOellegaard 16 onsdag den 6. juni 12
  • 18. Notes • Concept should work with any language/framework • E.g. communicating between ruby and python @oellegaard github.com/KristianOellegaard 17 onsdag den 6. juni 12
  • 19. Questions? http://kristian.io @oellegaard @oellegaard github.com/KristianOellegaard 18 onsdag den 6. juni 12