SlideShare a Scribd company logo
Backend & Frontend architecture
scalability & websockets
09-03-2016
Searchlite HQ
Anne Jan Brouwer
NoProtocol
About me
●
Anne Jan Brouwer
●
Professional developer since 2001
– C++
– Sysadminning
– PHP 2004
– NodeJS 2010
●
NoProtocol
– Realization
● Full stack implementation
Backend & Frontend architecture
scalability & websockets
●
About this talk:
– Language agnostic
● Mostly . .
– Architecture focussed
●
For anyone involved with web
– Sites
– Apps
● Fun
Kinds of applications
●
Content driven websites
●
Realtime data driven
– Physical data
– News
– Chat
●
??
●
Most common are multi-user CMS-like systems
– Right??
Backend & Frontend
●
Back in the olden days
– Didn't used to be like that
– Everything was done serverside
– Frontend was just styling
●
These days
– Code running serverside gets smaller
– Code running clientside gets larger
– Everything is (ran through) an API
Scalability
●
What
– More iron
– Distribution (CDNs etc)
●
How?
– Handling state?
– Getting rid of state?
– Different models?
●
Performance
Performance
Scalability
High availability
●
What are we talking about?
– Failovers?
– Handovers?
●
How do we achieve that?
– Handling application state?
– Getting rid of state?
– Different models / patterns / paradigms?
Websockets
●
Back in the olden days
– Polling
– Long Polling
●
Standard since 2011
– RFC6455
● Implementations available for most
programming languages
– Yes, even for PHP
Websockets
Websockets
●
They're nice for things like chat and games
●
But what about serious applications?
– Etherpad
– Ethercalc
– Etherdraw
●
Google docs
Websockets
●
But how does that apply to my CMS
●
What about application state?
●
Websockets have inherent state
●
Coming from classic website model?
– You probably need a different pattern / paradigm
pub/sub
●
Publish–subscribe pattern
●
Does literally what it says
●
First described in 1987
– In a talk at the SOSP conference
– As part of “news” subsystem of Isis toolkit
●
Not one standard but a pattern
●
WAMP
– Web Application Messaging Protocol (draft)
pub/sub
pub/sub
●
Publish
●
.. to a channel
– sometimes called a topic
●
Most implementations return number of subscribers
pub/sub
●
Subscribe to (one or more) channels
●
Subscribe to (one or more) patterns
– For example: news.*
●
Some servers / libraries
– Faye
– RabbitMQ
– Redis
– many more . .
Tying it all together
Tying it all together
●
What is it good for?
– Absolutely everything
● Subscribing to channels for pages and widgets
– Your “user” list view
– Any widget really
● Subscribing to alerts
● Collaborating
Tying it all together
●
Take a look at your “CMS”
●
Any table could be an “auto-updating” list
– Get initial data old-school page-load or via API
● Paginated
– Subscribe to data channel
● Go fancy; subscribe to channel + pattern
● Any form could be a “multi-player” form
– Implement field locking for bonus points
Tying it all together
●
You (client) send event to API (sync)
●
API (server) broadcasts to channel (async)
●
“Other” clients pick up on change
– Only when applicable
Implementation
On the backend
●
Redis (or other messaging bus)
●
NodeJS (or other socket server)
●
Some other backend language (optionally)
– Legacy reasons
●
Your favorite database
– For long-term storing/logging
Interesting Redis perks
●
Key-value store
– With TTL
● Distributed API rate-limiting
●
Partitioning
●
Distributed locks
●
Cache store
– Auto-eviction
● Lua scripting
On the frontend
●
RxJS
●
Angular
– Listeners, data objects
– With RxJS
●
React
– Something something Flux
● Not a lib but a pattern
● Redux
●
PubSubJS
– Nice and small
But will it scale?
But will it scale?
●
Subscribers are “cheap”
●
Load balancing is simplified
– Easiest round-robin setup mostly suffices
● Requests are lighter (less data)
– Only wanted (subscribed) data gets transmitted
● Easy to add more (micro) servers
● Works very well with automatic scaling (AWS)
How gracefully will it fail?
●
Reload drops current subscriptions
●
You start again
– Get initial data
– Subscribe to channel
● Handling a closed socket
– Opportunity for an “event”
● Fail-fast
What about security?
What about security?
●
WSS
– Mandatory when serving over https
●
JWT
– Just as safe as session cookies
● Subscriptions dropped when connection closes
– Safer than token based systems
●
Have a TTL
What about security?
●
Unit-testable
– Via mockups
– Echo service
●
Graceful degradation
– Since (in most cases) it's just an addition
●
Ledger
– Accountability
– Why not a blockchain?
Retrofitting
Retrofitting
●
Fitting pub/sub into existing systems
●
A-sync all the things?
●
Starting small
– Polling widget was hated during writing
– Usually a retrofit in itself
●
Things fall into place
– On initial load get data directly (old-school) or via API
– Subscribe and receive changes
Wrapping up
Wrapping up
Use these modern web paradigms
Over 95% browser support*
* Probably even better depending on your target audience
Questions?
AnneJan.com
@annejanbrouwer
github.com/annejan
NoProtocol.com

More Related Content

What's hot (20)

PDF
Modern Web Applications
Ömer Göktuğ Poyraz
 
PDF
Single Page Applications
Massimo Iacolare
 
PPT
Web development | Derin Dolen
Derin Dolen
 
PPTX
Top web development tools
BusinessDevelopment35
 
PPT
Advanced Web Development
Robert J. Stein
 
PDF
Introduction to web development
Mohammed Safwat
 
PDF
Universal apps lightning talk
Elyse Kolker Gordon
 
PDF
Rise and Fall of the Frontend Developer
Rafael Casuso Romate
 
PPTX
Introduction to Web Development
Parvez Mahbub
 
PPTX
Progressive Web Apps - Overview & Getting Started
Gaurav Behere
 
PDF
Wordpress development 101
Commit Software Sh.p.k.
 
PDF
Dynamic websites lec5
Belal Arfa
 
PPTX
Single Page Application Development with backbone.js and Simple.Web
Chris Canal
 
PPTX
Single page applications
Prafful Garg
 
PDF
Fundamentals of Web Development For Non-Developers
Lemi Orhan Ergin
 
PPTX
Front-End Development
Hein Htet Aung
 
PPTX
Creating SmartPhone Apps Using WordPress
codebangla
 
PDF
Meet.js Summit 2019 - PWA in practice
Łukasz Romanowicz
 
PPTX
Headless Architecture
Amandeep Singh
 
PPT
Web Issues
tterrill
 
Modern Web Applications
Ömer Göktuğ Poyraz
 
Single Page Applications
Massimo Iacolare
 
Web development | Derin Dolen
Derin Dolen
 
Top web development tools
BusinessDevelopment35
 
Advanced Web Development
Robert J. Stein
 
Introduction to web development
Mohammed Safwat
 
Universal apps lightning talk
Elyse Kolker Gordon
 
Rise and Fall of the Frontend Developer
Rafael Casuso Romate
 
Introduction to Web Development
Parvez Mahbub
 
Progressive Web Apps - Overview & Getting Started
Gaurav Behere
 
Wordpress development 101
Commit Software Sh.p.k.
 
Dynamic websites lec5
Belal Arfa
 
Single Page Application Development with backbone.js and Simple.Web
Chris Canal
 
Single page applications
Prafful Garg
 
Fundamentals of Web Development For Non-Developers
Lemi Orhan Ergin
 
Front-End Development
Hein Htet Aung
 
Creating SmartPhone Apps Using WordPress
codebangla
 
Meet.js Summit 2019 - PWA in practice
Łukasz Romanowicz
 
Headless Architecture
Amandeep Singh
 
Web Issues
tterrill
 

Viewers also liked (10)

PPTX
An Architecture of the Slot Games Platform
Krzysztof Opałka
 
PDF
Lean Startup: Kevin Huang at SMECC - 20130723
smecchk
 
PDF
An Introduction to Game Programming with Flash: An Introduction to Flash and ...
Krzysztof Opałka
 
PPTX
Designgjeld yggdrasil 2015
Daniel Sundbäck
 
PPTX
Opplevd hastighet #ygg15
Fredrik Johnsson
 
PPTX
Frontend Architecture and Data Visualization
Altocloud
 
PDF
Facebook chat architecture
Udaya Kiran
 
PPTX
Social Media Marketing Plan Proposal for the movie WHIPLASH
Mariel Espejo
 
PDF
Architecting large Node.js applications
Sergi Mansilla
 
PPTX
Film.Marketing.Plan
bill balina
 
An Architecture of the Slot Games Platform
Krzysztof Opałka
 
Lean Startup: Kevin Huang at SMECC - 20130723
smecchk
 
An Introduction to Game Programming with Flash: An Introduction to Flash and ...
Krzysztof Opałka
 
Designgjeld yggdrasil 2015
Daniel Sundbäck
 
Opplevd hastighet #ygg15
Fredrik Johnsson
 
Frontend Architecture and Data Visualization
Altocloud
 
Facebook chat architecture
Udaya Kiran
 
Social Media Marketing Plan Proposal for the movie WHIPLASH
Mariel Espejo
 
Architecting large Node.js applications
Sergi Mansilla
 
Film.Marketing.Plan
bill balina
 
Ad

Similar to Backend & Frontend architecture scalability & websockets (20)

PDF
Real time web apps
Sepehr Rasouli
 
PDF
Adding Real-time Features to PHP Applications
Ronny López
 
PDF
Building and Scaling a WebSockets Pubsub System
Kapil Reddy
 
PDF
Adding Realtime to your Projects
Ignacio Martín
 
PDF
Real Time Realitites
markisuak
 
PDF
Ducksboard - A real-time data oriented webservice architecture
Ducksboard
 
PDF
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
sametmax
 
PDF
09-01-services-slides.pdf for educations
katariraju71
 
PDF
APIs for modern web apps
Chris Mills
 
PDF
Scalable and Available, Patterns for Success
Derek Collison
 
PPTX
Autobahn primer
Robbie Byrd
 
PDF
API Design and WebSocket
Frank Greco
 
PPT
Large-scale projects development (scaling LAMP)
Alexey Rybak
 
PDF
What is Reactive programming?
Kevin Webber
 
PDF
Building real time applications with Symfony2
Antonio Peric-Mazar
 
PPTX
How to develop innovative, scalable systems
Max Kossatz
 
PDF
Client-side Development 2016
Huge
 
PPT
Camelone-2012 HTML5 WebSocket ActiveMQ/Camel
Charles Moulliard
 
PPTX
APIs, STOP Polling, lets go Streaming
Phil Wilkins
 
PDF
Queueing at the Checkout
William Tracz
 
Real time web apps
Sepehr Rasouli
 
Adding Real-time Features to PHP Applications
Ronny López
 
Building and Scaling a WebSockets Pubsub System
Kapil Reddy
 
Adding Realtime to your Projects
Ignacio Martín
 
Real Time Realitites
markisuak
 
Ducksboard - A real-time data oriented webservice architecture
Ducksboard
 
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
sametmax
 
09-01-services-slides.pdf for educations
katariraju71
 
APIs for modern web apps
Chris Mills
 
Scalable and Available, Patterns for Success
Derek Collison
 
Autobahn primer
Robbie Byrd
 
API Design and WebSocket
Frank Greco
 
Large-scale projects development (scaling LAMP)
Alexey Rybak
 
What is Reactive programming?
Kevin Webber
 
Building real time applications with Symfony2
Antonio Peric-Mazar
 
How to develop innovative, scalable systems
Max Kossatz
 
Client-side Development 2016
Huge
 
Camelone-2012 HTML5 WebSocket ActiveMQ/Camel
Charles Moulliard
 
APIs, STOP Polling, lets go Streaming
Phil Wilkins
 
Queueing at the Checkout
William Tracz
 
Ad

Recently uploaded (20)

PDF
Beginning-Laravel-Build-Websites-with-Laravel-5.8-by-Sanjib-Sinha-z-lib.org.pdf
TagumLibuganonRiverB
 
PDF
AI security AI security AI security AI security
elite44
 
PDF
ContextForge MCP Gateway - the missing proxy for AI Agents and Tools
Mihai Criveti
 
PPTX
Metaphysics_Presentation_With_Visuals.pptx
erikjohnsales1
 
PPTX
Introduction-to-the-AWS-Solution-Architect.pptx
Prince391830
 
PPTX
美国电子毕业证帕克大学电子版成绩单UMCP学费发票办理学历认证
Taqyea
 
PDF
web application development company in bangalore.pdf
https://dkpractice.co.in/seo.html tech
 
PPTX
CHAPTER 1 - PART 3 FOR GRADE 11 STUDENTS
FSBTLEDNathanVince
 
PDF
Empowering Local Language Email with IDN & EAI – Powered by XgenPlus
XgenPlus Technologies
 
PDF
google promotion services in Delhi, India
Digital Web Future
 
PPTX
Lesson 1.1 Career-Opportunities-in-Ict.pptx
lizelgumadlas1
 
PDF
FutureCon Seattle 2025 Presentation Slides - You Had One Job
Suzanne Aldrich
 
PDF
Strategic Plan New and Completed Templeted
alvi932317
 
PPTX
PHIPA-Compliant Web Hosting in Toronto: What Healthcare Providers Must Know
steve198109
 
PPTX
Ransomware attack and its effects on cyber crimes
ShilpaShreeD
 
PPTX
My Mother At 66! (2).pptx00000000000000000000000000000
vedapattisiddharth
 
PDF
BRKSP-2551 - Introduction to Segment Routing.pdf
fcesargonca
 
PDF
Materi tentang From Digital Economy to Fintech.pdf
Abdul Hakim
 
PPTX
Meloniusk_Communication_Template_best.pptx
howesix147
 
PPTX
Class_4_Limbgvchgchgchgchgchgcjhgchgcnked_Lists.pptx
test123n
 
Beginning-Laravel-Build-Websites-with-Laravel-5.8-by-Sanjib-Sinha-z-lib.org.pdf
TagumLibuganonRiverB
 
AI security AI security AI security AI security
elite44
 
ContextForge MCP Gateway - the missing proxy for AI Agents and Tools
Mihai Criveti
 
Metaphysics_Presentation_With_Visuals.pptx
erikjohnsales1
 
Introduction-to-the-AWS-Solution-Architect.pptx
Prince391830
 
美国电子毕业证帕克大学电子版成绩单UMCP学费发票办理学历认证
Taqyea
 
web application development company in bangalore.pdf
https://dkpractice.co.in/seo.html tech
 
CHAPTER 1 - PART 3 FOR GRADE 11 STUDENTS
FSBTLEDNathanVince
 
Empowering Local Language Email with IDN & EAI – Powered by XgenPlus
XgenPlus Technologies
 
google promotion services in Delhi, India
Digital Web Future
 
Lesson 1.1 Career-Opportunities-in-Ict.pptx
lizelgumadlas1
 
FutureCon Seattle 2025 Presentation Slides - You Had One Job
Suzanne Aldrich
 
Strategic Plan New and Completed Templeted
alvi932317
 
PHIPA-Compliant Web Hosting in Toronto: What Healthcare Providers Must Know
steve198109
 
Ransomware attack and its effects on cyber crimes
ShilpaShreeD
 
My Mother At 66! (2).pptx00000000000000000000000000000
vedapattisiddharth
 
BRKSP-2551 - Introduction to Segment Routing.pdf
fcesargonca
 
Materi tentang From Digital Economy to Fintech.pdf
Abdul Hakim
 
Meloniusk_Communication_Template_best.pptx
howesix147
 
Class_4_Limbgvchgchgchgchgchgcjhgchgcnked_Lists.pptx
test123n
 

Backend & Frontend architecture scalability & websockets

  • 1. Backend & Frontend architecture scalability & websockets 09-03-2016 Searchlite HQ Anne Jan Brouwer NoProtocol
  • 2. About me ● Anne Jan Brouwer ● Professional developer since 2001 – C++ – Sysadminning – PHP 2004 – NodeJS 2010 ● NoProtocol – Realization ● Full stack implementation
  • 3. Backend & Frontend architecture scalability & websockets ● About this talk: – Language agnostic ● Mostly . . – Architecture focussed ● For anyone involved with web – Sites – Apps ● Fun
  • 4. Kinds of applications ● Content driven websites ● Realtime data driven – Physical data – News – Chat ● ?? ● Most common are multi-user CMS-like systems – Right??
  • 5. Backend & Frontend ● Back in the olden days – Didn't used to be like that – Everything was done serverside – Frontend was just styling ● These days – Code running serverside gets smaller – Code running clientside gets larger – Everything is (ran through) an API
  • 6. Scalability ● What – More iron – Distribution (CDNs etc) ● How? – Handling state? – Getting rid of state? – Different models? ● Performance
  • 9. High availability ● What are we talking about? – Failovers? – Handovers? ● How do we achieve that? – Handling application state? – Getting rid of state? – Different models / patterns / paradigms?
  • 10. Websockets ● Back in the olden days – Polling – Long Polling ● Standard since 2011 – RFC6455 ● Implementations available for most programming languages – Yes, even for PHP
  • 12. Websockets ● They're nice for things like chat and games ● But what about serious applications? – Etherpad – Ethercalc – Etherdraw ● Google docs
  • 13. Websockets ● But how does that apply to my CMS ● What about application state? ● Websockets have inherent state ● Coming from classic website model? – You probably need a different pattern / paradigm
  • 14. pub/sub ● Publish–subscribe pattern ● Does literally what it says ● First described in 1987 – In a talk at the SOSP conference – As part of “news” subsystem of Isis toolkit ● Not one standard but a pattern ● WAMP – Web Application Messaging Protocol (draft)
  • 16. pub/sub ● Publish ● .. to a channel – sometimes called a topic ● Most implementations return number of subscribers
  • 17. pub/sub ● Subscribe to (one or more) channels ● Subscribe to (one or more) patterns – For example: news.* ● Some servers / libraries – Faye – RabbitMQ – Redis – many more . .
  • 18. Tying it all together
  • 19. Tying it all together ● What is it good for? – Absolutely everything ● Subscribing to channels for pages and widgets – Your “user” list view – Any widget really ● Subscribing to alerts ● Collaborating
  • 20. Tying it all together ● Take a look at your “CMS” ● Any table could be an “auto-updating” list – Get initial data old-school page-load or via API ● Paginated – Subscribe to data channel ● Go fancy; subscribe to channel + pattern ● Any form could be a “multi-player” form – Implement field locking for bonus points
  • 21. Tying it all together ● You (client) send event to API (sync) ● API (server) broadcasts to channel (async) ● “Other” clients pick up on change – Only when applicable
  • 23. On the backend ● Redis (or other messaging bus) ● NodeJS (or other socket server) ● Some other backend language (optionally) – Legacy reasons ● Your favorite database – For long-term storing/logging
  • 24. Interesting Redis perks ● Key-value store – With TTL ● Distributed API rate-limiting ● Partitioning ● Distributed locks ● Cache store – Auto-eviction ● Lua scripting
  • 25. On the frontend ● RxJS ● Angular – Listeners, data objects – With RxJS ● React – Something something Flux ● Not a lib but a pattern ● Redux ● PubSubJS – Nice and small
  • 26. But will it scale?
  • 27. But will it scale? ● Subscribers are “cheap” ● Load balancing is simplified – Easiest round-robin setup mostly suffices ● Requests are lighter (less data) – Only wanted (subscribed) data gets transmitted ● Easy to add more (micro) servers ● Works very well with automatic scaling (AWS)
  • 28. How gracefully will it fail? ● Reload drops current subscriptions ● You start again – Get initial data – Subscribe to channel ● Handling a closed socket – Opportunity for an “event” ● Fail-fast
  • 30. What about security? ● WSS – Mandatory when serving over https ● JWT – Just as safe as session cookies ● Subscriptions dropped when connection closes – Safer than token based systems ● Have a TTL
  • 31. What about security? ● Unit-testable – Via mockups – Echo service ● Graceful degradation – Since (in most cases) it's just an addition ● Ledger – Accountability – Why not a blockchain?
  • 33. Retrofitting ● Fitting pub/sub into existing systems ● A-sync all the things? ● Starting small – Polling widget was hated during writing – Usually a retrofit in itself ● Things fall into place – On initial load get data directly (old-school) or via API – Subscribe and receive changes
  • 35. Wrapping up Use these modern web paradigms Over 95% browser support* * Probably even better depending on your target audience