48

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.

https://www.visualstudio.com/en-us/docs/build/admin/agents/v2-windows

James Newton-King
  • 48,174
  • 24
  • 109
  • 130

3 Answers3

52

Yes you can run multiple agents in a single VM.

Make two directories say Agent1 and Agent2, extract the agent in each one of them and configure them with different names against your VSTS/TFS account.

It should work out of the box.

Harshil Lodhi
  • 7,274
  • 1
  • 33
  • 42
  • 7
    It's worth noting that builds are typically IO constrained (disk/network read/write speeds) rather than memory/CPU constrained. Running too many parallel builds on one machine will actually degrade performance. – Daniel Mann Nov 27 '16 at 18:47
  • @DanielMann I am running two build agents at the same machine, and they never run in parallel. Should that be possible? – Boland Feb 01 '17 at 07:54
  • 1
    @Boland I believe that has to do with the Pipelines you have setup. You can run 1 build or release pipeline concurrently per private pipeline you have purchased. Go to root vsts settings | Build and Release | Resource Limits. make those more than 1. – etropic Feb 05 '18 at 22:29
  • 1
    In our company, two agents per VM are running. The fact that this makes no sense for I/O-constrained workloads has already been mentioned. I just want to bring attention to an actual issue I am seeing: When both the agents on the VM share the same user they run under, pipelines often fail in nasty ways. Many tools, e.g. NuGet package manager for .NET, use a well-known folder in the user's profile to store some data and they do not expect multiple instances of the same tool to run concurrently. – Palec Oct 02 '22 at 16:52
3

We run 4 agent jobs per machine concurrently with no issues. As mentioned above, should work out of the box. Just make sure you clean up directories. We have a script to do it every night

ylerner
  • 75
  • 7
3

Yes, this works, I did the following:

  1. Created a PAT for agent installation needs
  2. Downloaded agent binaries from the agent creation page
  3. Unpacked the archive contents into 2 different directories ("c:\ado-build-agents\agent1" and "c:\ado-build-agents\agent2")
  4. Ran "config.cmd" and followed configuration instructions, provided by it.
  5. Updated pipelines to build the agent pool, which those agents reside in ("Default" in my case)
  6. To test the setup - triggered all 15 pipelines, that I had. As the result I was able to see two pipelines running at the same time, while others were in the "Queued" state (according to my expectations).

I will be also testing out how resources are consumed by the agents to try to understand if I should deploy more agents on the build machine.

v0ffka
  • 41
  • 1
  • 1
  • This is against Microsoft's recommendations which are 1 agent per machine. How was the performance? – Rye bread Sep 27 '22 at 12:02
  • @Ryebread, do you have any link to the recommendation? I am trying to get the DevOps Server admins in our company to change the setup and run just one agent per VM. – Palec Oct 02 '22 at 16:45
  • @Palec Here you go: https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/agents?view=azure-devops&tabs=browser#install – Rye bread Oct 03 '22 at 07:41
  • _Although multiple agents can be installed per machine, we strongly suggest to only install one agent per machine. Installing two or more agents may adversely affect performance and the result of your pipelines._ Thanks, @Ryebread! – Palec Oct 03 '22 at 13:27