Skip to content

Automatically keep active workspaces alive #2233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ammario opened this issue Jun 10, 2022 · 20 comments
Closed

Automatically keep active workspaces alive #2233

ammario opened this issue Jun 10, 2022 · 20 comments
Labels
api Area: HTTP API cli Area: CLI

Comments

@ammario
Copy link
Member

ammario commented Jun 10, 2022

In v1, we detected when users were engaging with workspaces to keep them alive.

This made for a great developer experience since the developer never had to think about "bumping". The workspace magically stayed on for however long they needed it. While this was great for developers, it was painful for those responsible for cloud costs. Tabs left open overnight and untraceable ghost activity beefed up cloud bills.

Organizations fall on both sides of this trade off.

I believe there's a way to get the best of both worlds here.

We could add a flag like coder config-ssh --keep-alive. Every tunnel command in the SSH config would carry along that --keep-alive flag, and every coder CLI spawned with the flag would periodically bump the workspace. Idempotent bumping (see #2230) is a necessary prerequisite.

Eventually we could bump within native IDE extensions. We could implement a similar keep-alive behavior on requests to coder_apps so browser customers get activity-based shutdown as well.


Implementation note: reuse the notification goroutine

@ammario ammario changed the title Automatically keep active workspaces alive Automatically keep active workspaces alive via special flag Jun 10, 2022
@ketang
Copy link
Contributor

ketang commented Jun 10, 2022

What does this --keep-alive do exactly? Is it a bump or a pause or...?

@johnstcn
Copy link
Member

I'm imagining that it just periodically sends a request to /api/v2/workspaces/:workspace/extend so that the workspace never gets turned off.

@johnstcn johnstcn added api Area: HTTP API cli Area: CLI needs grooming labels Jun 10, 2022
@ammario
Copy link
Member Author

ammario commented Jun 10, 2022

I'm imagining that it just periodically sends a request to /api/v2/workspaces/:workspace/extend so that the workspace never gets turned off.

Yes, exactly. If we had a VS Code plugin, this could be implemented there too.

I suggested something in config-ssh so we can uniformly support JetBrains, VS Code, Vim and misc. terminal work.

@ketang
Copy link
Contributor

ketang commented Jun 10, 2022

When does it stop sending that keep alive?

@ammario
Copy link
Member Author

ammario commented Jun 10, 2022

When does it stop sending that keep alive?

When the connection terminates. E.g when the computer sleeps.

@ketang
Copy link
Contributor

ketang commented Jun 10, 2022

Hmm. My computer never sleeps unless I'm away from home. I also don't exit VS Code.

@ammario
Copy link
Member Author

ammario commented Jun 10, 2022

Yeah that's a challenge. The customer in question is fine with that. The turning off is a big nice to have for them. It also still works well in multi-workspace situations. You're unlikely to keep multiple VS Codes open with multiple workspaces all the time.

@ketang
Copy link
Contributor

ketang commented Jun 10, 2022

You're unlikely to keep multiple VS Codes open with multiple workspaces all the time.

uh 😬

@ammario
Copy link
Member Author

ammario commented Jun 10, 2022

You're unlikely to keep multiple VS Codes open with multiple workspaces all the time.

uh 😬

You're an edge case of an edge case of an edge case of an edge case.

@ketang
Copy link
Contributor

ketang commented Jun 10, 2022

Possibly. We should gather data.

@ajmeese7
Copy link

Contributing data: I'm with @ketang on this one! I love to keep all my projects/workspaces open so I can bounce between them with ease.

@ammario
Copy link
Member Author

ammario commented Jun 24, 2022

@ajmeese7 I agree and do the same thing.

Perhaps instead of activity detection at the SSH level we can do something more intelligent as a VS Code plugin. For example, we could bump the workspace on user-interaction.

@ammario ammario changed the title Automatically keep active workspaces alive via special flag Automatically keep active workspaces alive Jul 2, 2022
@ketang
Copy link
Contributor

ketang commented Jul 2, 2022

For automatic keep alive, we'll probably want to expose a fair number of knobs and switches, primarily around which events count for liveness and how long their effects are. Given how tricky this can be to get right, I don't want to have it entirely in opaque, unparameterizable code.

@ammario
Copy link
Member Author

ammario commented Jul 2, 2022

What MVP can we start with?

@ketang
Copy link
Contributor

ketang commented Jul 3, 2022

Incrementally replicate v1 but expose the knobs and switches.

@ammario
Copy link
Member Author

ammario commented Jul 3, 2022

Incrementally replicate v1 but expose the knobs and switches.

What does "replicate v1" mean? Why do you think we need to expose the knobs right now? Which knobs do you think we should expose?

@ketang
Copy link
Contributor

ketang commented Jul 3, 2022

I was kind of waving my hands because I haven't actually looked at the v1 implemention. But presumably it's basically some set of event types that count as activity and some grace period after each occurrence during which shutdown is deferred. What we could do is just expose a map from event type to grace period. We'd have sensible defaults that they could override, either by adding an event type, adjusting the grace period for an event type, or excluding an event type.

@sharkymark
Copy link
Contributor

Relying on a CLI command parameter setting is limited and flawed.

The customers, except for 1, use Coder completely browser-based, so some semblance of idle detection is not met with the CLI configuration.

To be clear, the largest of these customers actually does NOT like the existing idle behavior of v1. Their desired state is if the auto-shutdown behavior set by admins is 4 hours, then in 4 hours, if nothing was going on in the IDE or terminal, the workspace (in this case, a Kubernetes pod, is destroyed)

So their desired state is not met by v1 either.

@ammario @ketang @johnstcn

@ketang
Copy link
Contributor

ketang commented Jul 3, 2022

Ah I didn't mean that it would be in the CLI. It would be server-side.

I think giving customers control is the only realistic option. We don't know how do it perfectly, and giving them more control is a good compromise until we figure it out.

@ammario
Copy link
Member Author

ammario commented Jul 14, 2022

It looks certain we're going to do this. Let's discuss implementation in #2995.

@ammario ammario closed this as completed Jul 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Area: HTTP API cli Area: CLI
Projects
None yet
Development

No branches or pull requests

5 participants