perf: remove pubsub usage for workspace agent metadata updates #21177
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The pubsub usage for workspace metadata updates, where the
UpdateWorkspaceAgentMetadataalso callspubsub.Publishcan be quite expensive in deployments with a larger workspace/workspace agent count.IIUC the
Publishcall leads to a DB wide lock on the message queue portion within PG. End users can try to reduce the impact of these calls by setting higher metadata update intervals for each agent metadata in a template, but in reality the end user facing functionality doesn't really need to be achieved via pubsub imo.ATM, the only subscriber for these events is the
WorkspaceUI page, where a user is viewing a single workspace. I would assume that most of the time people don't leave the workspace page open after starting a workspace and connecting via some IDE. This assumption means that we're sending a lot of publish events when there's no subscriber that wants to receive them. This still puts some amount of processing load on the DB even though there's no one who wants the data. On top of that, it's easy for end users to set (or not set, and get the default) low metadata update intervals, and it's not immediately clear to them that the lowest interval in the whole template is the frequency on which that agent will sendUpdateWorkspaceAgentMetdata/Publishcalls to the DB.I am also assuming that having the UI show to-the-second up to dateThis is doubly true for workspaces that are used by AI related tasks.
Therefore, of someone is really viewing their workspace UI page it seems reasonable to simply poll the database for that workspaces agent metadata.
NOTE: I've built and tested this within a workspace using
develop.shand verified the polling works. We likely still want to add a frontend test and potentially change the interval and/or retry behaviour as well as the message in the FE when the metadata cannot be retrieved.Also blink tasks helped with these changes.