2. Agenda
● What Is real-time? (for WEB)
● HTTP based techniques
● HTML5 Web sockets
● Ratchet library for PHP
● What's NEXT? (WAMP, Scaling…)
3. The real-time web is
“a set of technologies and practices that
enable users to receive information as soon
as it is published by its authors, rather than
requiring that they or their software check a
source periodically for updates“
https://en.wikipedia.org/wiki/Real-time_web
4. AJAX polling
● Latency (<= interval)
● BIG overhead
● Half-duplex
● But...
easy to implement
6. HTML5 Websocket protocol
RFC 6455
“is a protocol providing full-duplex communication
channels over a single TCP connection“
https://en.wikipedia.org/wiki/WebSocket
Request
Response
12. ● Catch all possible exception;
● Ping a DB connection and
reconnect;
● … and everything else it
interacts with;
● Use supervisord;
● Log messages;
● Tests, tests, tests...
Code carefully
One error will ruin it all
14. Web Application Messaging Protocol
JSON based WebSocket subprotocol that provides two application
messaging patterns in one unified protocol:
● Remote Procedure Calls (call function and get result)
● Publish & Subscribe (topics - channels in websocket)
onOpen
onClose
onCall - call a remote procedure
onSubscribe - subscribe to topic
onUnsubscribe - unsubscribe from topic
onPublish - publish to topic
onError
Events:
Client libs: http://wamp-proto.org/implementations/
http://wamp-proto.org/
15. Problems
1. Ratchet will not support SSL for server
Nginx, HAProxy, STunel
2. Difficult to scale (load balancers)
Reverse proxies still can help