Hosting multiple VSTS build agents on one Windows VM?

Hi, good day to you. I have a Windows VM that hosts a VSTS build agent. Due to the number and length of builds that are running, I would like to know whether multiple build agents can be hosted on one computer? That would allow a dedicated agent for slow builds, and a dedicated agent for quick builds. Can I know how should I implement that in my build pipeline?

Yes you can add more than one.

Be careful though, since Msbuild, vstest and other build tools will try to parallelize the build process, the build machine is often constrained in I/O and CPU. Adding a 2nd agent to the existing server may cause both to slow down.

Adding a 2nd agent is simply creating a new folder on your agent VM, downloading the agent and running config.cmd.

You can install multiple agents on the same VM and in pipeline specify as demand the Agent.Name:
pool:
name: pool1
demands:
- Agent.Name -equals agent-windows-01

You can’t configure the existing agent to run more than 1 pipeline, you just install more agents on the same VM.

You can also manually go into the agent queue settings and add a capability to the agent. That way you can filter using the demands on something more configurable than just the agent name.

What Jesse said. If run times are already a concern and they are resource intensive jobs dividing those already limited VM resources between more runs is likely to result in multiple simultaneous runs taking even longer to complete.

If they are simple pipelines running simple tasks scripts or managing activities on other servers but not building anything then sure stacking agents might work just fine.

Our agents that compile things are single agent per vm so those jobs get 100% of the resources.

Agents that do iac things and run simple pipelines that just take a long time to complete we have VMs with a 1 agent per vcpu ratio.

If using Azure Pipelines in the cloud, use the hosted agents when you can. Consider setting up a ScalesetVM cluster to easily scale up and down depending on the load. Only use self-hosted owned iron VMs for special things that such a cloud thing can’t do.

Thinking about it for iac pipelines I think we may be a 5/1 ratio in places performance when doesn’t matter much, the pipelines mostly wait for feedback from something. But never just one agent vm always a minimum of 2 because if you stack agents and anything goes wrong with that one vm non of the pipelines that depend on it will run.