
Handle unlimited channels
Handle unlimited channels
Pub/sub channels are very cheap. You can have millions of unique channels without worrying about memory or CPU usage. Channels are automatically cleaned up when they are no longer used.

Deploy easily
Deploy easily
The socketcluster
CLI tool exposes kubectl
(Kubernetes) shortcut commands to make deploying your app to any Kubernetes cluster really easy. All necessary Kubernetes .yaml
files are provided.

Scale easily
Scale easily
After deploying your app to a Kubernetes cluster, you can scale indefinitely by using the kubectl scale deployment
command to add more scc-worker
and scc-broker
instances as needed.

Guarantee message order
Guarantee message order
You can perform asynchronous operations anywhere along a socket's inbound or outbound stream without any risk of disrupting the message processing order.

Monitor message backpressure
Monitor message backpressure
Awaiting for asynchronous actions along a socket's inbound or outbout streams can cause messages to pile up. This can be easily monitored on the back end using socket.getInboundBackpressure()
and socket.getOutboundBackpressure()
.

Support efficient authentication
Support efficient authentication
SocketCluster supports JWT authentication. This form of authentication is ideal for WebSockets because the token expiry can be made arbitrarily short and renewed often on an interval for very little performance cost while saving many database lookups.

Enforce access control using middleware streams
Enforce access control using middleware streams
Middleware streams allow you to block socket connections using the MIDDLEWARE_HANDSHAKE
middleware line and to block individual socket actions using the MIDDLEWARE_INBOUND
and MIDDLEWARE_OUTBOUND
lines.

Throttle and transform data using middleware streams
Throttle and transform data using middleware streams
Every data packet which is being received from or being sent to a client can be delayed or transformed using MIDDLEWARE_INBOUND_RAW
, MIDDLEWARE_INBOUND
or MIDDLEWARE_OUTBOUND
lines.

Avoid callback hell
Avoid callback hell
All data and events must be consumed using asynchronous loops (e.g. for-await-of
). Event listener callbacks are not supported; this solves many problems related to code readability and maintainability.

Recover from failure
Recover from failure
Clients are optimized to handle lost connections seamlessly. For example, if a client loses the connection, channels attached to that socket will be put in a pending
state and automatically resubscribe after the socket reconnects.

Write declarative code
Write declarative code
Without callbacks, asynchronous logic can always be executed from top to bottom. This makes it more obvious which parts of the code are serial and which parts are parallel and it encourages a more declarative style of programming.

Avoid memory leaks
Avoid memory leaks
Sockets and channels do not need to be destroyed explicitly. They will be automatically marked for garbage collection as soon as they stop being used and are no longer referenced in the code.