Real-Time Chat
The project uses Laravel Reverb, Laravel Echo, private presence channels, typing indicators, seen status, message history and CI. This case study explains why normal Laravel HTTP servers and Reverb WebSocket servers are different and how both scale.
1 user — one app + one Reverb process
1 HTTP APP + 1 REALTIMELaravel server job
Validates and authorizes message requests, stores messages and exposes message history APIs.
Reverb server job
Keeps WebSocket connections open and broadcasts events. It is not the database and it should not replace durable message storage.
Correct flow
Send → validate/authorize → save message → broadcast event → receiver updates instantly.
~100 users — separate HTTP and socket resources
1–2 HTTP + 1–2 REVERBWhy separate?
HTTP requests are short-lived. WebSocket connections remain open. Separating capacity prevents socket growth from exhausting normal API workers.
Redis role
Shares transient presence, pub/sub and queue state across multiple processes so realtime nodes have common coordination.
Database role
Store messages, conversation membership and read state. Avoid writing every typing heartbeat into MySQL.
~1 million users — dedicated realtime fleet
4–10 HTTP + 10–30 REALTIME*Why more realtime nodes?
Capacity is driven by concurrently connected sockets, not only messages per second. A mostly idle user still consumes a connection.
Routing
Consistent routing or shared pub/sub helps deliver events regardless of which Reverb node holds the receiver connection.
History scaling
Index conversation_id + created_at, paginate messages, and use replicas for historical reads where acceptable.
~10 million users — regional realtime architecture
20–50+ HTTP + 100+ REALTIME*Regional connections
Users connect to a nearby realtime fleet to reduce latency. Cross-region events travel through a shared messaging/event backbone.
Ephemeral vs durable
Typing and online status live in fast transient systems. Actual messages and important delivery/read states go to durable storage.
Reliability
Use message IDs, acknowledgements, retry-safe processing, reconnect/resume logic, backpressure and monitoring of connected sockets per node.
*Realtime server counts depend heavily on concurrent connections
Ten million accounts do not mean ten million simultaneous WebSockets. The right Reverb fleet size comes from actual concurrent connections, memory per socket, event rate, network throughput and load testing. HTTP Laravel server count is measured separately.