Clients can use PubSub Clients can register RPC → code is executed here Clients can call RPC More infrastructure (but one-time) Easier to separate concerns (domains) Scales well Code integrated (for example PHP based) Clients can only use what the code offers Server registers RPC, so it executes the code Less infrastructure Doesn’t scale well
Ratchet\ConnectionInterface; use Ratchet\Server\IoServer; use Ratchet\WebSocket\WsServer; class MyWsServer implements MessageComponentInterface { public function onOpen(ConnectionInterface $conn) { $conn->send('Test message'); } public function onMessage(ConnectionInterface $conn, $msg) { // Do something with the message } public function onClose(ConnectionInterface $conn) { } public function onError(ConnectionInterface $conn, \Exception $e) { } } $server = IoServer::factory( new HTTPServer( new WsServer( new MyWsServer() ) ), 8090 ); $server->run();
apps (like chat) Complex apps with trusted clients only Multiple for : Complex apps with web or other untrusted clients High-traffic Note : Multiple adds complexity if they need to communicate If your websocket server runs code, each process is