Comments (3)
@maxime-crunding
You can restart all workers by sending a SIGUSR2 signal to the master process (master PID is logged when you start SC) or you can use the SocketCluster instances' killWorkers() method (on master) if you want to do it programmatically. The new workers will use the fresh code.
Workers typically take less than a second to restart - Not long enough for HTTP requests to timeout - So except from the fact that all active realtime connections are destroyed (and will have to reconnect), it might feel close to zero downtime. SC clients will automatically try to reconnect - So in effect, clients will miss a few seconds of realtime messages between the time they lose the connection and the time the 'connect' event triggers again.
Missing a few realtime messages isn't a huge deal if you're storing the messages in a database anyway (which is usually the case for most apps unless we want truly ethereal messaging) you can make your clients refetch the latest data when socket.on('connect', ...) triggers - That way they won't actually miss anything - This reduces the problem down to only to a slight delay.
True zero downtime deploy is difficult to achieve with realtime WebSocket connections because each client is attached to a single server. We could come up with a strategy to keep the old workers up (the ones that have active connections) and spawn some new ones (which use the new code) to handle all new connections and the old workers will be killed only when they have 0 clients left attached to them - But then what if we do several deploys in a row - We might end up with a LOT of workers using different versions of the code and it would get confusing when errors happen. So this approach is probably not worthwhile.
from socketcluster.
Sending a SIGUSR2 to the master PID suits me perfectly.
Thanks for digging in.
from socketcluster.
I should probably add it to the docs... It's quite important :)
from socketcluster.
Related Issues (20)
- Worker is leaving instance repeatedly and reconnects after a while HOT 1
- Is it possible to merge publish messages? HOT 1
- SocketCluster version 16.0.1 SCC problem in minikube k8
- JWT token : invalid signature HOT 1
- `socketcluster create` screws up app name HOT 2
- badSocketAuthToken event not triggering HOT 2
- Unused dependencies HOT 1
- Bump Docker image HOT 1
- Socket connection gets timed out unexpectedly HOT 3
- Potential security issue HOT 5
- any way to send the missing socket update to client after network restore HOT 3
- We unable received the middleware sending error message from socket client HOT 2
- Has anyone tried to deploy socket cluster on Azure Container apps? HOT 1
- socket.on is not a function HOT 3
- BadConnectionError - socketcluster-client when requesting from server side. It works fine if the request is issued from the browser. HOT 3
- Callbacks scale much more than async/await approach HOT 2
- Namespace in channels HOT 3
- Is there any CPU/Memory Resources requests / limits recommendation?
- Socketcluster 16.x stopped working due to underlying library update HOT 1
- socketcluster compliance HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from socketcluster.