https://chatx-zbry.onrender.com/
A scalable, real-time chat application built with Node.js and Socket.IO, featuring SQLite persistence and multi-core clustering support.
- Real-time Communication: Powered by Socket.IO for low-latency messaging.
- Scalability: Implements Node.js native clustering with
@socket.io/cluster-adapterto utilize available CPU cores. - Data Persistence: Messages are stored securely in a local SQLite database (
chat.db). - Connection Recovery: Built-in support for connection state recovery to handle temporary disconnects without losing messages.
- Backend: Node.js, Express
- WebSockets: Socket.IO
- Database: SQLite (
sqlite3,sqlite) - Clustering:
@socket.io/cluster-adapter
-
Navigate to the project directory.
-
Install the required dependencies:
npm install express socket.io sqlite3 sqlite @socket.io/cluster-adapter
Note: If you are using PowerShell on Windows and encounter errors installing the cluster adapter, wrap the package name in quotes:
'@socket.io/cluster-adapter'.
-
Start the server:
node index.js
-
The application will spawn worker processes based on your available CPU cores.
-
Open your web browser and navigate to
http://localhost:3000.
index.js: The main server file containing clustering logic, database setup, and socket event handlers.index.html: The client-side HTML file serving the chat interface.chat.db: The SQLite database file (auto-generated upon first run).