https://github.com/bhaskarblur/distributed-chat-system
A scalable, distributed chat system built with Go - Gin, Kafka, and WebSocket. Distributes messages over services via Kafka
https://github.com/bhaskarblur/distributed-chat-system
chat-application gin-gonic golang kafka redis websocket
Last synced: 5 months ago
JSON representation
A scalable, distributed chat system built with Go - Gin, Kafka, and WebSocket. Distributes messages over services via Kafka
- Host: GitHub
- URL: https://github.com/bhaskarblur/distributed-chat-system
- Owner: bhaskarblur
- Created: 2024-11-24T14:58:27.000Z (over 1 year ago)
- Default Branch: develop
- Last Pushed: 2024-11-24T19:35:13.000Z (over 1 year ago)
- Last Synced: 2025-05-29T21:35:39.432Z (about 1 year ago)
- Topics: chat-application, gin-gonic, golang, kafka, redis, websocket
- Language: Go
- Homepage:
- Size: 54.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Distributed Chat System
A scalable, distributed chat system built with Go, Kafka, and WebSocket. This system enables real-time communication between users, leveraging Kafka for message brokering and WebSocket for maintaining persistent connections.
---
## Features
- **Real-time Messaging**: Supports instant communication using WebSocket.
- **Scalability**: Designed to handle a large number of users and messages with Kafka's horizontal scaling.
- **Distributed Architecture**: Runs multiple chat service instances seamlessly.
- **Dynamic Message Routing**: Routes messages to the correct chat service based on user connections.
- **Fault Tolerance**: Ensures reliable message delivery, even during failures.
- **Dynamic Topic Creation**: Automatically creates Kafka topics for new server instances.
---
## Architecture
1. **WebSocket Layer**:
- Maintains persistent connections with users.
- Forwards received messages to Kafka.
2. **Kafka (Message Broker)**:
- Distributes messages across chat service instances.
- Routes messages to appropriate partitions based on `ServerId`.
3. **Chat Services**:
- Each service consumes messages from Kafka partitions.
- Sends messages to connected users via WebSocket.
4. **User-to-Server Mapping**:
- Maintains a mapping of which user is connected to which server.
- Ensures message delivery to the correct server.