Answers: <p>In general: No you can't. At least not on the Docker level.</p>
  <p>You can maybe code your app in a way that it monitors such metrics and adjusts itself but Docker isn't able to.</p>
  <p>What Docker CAN do is limit the app to 50% and kill it if it uses more than that by utilizing resource limits:</p>
  <p><a href="https://docs.docker.com/config/containers/resource_constraints/" rel="nofollow noreferrer">docs.docker.com - containers/resource_constraints</a></p>
  <p><a href="https://docs.docker.com/compose/compose-file/compose-file-v3/#resources" rel="nofollow noreferrer">docs.docker.com - docker-compose resource limits</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2021-02-24T21:48:19.297Z
Answers: 2021-02-24T21:48:19.297Z
Answers: Worp
Body: <p>Consider the scenario where I have:</p>
  <ul>
  <li>4 replicas of an app</li>
  <li>4 cores</li>
  <li>On load, the app consumes 100% for a single core</li>
  </ul>
  <p>Can I tell each replica to only use 50% of the core and if so, would this allow at most 8 simultaneous connections to the app? I have just dipped my toe into this stuff so an feedback would be appreciated.</p>
  
Tags: <containers><docker-swarm>
Title: Increase concurrent users by limiting container resources with docker-swarm
UserDisplayName: tyluRp
ThreadText: # Increase concurrent users by limiting container resources with docker-swarm
  
  (Asked by: username_0 on 2021-01-25)
  
  Consider the scenario where I have:
  
  * 4 replicas of an app
  * 4 cores
  * On load, the app consumes 100% for a single core
  
  Can I tell each replica to only use 50% of the core and if so, would this allow at most 8 simultaneous connections to the app? I have just dipped my toe into this stuff so an feedback would be appreciated.
  
  **Tags:** containers, docker-swarm
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-02-24. Score: 1
  
  In general: No you can't. At least not on the Docker level.
  
  You can maybe code your app in a way that it monitors such metrics and adjusts itself but Docker isn't able to.
  
  What Docker CAN do is limit the app to 50% and kill it if it uses more than that by utilizing resource limits:
  
  [docs.docker.com - containers/resource\_constraints](https://docs.docker.com/config/containers/resource_constraints/)
  
  [docs.docker.com - docker-compose resource limits](https://docs.docker.com/compose/compose-file/compose-file-v3/#resources)
  
  
  ---
  
  