SlideShare a Scribd company logo
Adding Real-time
Features to PHP
Applications
About me
@ronnylt
Ronny López
Technical Lead
Opinions are my own
Agenda
• Concepts and foundations
• Real-time communication patterns
• Implementations
• Examples
Real-time
A system is said to be real-time if the total
correctness of an operation depends not only upon
its logical correctness, but also upon the time in
which it is performed
Real-time
Applications must guarantee response within
specified time constraints, often referred to as
“deadlines”
Real-time
Applications in which the computer must
respond as rapidly as required by the user
Criteria for real-time
• Hard – missing a deadline is a total system failure

• Firm – infrequent deadline misses are tolerable, but
may degrade the system's QoS. Results are NOT
usefulness after its deadline

• Soft – the usefulness of a result degrades after its
deadline, thereby degrading the system’s QoS
Real-time
Soft real-time
Soft real-time
Typically used to solve issues of concurrent
access and the need to keep a number of
connected systems up-to-date through
changing situations
Soft real-time use cases
• Live audio-video systems
• Users collaboration
• Messaging applications, etc…
• Real-time analytics
• Gaming
• Etc…
The road to 500 million
Symfony downloads
https://symfony.com/500million
Why adding a soft

real-time feature?
• To improve end-user experience
• Due to insufficient scaling capacity
Real-time
Communication on the
Web
A Bit of History
• Flash
• Ajax (XMLHttpRequest)
• Comet (reverse Ajax)
• WebSocket
• Polyfills
The Modern Web
• WebSockets
• HTTP/2
WebSockets
• Full-duplex communication channels over a
single TCP connection
• Currently supported in most major
browsers
• Can be used by any client or server
application
HTTP/2
• Major revision of the HTTP
• Replacement for how HTTP is expressed
“on the wire”
• Focus on performance, end-user perceived
latency, network and server resource usage
The Mobile Internet
• Inestable connections
• HTTP & TCP slow-start are usually not a
good match for constantly dropped
connections
• Network interface kills battery
• Large responses + periodic polling = bad
What EveryWeb
Developer Should Know
About Networking and
Browser Performance
Real-time
Communication
Patterns
The “actors”
Client Server
Peer Peer
Basic Patterns
• Remote Procedure Call (RPC)
• PUB/SUB
RPC
• Allows to call a procedure (function)
remotely
• Involves peers of these three roles
Caller CalleeDealer
RPC – Example 1
Something you usually do with Ajax
Browser Server
GetConference(123)
{name:deSymfony,where: Madrid}
RPC – Example 2
Push data to the browser
BrowserServer
DisplayOffer(offer)
RPC – Example 3
Communication between micro-services
Auth
Server
login(user)
Analytics Payments
track(user) process(order)
Publisher/Subscriber
• A peer subscribe to a topic
• Another peer publish a message about this
topic
• All publishers interested in the topic
receives the message
PUB/SUB – Example 1
Notifications
Browser
Server
updateStats(stats)
Browser Browser
Subscribed To: StatsUpdate
PUB/SUB – Example 2
Micro-services Synchronization
Auth
Admin
Service
updateSettings(freshSettings)
Encoding Payments
Subscribed To: SettingsChanges
Analytics
Web Application Messaging Protocol

http://wamp-proto.org/
Not to be confused with WAMP:
”Windows + Apache + MySQL + PHP"
WAMP
• Open standard WebSocket subprotocol
• Provides two application messaging
patterns in one unified protocol
• Remote Procedure Calls
• Publish & Subscribe
WAMP Features
• Enables different technologies, processes,
machines, etc… to communicate with each
other, in soft real-time
WAMP Features
• Based on modern Web standards:
WebSocket, JSON and URIs
• Designed with first-class support for
different languages in mind (Polyglot)
Unified Application Routing
Routing of events (for PUB/SUB) and routing of
calls (for RPC) in one unified protocol
Caller CalleeDealer
Publisher SubscriberBroker
Dealer
• Routes calls from the caller to the callee
and routes back results or errors
• Callers and callee don’t know about each
other
• Applications using RPC benefit from these
loose coupling
Caller CalleeDealer
Broker
• Keeps a book of subscriptions
• Forward the events (messages) to all
subscribers
• Publisher are subscribers are loosely
coupled
Publisher SubscriberBroker
Unified Protocol
• When you combine a Broker and a Dealer
you get what WAMP calls a Router
Router Broker Dealer= +
The Big Picture
WAMP Router
(Dealer + Broker)
BrowserBrowserBrowserBrowser
Mobile
Clients
Services
Do we really need
another wheel?
How does WAMMP compare to other technologies
Criteria
• Pub/Sub
• RPC
• Routed RPC (not only point-to-point)
• Web native: run natively on the Web (without
tunneling or bridging)
• Cross Language
• Open Standard
Tech PubSub RPC
Routed
RPC
Web native
Cross
Language
Open
Standard
WAMP ✔ ✔ ✔ ✔ ✔ ✔
Ajax ✔ ✔ ✔
Comet ✔ ✔
JSON-RPC ✔ ✔ ✔ ✔
socket.io ✔ ✔
ZMQ ✔ ✔
XMPP ✔ ✔ ✔ ✔
Implementations
• Client libraries for most popular languages
• Full featured router implementations in
several languages
WAMP Routers
• crossbar.io – Advanced, open-source, full
featured, supported by the creators of
WAMP

• Your own… It’s an open protocol
WAMP Ecosystem
• Thruway – library built in PHP that provides
both a client and a router
• Turnpike – router implemented in Go

• wamp.rt  – router for NodeJS

• Erwa – router implemented in Erlang

Choosing an
implementation
Let’s talk about trade-offs
Is PHP suitable for soft
real-time applications?
Is PHP the right tool
for the job?
No.
No?
Why not?
Let’s use
Node.js ! It’s an opportunity to
deploy Erlang or
Golang, or …
Languages War
Conflicts Everywhere
Conflicts everywhere
Trade-offs everywhere
Trade-off
• Situation that involves losing one
quality or aspect of something in
return for gaining another quality
or aspect

• It often implies a decision to be
made with full comprehension of
both the upside and downside of
a particular choice
Is PHP the right tool
for the job?
There is not simple answer
The simpler answer I know is:
“I don’t care”
PHP Codebase

(Symfony, Silex, Laravel, Drupal, etc…)
Clients
Web, Mobile, etc…
Request/Response
Request/Response
Real-time API

Pub/Sub, RPC, etc..
RPC
• A big ecosystem of thousands of useful
libraries and components easily installable
thanks to Composer
• Very powerful template engines, ORMs,
etc…
• We have implemented very powerful design
patters in PHP coming from Java and other
languages
• We have several thousands of high quality code
running on production
• We have invested multiple hours testing,
refactoring and improving the codebase
It’s here to stay
Adding Real-time Features to PHP Applications
Remember
Full comprehension of both the upsides and downsides
of a particular choice
Downsides
• We have to introduce a new stack to
provide real-time features
Upsides
• Possibility to introduce real-time features
without deep modifications in the current
codebase
• No need to learn a whole new language/
stack, with the implications it has
• Loosely coupled systems
Upsides cont…
• Opens the door to write reactive, event-
based, distributed architectures
• Scalability is easier to achieve by
distributing messages to multiple systems
Examples
The Stack
• crossbar.io used as the router (dealer+broker)
• PHP client gathers and publish events
• Silex/Symfony backend serve the data and
contains the biz logic
crossbar.io
• Networking platform for distributed and
micro-services applications
• Full implementation of the WAMP protocol
• Feature rich, scalable, robust and secure
• It takes care of the hard parts of messaging
so you can focus on your app's features
Adding Real-time Features to PHP Applications
Tips and Tricks
• WSS
• Deadlines
• Timeouts
• Retries with back-off, etc…
• Idempotency
Opinionated
Conclusion
• Understand core concepts and patterns,
technology is volatile
• Question everything: Why?, why not?
• Decide based on several factors: user
experience, scalability, feasibility, developer
experience, maintenance costs/debt, etc…
Don’t Stop Here
• gRPC – A high performance, open-source
universal RPC framework from Google



http://www.grpc.io/

• IoT, WoT, etc… – real world objects
connected to the wider internet
References
• WAMP Proto – http://wamp-proto.org/
• https://github.com/voryx/ThruwayBundle
• https://www.infoq.com/articles/websocket-
and-http2-coexist
Questions
• What about React PHP?
• Multi-Threading in PHP with pthreads?

https://gist.github.com/krakjoe/6437782/
• Micro-services what?
Gracias!
@ronnylt
Work with us!

More Related Content

What's hot (20)

PPTX
A tour of Java and the JVM
Alex Birch
 
PDF
RabbitMQ fairly-indepth
Wee Keat Chin
 
PPTX
Keeping up with PHP
Zend by Rogue Wave Software
 
PDF
XMPP Academy #1
Mickaël Rémond
 
PDF
Messaging Standards and Systems - AMQP & RabbitMQ
All Things Open
 
PDF
Fabric8 mq
Rob Davies
 
PPTX
High powered messaging with RabbitMQ
James Carr
 
PDF
Integrating PostgreSql with RabbitMQ
Gavin Roy
 
PDF
EUC2015 - Load testing XMPP servers with Plain Old Erlang
Paweł Pikuła
 
PDF
Being Agile with Scrum - koders.co
Ender Aydin Orak
 
PDF
ZaloPay Merchant Platform on K8S on-premise
Chau Thanh
 
PDF
Apache james more than emails in the cloud
Ioan Eugen Stan
 
PDF
Apache James/Hupa & GWT
Manuel Carrasco Moñino
 
PDF
NullMQ @ PDX
Jeff Lindsay
 
PPSX
webservers
Ewere Diagboya
 
PPT
Lecture6
tt_aljobory
 
PDF
Composer
Le Thanh Sang
 
PPTX
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)
Panagiotis Kanavos
 
PDF
Java Application Servers Are Dead!
Eberhard Wolff
 
PDF
CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...
Ortus Solutions, Corp
 
A tour of Java and the JVM
Alex Birch
 
RabbitMQ fairly-indepth
Wee Keat Chin
 
Keeping up with PHP
Zend by Rogue Wave Software
 
XMPP Academy #1
Mickaël Rémond
 
Messaging Standards and Systems - AMQP & RabbitMQ
All Things Open
 
Fabric8 mq
Rob Davies
 
High powered messaging with RabbitMQ
James Carr
 
Integrating PostgreSql with RabbitMQ
Gavin Roy
 
EUC2015 - Load testing XMPP servers with Plain Old Erlang
Paweł Pikuła
 
Being Agile with Scrum - koders.co
Ender Aydin Orak
 
ZaloPay Merchant Platform on K8S on-premise
Chau Thanh
 
Apache james more than emails in the cloud
Ioan Eugen Stan
 
Apache James/Hupa & GWT
Manuel Carrasco Moñino
 
NullMQ @ PDX
Jeff Lindsay
 
webservers
Ewere Diagboya
 
Lecture6
tt_aljobory
 
Composer
Le Thanh Sang
 
Parallel and Asynchronous Programming - ITProDevConnections 2012 (Greek)
Panagiotis Kanavos
 
Java Application Servers Are Dead!
Eberhard Wolff
 
CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...
Ortus Solutions, Corp
 

Similar to Adding Real-time Features to PHP Applications (20)

PDF
Building real time applications with Symfony2
Antonio Peric-Mazar
 
PDF
Html5 web sockets - Brad Drysdale - London Web 2011-10-20
Nathan O'Hanlon
 
PDF
Backend & Frontend architecture scalability & websockets
Anne Jan Brouwer
 
PDF
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
sametmax
 
PPTX
Smart Gamma - Real-Time Web applications with PHP and Websocket.
Evgeniy Kuzmin
 
PDF
Real time web apps
Sepehr Rasouli
 
PDF
Adding Realtime to your Projects
Ignacio Martín
 
PPTX
Autobahn primer
Robbie Byrd
 
PDF
PHP projects beyond the LAMP stack
Codemotion
 
PDF
Voice and Video on the Web
Kundan Singh
 
PDF
Cs556 section1
farshad33
 
PDF
DevCon 5 (July 2013) - WebSockets
Crocodile WebRTC SDK and Cloud Signalling Network
 
PPT
Large-scale projects development (scaling LAMP)
Alexey Rybak
 
PDF
Rapid Web Development with Python for Absolute Beginners
Fatih Karatana
 
PDF
PHP is the King, nodejs is the Prince and Lua is the fool
Alessandro Cinelli (cirpo)
 
PDF
PHP is the king, nodejs is the prince and Lua is the fool
Alessandro Cinelli (cirpo)
 
PPTX
Real-Time Web applications with WebSockets
Stanislav Zozulia
 
PDF
PHP is the King, nodejs the prince and python the fool
Alessandro Cinelli (cirpo)
 
PDF
PHP is the king, nodejs is the prince and Python is the fool - Alessandro Cin...
Codemotion
 
PDF
X realtime xmp-ptut-pdf
Hsiao Tim
 
Building real time applications with Symfony2
Antonio Peric-Mazar
 
Html5 web sockets - Brad Drysdale - London Web 2011-10-20
Nathan O'Hanlon
 
Backend & Frontend architecture scalability & websockets
Anne Jan Brouwer
 
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
sametmax
 
Smart Gamma - Real-Time Web applications with PHP and Websocket.
Evgeniy Kuzmin
 
Real time web apps
Sepehr Rasouli
 
Adding Realtime to your Projects
Ignacio Martín
 
Autobahn primer
Robbie Byrd
 
PHP projects beyond the LAMP stack
Codemotion
 
Voice and Video on the Web
Kundan Singh
 
Cs556 section1
farshad33
 
DevCon 5 (July 2013) - WebSockets
Crocodile WebRTC SDK and Cloud Signalling Network
 
Large-scale projects development (scaling LAMP)
Alexey Rybak
 
Rapid Web Development with Python for Absolute Beginners
Fatih Karatana
 
PHP is the King, nodejs is the Prince and Lua is the fool
Alessandro Cinelli (cirpo)
 
PHP is the king, nodejs is the prince and Lua is the fool
Alessandro Cinelli (cirpo)
 
Real-Time Web applications with WebSockets
Stanislav Zozulia
 
PHP is the King, nodejs the prince and python the fool
Alessandro Cinelli (cirpo)
 
PHP is the king, nodejs is the prince and Python is the fool - Alessandro Cin...
Codemotion
 
X realtime xmp-ptut-pdf
Hsiao Tim
 
Ad

Recently uploaded (20)

PDF
What Is an Internal Quality Audit and Why It Matters for Your QMS
BizPortals365
 
PPTX
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
 
PDF
Continouous failure - Why do we make our lives hard?
Papp Krisztián
 
PPTX
Android Notifications-A Guide to User-Facing Alerts in Android .pptx
Nabin Dhakal
 
PPTX
CV-Project_2024 version 01222222222.pptx
MohammadSiddiqui70
 
PDF
LPS25 - Operationalizing MLOps in GEP - Terradue.pdf
terradue
 
PPTX
Wondershare Filmora Crack 14.5.18 + Key Full Download [Latest 2025]
HyperPc soft
 
PDF
Laboratory Workflows Digitalized and live in 90 days with Scifeon´s SAPPA P...
info969686
 
PPTX
How Can Recruitment Management Software Improve Hiring Efficiency?
HireME
 
PPTX
Introduction to web development | MERN Stack
JosephLiyon
 
PDF
>Nitro Pro Crack 14.36.1.0 + Keygen Free Download [Latest]
utfefguu
 
PDF
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
 
PDF
The Rise of Sustainable Mobile App Solutions by New York Development Firms
ostechnologies16
 
PDF
Building scalbale cloud native apps with .NET 8
GillesMathieu10
 
PPTX
Avast Premium Security crack 25.5.6162 + License Key 2025
HyperPc soft
 
PPTX
computer forensics encase emager app exp6 1.pptx
ssuser343e92
 
PDF
From Chaos to Clarity: Mastering Analytics Governance in the Modern Enterprise
Wiiisdom
 
PDF
capitulando la keynote de GrafanaCON 2025 - Madrid
Imma Valls Bernaus
 
PDF
Cloud computing Lec 02 - virtualization.pdf
asokawennawatte
 
PDF
Automated Test Case Repair Using Language Models
Lionel Briand
 
What Is an Internal Quality Audit and Why It Matters for Your QMS
BizPortals365
 
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
 
Continouous failure - Why do we make our lives hard?
Papp Krisztián
 
Android Notifications-A Guide to User-Facing Alerts in Android .pptx
Nabin Dhakal
 
CV-Project_2024 version 01222222222.pptx
MohammadSiddiqui70
 
LPS25 - Operationalizing MLOps in GEP - Terradue.pdf
terradue
 
Wondershare Filmora Crack 14.5.18 + Key Full Download [Latest 2025]
HyperPc soft
 
Laboratory Workflows Digitalized and live in 90 days with Scifeon´s SAPPA P...
info969686
 
How Can Recruitment Management Software Improve Hiring Efficiency?
HireME
 
Introduction to web development | MERN Stack
JosephLiyon
 
>Nitro Pro Crack 14.36.1.0 + Keygen Free Download [Latest]
utfefguu
 
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
 
The Rise of Sustainable Mobile App Solutions by New York Development Firms
ostechnologies16
 
Building scalbale cloud native apps with .NET 8
GillesMathieu10
 
Avast Premium Security crack 25.5.6162 + License Key 2025
HyperPc soft
 
computer forensics encase emager app exp6 1.pptx
ssuser343e92
 
From Chaos to Clarity: Mastering Analytics Governance in the Modern Enterprise
Wiiisdom
 
capitulando la keynote de GrafanaCON 2025 - Madrid
Imma Valls Bernaus
 
Cloud computing Lec 02 - virtualization.pdf
asokawennawatte
 
Automated Test Case Repair Using Language Models
Lionel Briand
 
Ad

Adding Real-time Features to PHP Applications