Runner is shutting down VM and causing Redis to disconnect

Runner is shutting down VM and causing Redis to disconnect

I am using Redis as a session store for an Express app and stored values in the session are coming back undefined. I suspect the Redis connection is being lost as the logs in Upstash are showing this.

How do I prevent the VM from shutting down? Shouldn’t the runner just turn off and not the app vm? I’m a little confused. Looking forward to the solution!

Hmm … I guess it depends when and why the vm is shutting down.

Is this during a (successful) deploy? Or as part of autoscaling (down)?

If so, it would be normal for a VM to be shut down. You can see from the bit in [] like [abcdefg] which vm the log line is referring to. Like, during a deploy you will see log lines from [new-vm-id] appear alongside ones from [old-vm-id] as they swap (new vm starts and old one shuts down).

In that case, you’d expect and want the Redis connection to be lost from the old vm, as it would not be needed any more and you only have a limited number.

If it’s during normal operation, then a vm should not generally shutdown. Unless Fly needs to move one (like during capacity, load, scaling etc).

Since you mention using Upstash, if losing connections is a general concern, the other approach would be using a http call to their API. Avoiding needing a connection at all. Normally you are right, a redis connection is made and persists for speed/overhead. But they have made a REST API with serverless-style in mind: