SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Building Real-Time Web
http://tinyurl.com/realtime2012

     http://   Timothy Fitz .com
                 CTO Canvas
What is “Realtime web”
What does “Realtime” look like?
What does “Realtime” look like?
What does “Realtime” look like?
“Push, not pull.”

REALTIME WEB
Talking to the browser
High concurrency
Scaling up

3 HARD PROBLEMS
Talking to the browser
•   Short Polling
•   Long Polling
•   WebSocket
•   Flash Socket
Short Polling
Long Polling
Flash Socket
WebSocket
High Concurrency
• Blocking I/O
  – Thread per process
  – Tops out at 200 to 1k connections
• Non-blocking I/O
  – One process, one thread
  – 10k to 100k connections
Django
Django
 Apache
There is no apache for realtime
Non-blocking I/O Servers
• Python
  – Twisted
  – Tornado
  – gevent
• Not python
  – Node.js
  – Erlang something
Twisted
• Pro
  – Can talk every protocol ever
  – Oldest and most widely used in production
• Con
  – Overkill for web-only tasks
  – Not simple
Tornado
• Pro
  – Simple
  – Does HTTP stuff simply
• Con
  – Might not interface with what you need
• Confusing
  – You can run Tornado (HTTP layer) on top of
    Twisted (networking layer)
gevent
• Pro
  – Coroutines are a better model than callbacks
  – As such, very easy to write complicated logic
• Con
  – Least well documented
  – Least consensus on best practices
  – New, uncertain about production readiness
Node.js
• Pro
  – Best documentation by far
  – Socket.IO abstracts away browser communication
• Con
  – Can’t share logic between Django app
  – New, but has fairly large install base
Erlang
• Pro
  – Hands down best for complex realtime tasks
  – Forces you to think about concurrency/scale
  – Abstracts away the network
  – Old and reliable
• Con
  – Forces you to think about concurrency/scale
  – Can’t share logic between Django app
  – High spin-up cost (functional, concurrency driven)
Just one
Frontend nodes x Backend nodes
More architecture decisions!

SCALING UP!
Just one
•   Everything in memory
•   Django nodes talk directly to box
•   Spare for availability
•   Failover = realtime data loss
    – Make realtime 100% redundant
Probably good enough!
– WARNING: NAPKIN MATH
– 10k daily visits * 10.0min avg visit
  = 70 average concurrent users
– One box can easily be built out to handle 3-5k
  = Roughly 450k-700k daily visits
Frontend nodes x Backend nodes
• Frontend handle users / connections
• Backend handles channels
More architecture decisions!
• In memory backend
  – Redis Pub/Sub
  – ZeroMQ
  – Roll your own
• Persisted to Disk:
  – ActiveMQ
  – RabbitMQ
  – Amazon SQS
Redis Pub/Sub
•   Simplest to setup
•   Simplest model
•   SUBSCRIBE channel_name
•   PUBLISH channel_name “Hello World!”
ZeroMQ
•   Publish/Subscribe semantics
•   Request/Response
•   Push/Pull (round robin)
•   Extremely fast
Roll your own
• Same language as your frontend
  – (Twisted/Node/Whatever)
• Only do this if you have per-channel business
  logic
  – You probably don’t.
• Erlang maps really really well to this domain.
Full Stack Services
• REST APIs to push to the browser
• http://pusher.com
• http://beaconpush.com
Canvas

Amazon ELB   Nginx + Twisted   Redis
Final Recommendations
•   Need python? Twisted
•   Don’t? Node.js/SocketIO
•   Need scale/reliability? Redis backend.
•   Complex? Going big? Erlang all the way.
Questions?
Further Reading
• IMVU IMQ talk http://www.slideshare.net/JonWatte/message-queuing-
  on-a-large-scale-imvus-stateful-realtime-message-queue
• Twilio talk on gevent + zeromq (given by Jeff Lindsay, highly recomended):
  http://www.twilio.com/conference/video/distributed-systems-with-
  gevent-and-zeromq
• Last.fm scaling Eralng/Mochiweb to 1 million concurrent connections on
  one machine: http://www.metabrew.com/article/a-million-user-comet-
  application-with-mochiweb-part-1
• The original Comet blog post: http://infrequently.org/2006/03/comet-low-
  latency-data-for-the-browser/
• Django + Socket.IO + gevent:
  http://codysoyland.com/2011/feb/6/evented-django-part-one-socketio-
  and-gevent/

Weitere ähnliche Inhalte

Was ist angesagt?

Rabbits, indians and... Symfony meets queueing brokers
Rabbits, indians and...  Symfony meets queueing brokersRabbits, indians and...  Symfony meets queueing brokers
Rabbits, indians and... Symfony meets queueing brokersGaetano Giunta
 
Ruby Concurrency Realities
Ruby Concurrency RealitiesRuby Concurrency Realities
Ruby Concurrency RealitiesMike Subelsky
 
Cluster Fudge: Recipes for WordPress in the Cloud (WordCamp Austin 2014 Speaker)
Cluster Fudge: Recipes for WordPress in the Cloud (WordCamp Austin 2014 Speaker)Cluster Fudge: Recipes for WordPress in the Cloud (WordCamp Austin 2014 Speaker)
Cluster Fudge: Recipes for WordPress in the Cloud (WordCamp Austin 2014 Speaker)Grant Norwood
 
Perconalive feb-2011-share
Perconalive feb-2011-sharePerconalive feb-2011-share
Perconalive feb-2011-sharemdcallag
 
Hybrid concurrency patterns
Hybrid concurrency patternsHybrid concurrency patterns
Hybrid concurrency patternsKyle Drake
 
STAQ Development Manual (Redacted)
STAQ Development Manual (Redacted)STAQ Development Manual (Redacted)
STAQ Development Manual (Redacted)Mike Subelsky
 
Get Off My Thread! - keep your UI super-responsive
Get Off My Thread! - keep your UI super-responsiveGet Off My Thread! - keep your UI super-responsive
Get Off My Thread! - keep your UI super-responsiveDroidConTLV
 
Making Symfony Services async with RabbitMq (and more Symfony)
Making Symfony Services async with RabbitMq (and more Symfony)Making Symfony Services async with RabbitMq (and more Symfony)
Making Symfony Services async with RabbitMq (and more Symfony)Gaetano Giunta
 
Big Data! Great! Now What? #SymfonyCon 2014
Big Data! Great! Now What? #SymfonyCon 2014Big Data! Great! Now What? #SymfonyCon 2014
Big Data! Great! Now What? #SymfonyCon 2014Ricard Clau
 
My month with Ruby
My month with RubyMy month with Ruby
My month with Rubyalextomovski
 
Ratpack for Real
Ratpack for RealRatpack for Real
Ratpack for RealTomAkehurst
 
Riak at Posterous
Riak at PosterousRiak at Posterous
Riak at Posterouscapotej
 
Dark Fairytales from a Phisherman
Dark Fairytales from a PhishermanDark Fairytales from a Phisherman
Dark Fairytales from a PhishermanMichele Orru
 
Why internal pen tests are still fun
Why internal pen tests are still funWhy internal pen tests are still fun
Why internal pen tests are still funpyschedelicsupernova
 
Some dope on Zope (Jan 2002, Bangalore LUG)
Some dope on Zope (Jan 2002, Bangalore LUG)Some dope on Zope (Jan 2002, Bangalore LUG)
Some dope on Zope (Jan 2002, Bangalore LUG)Kiran Jonnalagadda
 
What's new in Symfony3
What's new in Symfony3What's new in Symfony3
What's new in Symfony3Yuki MAEJIMA
 
Designing a Docker Stack for Symfony apps: lessons learned
Designing a Docker Stack  for Symfony apps: lessons learnedDesigning a Docker Stack  for Symfony apps: lessons learned
Designing a Docker Stack for Symfony apps: lessons learnedGaetano Giunta
 
Woo: Writing a fast web server
Woo: Writing a fast web serverWoo: Writing a fast web server
Woo: Writing a fast web serverfukamachi
 

Was ist angesagt? (20)

Rabbits, indians and... Symfony meets queueing brokers
Rabbits, indians and...  Symfony meets queueing brokersRabbits, indians and...  Symfony meets queueing brokers
Rabbits, indians and... Symfony meets queueing brokers
 
Ruby Concurrency Realities
Ruby Concurrency RealitiesRuby Concurrency Realities
Ruby Concurrency Realities
 
Cluster Fudge: Recipes for WordPress in the Cloud (WordCamp Austin 2014 Speaker)
Cluster Fudge: Recipes for WordPress in the Cloud (WordCamp Austin 2014 Speaker)Cluster Fudge: Recipes for WordPress in the Cloud (WordCamp Austin 2014 Speaker)
Cluster Fudge: Recipes for WordPress in the Cloud (WordCamp Austin 2014 Speaker)
 
Zero mq logs
Zero mq logsZero mq logs
Zero mq logs
 
Perconalive feb-2011-share
Perconalive feb-2011-sharePerconalive feb-2011-share
Perconalive feb-2011-share
 
Hybrid concurrency patterns
Hybrid concurrency patternsHybrid concurrency patterns
Hybrid concurrency patterns
 
STAQ Development Manual (Redacted)
STAQ Development Manual (Redacted)STAQ Development Manual (Redacted)
STAQ Development Manual (Redacted)
 
Get Off My Thread! - keep your UI super-responsive
Get Off My Thread! - keep your UI super-responsiveGet Off My Thread! - keep your UI super-responsive
Get Off My Thread! - keep your UI super-responsive
 
Making Symfony Services async with RabbitMq (and more Symfony)
Making Symfony Services async with RabbitMq (and more Symfony)Making Symfony Services async with RabbitMq (and more Symfony)
Making Symfony Services async with RabbitMq (and more Symfony)
 
Big Data! Great! Now What? #SymfonyCon 2014
Big Data! Great! Now What? #SymfonyCon 2014Big Data! Great! Now What? #SymfonyCon 2014
Big Data! Great! Now What? #SymfonyCon 2014
 
My month with Ruby
My month with RubyMy month with Ruby
My month with Ruby
 
Stackato v3
Stackato v3Stackato v3
Stackato v3
 
Ratpack for Real
Ratpack for RealRatpack for Real
Ratpack for Real
 
Riak at Posterous
Riak at PosterousRiak at Posterous
Riak at Posterous
 
Dark Fairytales from a Phisherman
Dark Fairytales from a PhishermanDark Fairytales from a Phisherman
Dark Fairytales from a Phisherman
 
Why internal pen tests are still fun
Why internal pen tests are still funWhy internal pen tests are still fun
Why internal pen tests are still fun
 
Some dope on Zope (Jan 2002, Bangalore LUG)
Some dope on Zope (Jan 2002, Bangalore LUG)Some dope on Zope (Jan 2002, Bangalore LUG)
Some dope on Zope (Jan 2002, Bangalore LUG)
 
What's new in Symfony3
What's new in Symfony3What's new in Symfony3
What's new in Symfony3
 
Designing a Docker Stack for Symfony apps: lessons learned
Designing a Docker Stack  for Symfony apps: lessons learnedDesigning a Docker Stack  for Symfony apps: lessons learned
Designing a Docker Stack for Symfony apps: lessons learned
 
Woo: Writing a fast web server
Woo: Writing a fast web serverWoo: Writing a fast web server
Woo: Writing a fast web server
 

Ähnlich wie Realtime web2012

Html5 web sockets - Brad Drysdale - London Web 2011-10-20
Html5 web sockets - Brad Drysdale - London Web 2011-10-20Html5 web sockets - Brad Drysdale - London Web 2011-10-20
Html5 web sockets - Brad Drysdale - London Web 2011-10-20Nathan O'Hanlon
 
Messaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkMessaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkTomas Doran
 
Scaling with Symfony - PHP UK
Scaling with Symfony - PHP UKScaling with Symfony - PHP UK
Scaling with Symfony - PHP UKRicard Clau
 
Life Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby AppsLife Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby AppsTristan Gomez
 
The State of WebSockets in Django
The State of WebSockets in DjangoThe State of WebSockets in Django
The State of WebSockets in DjangoRami Sayar
 
From a student to an apache committer practice of apache io tdb
From a student to an apache committer  practice of apache io tdbFrom a student to an apache committer  practice of apache io tdb
From a student to an apache committer practice of apache io tdbjixuan1989
 
High performance network programming on the jvm oscon 2012
High performance network programming on the jvm   oscon 2012 High performance network programming on the jvm   oscon 2012
High performance network programming on the jvm oscon 2012 Erik Onnen
 
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyFast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyKyle Drake
 
Modern software architectures - PHP UK Conference 2015
Modern software architectures - PHP UK Conference 2015Modern software architectures - PHP UK Conference 2015
Modern software architectures - PHP UK Conference 2015Ricard Clau
 
EKON27-FrameworksTuning.pdf
EKON27-FrameworksTuning.pdfEKON27-FrameworksTuning.pdf
EKON27-FrameworksTuning.pdfArnaud Bouchez
 
Lares from LOW to PWNED
Lares from LOW to PWNEDLares from LOW to PWNED
Lares from LOW to PWNEDChris Gates
 
Three years of OFELIA - taking stock
Three years of OFELIA - taking stockThree years of OFELIA - taking stock
Three years of OFELIA - taking stockFIBRE Testbed
 
John adams talk cloudy
John adams   talk cloudyJohn adams   talk cloudy
John adams talk cloudyJohn Adams
 
Vert.x introduction
Vert.x introductionVert.x introduction
Vert.x introductionGR8Conf
 
Cloud Connected Devices on a Global Scale (CPN303) | AWS re:Invent 2013
Cloud Connected Devices on a Global Scale (CPN303) | AWS re:Invent 2013Cloud Connected Devices on a Global Scale (CPN303) | AWS re:Invent 2013
Cloud Connected Devices on a Global Scale (CPN303) | AWS re:Invent 2013Amazon Web Services
 

Ähnlich wie Realtime web2012 (20)

Html5 web sockets - Brad Drysdale - London Web 2011-10-20
Html5 web sockets - Brad Drysdale - London Web 2011-10-20Html5 web sockets - Brad Drysdale - London Web 2011-10-20
Html5 web sockets - Brad Drysdale - London Web 2011-10-20
 
Messaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkMessaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new framework
 
Scaling with Symfony - PHP UK
Scaling with Symfony - PHP UKScaling with Symfony - PHP UK
Scaling with Symfony - PHP UK
 
Life Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby AppsLife Beyond Rails: Creating Cross Platform Ruby Apps
Life Beyond Rails: Creating Cross Platform Ruby Apps
 
The State of WebSockets in Django
The State of WebSockets in DjangoThe State of WebSockets in Django
The State of WebSockets in Django
 
Java
JavaJava
Java
 
From a student to an apache committer practice of apache io tdb
From a student to an apache committer  practice of apache io tdbFrom a student to an apache committer  practice of apache io tdb
From a student to an apache committer practice of apache io tdb
 
High performance network programming on the jvm oscon 2012
High performance network programming on the jvm   oscon 2012 High performance network programming on the jvm   oscon 2012
High performance network programming on the jvm oscon 2012
 
Distributed "Web Scale" Systems
Distributed "Web Scale" SystemsDistributed "Web Scale" Systems
Distributed "Web Scale" Systems
 
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::SynchronyFast, concurrent ruby web applications with EventMachine and EM::Synchrony
Fast, concurrent ruby web applications with EventMachine and EM::Synchrony
 
NullMQ @ PDX
NullMQ @ PDXNullMQ @ PDX
NullMQ @ PDX
 
Modern software architectures - PHP UK Conference 2015
Modern software architectures - PHP UK Conference 2015Modern software architectures - PHP UK Conference 2015
Modern software architectures - PHP UK Conference 2015
 
EKON27-FrameworksTuning.pdf
EKON27-FrameworksTuning.pdfEKON27-FrameworksTuning.pdf
EKON27-FrameworksTuning.pdf
 
Be faster then rabbits
Be faster then rabbitsBe faster then rabbits
Be faster then rabbits
 
Lares from LOW to PWNED
Lares from LOW to PWNEDLares from LOW to PWNED
Lares from LOW to PWNED
 
SPDY
SPDYSPDY
SPDY
 
Three years of OFELIA - taking stock
Three years of OFELIA - taking stockThree years of OFELIA - taking stock
Three years of OFELIA - taking stock
 
John adams talk cloudy
John adams   talk cloudyJohn adams   talk cloudy
John adams talk cloudy
 
Vert.x introduction
Vert.x introductionVert.x introduction
Vert.x introduction
 
Cloud Connected Devices on a Global Scale (CPN303) | AWS re:Invent 2013
Cloud Connected Devices on a Global Scale (CPN303) | AWS re:Invent 2013Cloud Connected Devices on a Global Scale (CPN303) | AWS re:Invent 2013
Cloud Connected Devices on a Global Scale (CPN303) | AWS re:Invent 2013
 

Mehr von Timothy Fitz

Good hypothesis testing is surprising!
Good hypothesis testing is surprising!Good hypothesis testing is surprising!
Good hypothesis testing is surprising!Timothy Fitz
 
Continuous Deployment: Beyond Continuous Delivery
Continuous Deployment: Beyond Continuous DeliveryContinuous Deployment: Beyond Continuous Delivery
Continuous Deployment: Beyond Continuous DeliveryTimothy Fitz
 
Gdc 2010 architecture final slideshare edition
Gdc 2010 architecture final slideshare editionGdc 2010 architecture final slideshare edition
Gdc 2010 architecture final slideshare editionTimothy Fitz
 
Scaling Up Continuous Deployment
Scaling Up Continuous DeploymentScaling Up Continuous Deployment
Scaling Up Continuous DeploymentTimothy Fitz
 
The Hard Problems of Continuous Deployment
The Hard Problems of Continuous DeploymentThe Hard Problems of Continuous Deployment
The Hard Problems of Continuous DeploymentTimothy Fitz
 
Continuous Deployment
Continuous DeploymentContinuous Deployment
Continuous DeploymentTimothy Fitz
 
Continuous Deployment
Continuous DeploymentContinuous Deployment
Continuous DeploymentTimothy Fitz
 
Continuous Deployment
Continuous DeploymentContinuous Deployment
Continuous DeploymentTimothy Fitz
 
Just In Time Scalability Agile Methods To Support Massive Growth Presentation
Just In Time Scalability  Agile Methods To Support Massive Growth PresentationJust In Time Scalability  Agile Methods To Support Massive Growth Presentation
Just In Time Scalability Agile Methods To Support Massive Growth PresentationTimothy Fitz
 

Mehr von Timothy Fitz (12)

Good hypothesis testing is surprising!
Good hypothesis testing is surprising!Good hypothesis testing is surprising!
Good hypothesis testing is surprising!
 
Continuous Deployment: Beyond Continuous Delivery
Continuous Deployment: Beyond Continuous DeliveryContinuous Deployment: Beyond Continuous Delivery
Continuous Deployment: Beyond Continuous Delivery
 
Gdc 2010 architecture final slideshare edition
Gdc 2010 architecture final slideshare editionGdc 2010 architecture final slideshare edition
Gdc 2010 architecture final slideshare edition
 
Scaling Up Continuous Deployment
Scaling Up Continuous DeploymentScaling Up Continuous Deployment
Scaling Up Continuous Deployment
 
The Hard Problems of Continuous Deployment
The Hard Problems of Continuous DeploymentThe Hard Problems of Continuous Deployment
The Hard Problems of Continuous Deployment
 
Continuous Deployment
Continuous DeploymentContinuous Deployment
Continuous Deployment
 
Continuous Deployment
Continuous DeploymentContinuous Deployment
Continuous Deployment
 
Shdh
ShdhShdh
Shdh
 
Socket.io
Socket.ioSocket.io
Socket.io
 
Shdh
ShdhShdh
Shdh
 
Continuous Deployment
Continuous DeploymentContinuous Deployment
Continuous Deployment
 
Just In Time Scalability Agile Methods To Support Massive Growth Presentation
Just In Time Scalability  Agile Methods To Support Massive Growth PresentationJust In Time Scalability  Agile Methods To Support Massive Growth Presentation
Just In Time Scalability Agile Methods To Support Massive Growth Presentation
 

Kürzlich hochgeladen

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 

Kürzlich hochgeladen (20)

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 

Realtime web2012

  • 1. Building Real-Time Web http://tinyurl.com/realtime2012 http:// Timothy Fitz .com CTO Canvas
  • 7. Talking to the browser High concurrency Scaling up 3 HARD PROBLEMS
  • 8. Talking to the browser • Short Polling • Long Polling • WebSocket • Flash Socket
  • 13. High Concurrency • Blocking I/O – Thread per process – Tops out at 200 to 1k connections • Non-blocking I/O – One process, one thread – 10k to 100k connections
  • 16. There is no apache for realtime
  • 17. Non-blocking I/O Servers • Python – Twisted – Tornado – gevent • Not python – Node.js – Erlang something
  • 18. Twisted • Pro – Can talk every protocol ever – Oldest and most widely used in production • Con – Overkill for web-only tasks – Not simple
  • 19. Tornado • Pro – Simple – Does HTTP stuff simply • Con – Might not interface with what you need • Confusing – You can run Tornado (HTTP layer) on top of Twisted (networking layer)
  • 20. gevent • Pro – Coroutines are a better model than callbacks – As such, very easy to write complicated logic • Con – Least well documented – Least consensus on best practices – New, uncertain about production readiness
  • 21. Node.js • Pro – Best documentation by far – Socket.IO abstracts away browser communication • Con – Can’t share logic between Django app – New, but has fairly large install base
  • 22. Erlang • Pro – Hands down best for complex realtime tasks – Forces you to think about concurrency/scale – Abstracts away the network – Old and reliable • Con – Forces you to think about concurrency/scale – Can’t share logic between Django app – High spin-up cost (functional, concurrency driven)
  • 23. Just one Frontend nodes x Backend nodes More architecture decisions! SCALING UP!
  • 24. Just one • Everything in memory • Django nodes talk directly to box • Spare for availability • Failover = realtime data loss – Make realtime 100% redundant
  • 25. Probably good enough! – WARNING: NAPKIN MATH – 10k daily visits * 10.0min avg visit = 70 average concurrent users – One box can easily be built out to handle 3-5k = Roughly 450k-700k daily visits
  • 26. Frontend nodes x Backend nodes • Frontend handle users / connections • Backend handles channels
  • 27. More architecture decisions! • In memory backend – Redis Pub/Sub – ZeroMQ – Roll your own • Persisted to Disk: – ActiveMQ – RabbitMQ – Amazon SQS
  • 28. Redis Pub/Sub • Simplest to setup • Simplest model • SUBSCRIBE channel_name • PUBLISH channel_name “Hello World!”
  • 29. ZeroMQ • Publish/Subscribe semantics • Request/Response • Push/Pull (round robin) • Extremely fast
  • 30. Roll your own • Same language as your frontend – (Twisted/Node/Whatever) • Only do this if you have per-channel business logic – You probably don’t. • Erlang maps really really well to this domain.
  • 31. Full Stack Services • REST APIs to push to the browser • http://pusher.com • http://beaconpush.com
  • 32. Canvas Amazon ELB Nginx + Twisted Redis
  • 33. Final Recommendations • Need python? Twisted • Don’t? Node.js/SocketIO • Need scale/reliability? Redis backend. • Complex? Going big? Erlang all the way.
  • 35. Further Reading • IMVU IMQ talk http://www.slideshare.net/JonWatte/message-queuing- on-a-large-scale-imvus-stateful-realtime-message-queue • Twilio talk on gevent + zeromq (given by Jeff Lindsay, highly recomended): http://www.twilio.com/conference/video/distributed-systems-with- gevent-and-zeromq • Last.fm scaling Eralng/Mochiweb to 1 million concurrent connections on one machine: http://www.metabrew.com/article/a-million-user-comet- application-with-mochiweb-part-1 • The original Comet blog post: http://infrequently.org/2006/03/comet-low- latency-data-for-the-browser/ • Django + Socket.IO + gevent: http://codysoyland.com/2011/feb/6/evented-django-part-one-socketio- and-gevent/

Hinweis der Redaktion

  1. Also known as Comet (in response to AJAX)And before that, under the umbrella of “DHTML” (throwback to the late 90s!)
  2. Latency often doesn’t matter at all (3-5s wouldn’t be noticed, for popular hashtags 1 minute wouldn’t make a difference)
  3. Chat (which is pubsub on steroids)Presence (the fact that you’re connected is important)Latency matters some, but you wouldn’t notice 1s of lag.
  4. Gaming, networked simulated physics / simulated spaces. Latency is critical in both directions (~200ms matters)
  5. Also a dozen other methods, and aggregate methods that have built-in fall back semantics.
  6. Supported absolutely everywhereIncredibly efficientIncredibly easy to implement, hard to get wrongRight for infrequent realtime, or tied to existing expensive operation (most common example: short poll Paypal/payment gateway for success confirmation)
  7. Works everywhere (desktop and mobile)Supports most use cases (twitter, etc)
  8. Requires flash support (user has it, no flashblock, desktop only for the most part)Bidirectional and binary.Bidirectional really only matters for realtime interactive apps (games, virtual spaces, motion is one of the few places where 200ms latency matters)Flash is dying, but if your app already requires (or if your UI is already in flash, hello vidya game) then this might be the best solution.
  9. Works on Chrome, FF, Safari, iOS mobile, IE10 previews. Coming to Android Mobile soon.Bidirectional, but UTF-8 (probably doesn’t matter)Very new (RFC hit “Proposed Standard” in Dec 2011, which means the spec is solidified. “Internet Standard” is then next step, and reserved for two independent interoperable implementations, very close)Great but you’ll probably have to support fallback for a while 
  10. Super simplifying, lots of options exist including hybrids.Often run one non-blocking process per core (if you have to scale to multiple machines, using the same strategy for multiple processes is trivial)
  11. Okay this is kind of a lie, there are hacky ways but you lose most of what makes Django, Django: sessions, users, auth, ORM, and most 3rd party libraries
  12. There is no consensus. There are some good python options. There are a LOT of options I’m not even mentioning, almost every language has two or three non-blocking I/O webservers. Python might be important, especially if you have logic you want to reuse between your Django application and your non-blocking I/O app
  13. Can have two for redundancy