#websockets #gamedev #server

nightly app scalesocket

A collaborative websocket server and autoscaler

6 releases

0.2.1 Nov 19, 2023
0.2.0 Nov 14, 2023
0.1.5 Aug 9, 2023
0.1.4 May 7, 2023
0.1.2 Nov 5, 2022

#72 in Caching

Download history 4/week @ 2023-08-15 2/week @ 2023-08-22 4/week @ 2023-08-29 4/week @ 2023-09-05 6/week @ 2023-09-12 3/week @ 2023-09-19 3/week @ 2023-09-26 1/week @ 2023-10-03 1/week @ 2023-10-17 1/week @ 2023-10-24 4/week @ 2023-10-31 54/week @ 2023-11-14 14/week @ 2023-11-21 18/week @ 2023-11-28

86 downloads per month




Build status Crates.io

ScaleSocket is a collaborative websocket server and autoscaler. It's a simple way to build multiplayer backends.

High level architecture diagram on ScaleSocket usage


ScaleSocket is a command line tool that lets you to wrap a script or binary, and serve it collaboratively over websockets. Clients then connect to rooms (a.k.a. channels) which have a unique URL (wss://example.com/exampleroom). Connecting to a room spawns a new process of the wrapped binary. Subsequent connections to the same room share the process.


For full details and installation instructions, see the documentation.


  • Share a backend process between websocket clients
  • Proxy websocket traffic to normal TCP socket or stdio
  • Route server messages to specific clients
  • Serve static files
  • Expose CGI environment variables to backend process
  • OpenMetrics compatible
  • Built-in lobby server for listing rooms

Quick Start

Create the file example.sh with the follow content:

echo '{"message": "hello world"}'
sleep 1
echo '{"message": "goodbye"}'
sleep 1

Make it executable:

$ chmod u+x example.sh

Wrap it by starting the ScaleSocket server:

$ scalesocket ./example.sh

Then connect to the websocket endpoint, for example using curl:

$ curl --include \
       --no-buffer \
       --http1.1 \
       --header "Connection: Upgrade" \
       --header "Upgrade: websocket" \
       --header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
       --header "Sec-WebSocket-Version: 13" \
�{"message": "hello world"}�{"message": "goodbye"}%

For more advanced usage and features, see usage.



Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.


~307K SLoC