title: How to prevent parallel builds per build configuration across multiple Build Agents
body: <p>I have many build configurations in TeamCity, each servicing a large project. In the past if a build is kicked off the Build Agent could be busy for up to 20min!</p>
  
  <p>In order to improve throughput I <a href="https://stackoverflow.com/questions/1789212/running-multiple-teamcity-agents-on-the-same-computer">installed a second Build Agent on the same machine</a> such that if a build run is kicked off by say Build Agent 1 and it is busy for 20min and someone from another project makes a change then Build Agent 2 can do the build for the other project without needing to wait on the current build run to finish.</p>
  
  <p>All was well until two successive check-ins resulted in both Build Agents running a build for a single build configuration in parallel. Since some resources are shared, IIS directories &amp; databases, I don't want a single build configuration to run on both Build Agents in parallel.</p>
  
  <p>How can I ensure a build isn't triggered if a build is currently running for that build configuration on a different build agent?</p>
  
  <p><a href="http://stevesmithblog.com/blog/set-up-build-agents-by-project-in-teamcity/" rel="nofollow noreferrer">One way</a> seems to involve environmental variables and ensuring a 50/50 split by Build Agent in terms of <em>build configuration compatibility</em>, but that seems a little clunky.</p>