A test of scaling a simple websocket server written in Java and can be deployed either locally with HAProxy or deployed to google cloud kubernetes engine
To build this reposetory use docker build -t socketserver .
.
If you haven't enabled docker swarm yet, run: docker swarm init
.
This stack can be deployed using docker stack deploy --compose-file=docker-compose.yml [NAME]
.
This may take a while.
Finally you can observe your service using docker service ls
.
Scalling is possible with docker service scale [NAME]_ws=[NUM]
.
Delete this service using docker service rm [NAME]
.
Follow the tutorial on their official site. https://console.cloud.google.com/kubernetes/
A nice sample is provided by them on GitHub
Docker Compose does NOT work due to network limitations
When deploying loacally you can access the websocket via any webbrowser or application that supports websockets.
Connectings will be handled under the port 8443 so you can connect using ws://localhost:8443
. Port and more is editable in the docker-compose.yml.
You can obtain a SSL certificate either with LetsEncrypt or using CloudFlare. Either way you have to edit the docker-compose.yml to add your private key and your certificate like shown. This may help you creating the string.