An Introduction to socketcluster.io and Ruby Client
Full code at https://github.com/OpenSocket/socketcluster-client-ruby
I always had interest in real-time frameworks and working with chat based applications. I was searching for available frameworks that can be used for building chat based applications. There were lots of available options like Pubnub, Pusher, Firebase, socket.io and socketcluster.
The problem with cloud based services like Pubnub, Pusher and Firebase is limitation on writing custom logic on the backend side and ultimately pricing. The socket.io seem to have larger developer community, quite good in terms of setting up environment and flexible API architecture. Still, I needed something more than this; a framework that is easy to scale and can handle millions of concurrent connections. Finally , I found a socketcluster framework as best solution which is powered by fastest available WebSocket engine uwebsockets.
SocketCluster is an open source real-time framework for Node.js. It supports both direct client-server communication and group communication via pub/sub channels. It is designed to easily scale to any number of processes/hosts and is ideal for building chat systems. SocketCluster was designed to make the process of building scalable real-time systems simpler.
SocketCluster is a fast, highly scalable HTTP and WebSockets server environment which lets you build multi-process real-time systems that make use of all CPU cores on a machine/instance. It removes the limitations of having to run your Node server as a single process and makes your backend resilient by automatically recovering from worker crashes.
SocketCluster works like a pub/sub system which extends all the way to the browser/IoT device — It only delivers particular events to clients who actually need them. SocketCluster is designed to scale both vertically (as a cluster of processes) and horizontally (multiple machines/instances).
Technical Features
- Scales linearly as you add more CPU cores and workers.
- Scales horizontally across multiple machines.
- Resilient on both the client and back-end — Process crashes, lost connections, and other failures are handled seamlessly.
- Supports custom codecs for compressing messages during transmission.
- Supports both pub/sub channels and direct client-server communication (for RPC).
- Authentication engine compliant with JSON Web Token (JWT).
- Client sockets automatically reconnect (by default) if they lose the connection.
What is it good for?
- Single-page apps which need to render live data.
- Finance, cryptocurrencies and other block-chain applications.
- Chat-bots and other chat-related applications.
- Mobile apps built with web technologies such as React Native or Ionic/Cordova.
- Any kind of real-time app or service which needs to scale to millions of users.
We accomplished to design a Real-time SDKs using Ruby Client. It’s a ruby client for socketcluster.io
Get Maanav Shah’s stories in your inbox
Join Medium for free to get updates from this writer.
This client provides the following functionality:
- Easy to set up and use
- Support for emitting and listening to remote events
- Automatic re-connection
- Pub/sub
- Authentication (JWT)
- Can be used for extensive unit-testing of all server-side functions
- Support for ruby >= 2.2.0
This site is also open source, contributions on GitHub are welcome.
If you are new to Websockets, socket.io and socketcluster.io, I would recommend reading from these links:
https://www.linode.com/docs/development/introduction-to-websockets/
That’s it. Hope this helps.
If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Twitter or Facebook. Thank you!









