Autostop with multiple services

I have an app that exposes two TCP services, and I’m wondering how that interacts with autostop. I can’t find an answer in the Autostop/autostart documentation.

  • If only one service has auto_stop_machines, can the machine ever be autostopped?
  • if both services have auto_stop_machines, do they both need no connections for the machine to be autostopped?
2 Likes

Hey @amonks

No. autostop needs to be enabled for all services.

If that’s the only running machine in an app - yes.

Thanks @pavel, that’s very helpful!

Let me see if I’m following the case where it is not the only running machine in an app.

Let’s say I have a two-service app running on two machines, and both services have auto_stop_machines="stop", min_machines_running=0. Let’s say one of the machines has connections to both services, so it won’t be autostopped.

If the other machine has lots of connections on service A, and no connections on service B, do I understand you correctly that it will be stopped?


In case it’s helpful, I’ll make this concrete. Here’s the use case I’m thinking about:

I have a webserver app.

  • It needs to terminate its own TLS, so it exposes a TCP service on internal_port=4433, services.ports[0].port=443.
  • To handle redirecting HTTP connections to HTTPS, it exposes another TCP service on internal_port=8080, services.ports[0].port=80
  • I’d like the app to always run in its primary_region, and spin up in other regions as-needed
  • The port 80 service only gets connections very rarely

If I understand this correctly:

if both services have auto_stop_machines, do they both need no connections for the machine to be autostopped?

If that’s the only running machine in an app - yes (I read: if it’s not the only running machine in an app, then no, the machine will be autostopped if either one of its services has no connections)

then if a machine autostarts in a non-primary region to handle some local HTTPS traffic, it will be autostopped unless it also has traffic to the HTTP redirector service?

Hey @amonks

It depends :slight_smile: With more than one running machine the proxy is allowed to stop machines that have active connections provided that the app is left with enough capacity to handle current connections.

The proxy will check if any of the services is at/above soft limit. If that’s the case, the whole machine is considered to be above soft limit.

After that the proxy will stop the machines (one by one) until “num above soft limit + 1” are left.

So in your case, if any of the services on any of the machines is at/above soft limit, nothing should be stopped.

Awesome! Thanks again, @pavel!

This is the detail I was looking for: the services’ soft limit evaluations are OR’d.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.