Skip to content

[ws-daemon] Limit the number of concurrent workspace backups #10274

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

Merged
merged 1 commit into from
May 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions components/ws-daemon/pkg/content/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ func (s *WorkspaceService) DisposeWorkspace(ctx context.Context, req *api.Dispos
return resp, nil
}

// channel to limit the number of concurrent backups and uploads.
var backupWorkspaceLimiter = make(chan bool, 3)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to make the number be able to control with config. WDYT?


func (s *WorkspaceService) uploadWorkspaceContent(ctx context.Context, sess *session.Workspace, backupName, mfName string) (err error) {
//nolint:ineffassign
span, ctx := opentracing.StartSpanFromContext(ctx, "uploadWorkspaceContent")
Expand All @@ -407,6 +410,15 @@ func (s *WorkspaceService) uploadWorkspaceContent(ctx context.Context, sess *ses
span.SetTag("pvc", sess.PersistentVolumeClaim)
defer tracing.FinishSpan(span, &err)

// TODO: remove once we migrate to PVCs
// Avoid too many simultaneous backups in order to avoid excessive memory utilization.
waitStart := time.Now()
backupWorkspaceLimiter <- true
log.WithField("workspace", sess.WorkspaceID).Infof("waiting time for concurrent backups to finish was %v", time.Since(waitStart).String())
defer func() {
<-backupWorkspaceLimiter
}()

var (
loc = sess.Location
opts []storage.UploadOption
Expand Down