Actual requestes ressources (CPU, RAM) from a container group

Moritz 0 Reputation points
2023-03-08T17:14:26.8166667+00:00

Hi,

i want to deploy a container group with multiple containers using a yaml file.

My yaml-file looks like this:

apiVersion: '2022-09-01'
location: germanywestcentral
name: X
type: Microsoft.ContainerInstance/containerGroups
properties:
  restartPolicy: Always
  imageRegistryCredentials:
  - server: X
    username: X
    password: X
    identityUrl: X
  containers:
  - name: X-1
    properties:
      image: X:latest
      environmentVariables:
        - name: X
          value: X
      resources:
        requests:
          cpu: 1
          memoryInGb: 0.4
        limits:
          cpu: 1
          memoryInGb: 0.6
  - name: X-2
    properties:
      image: X:latest
      environmentVariables:
        - name: X
          value: X
      resources:
        requests:
          cpu: 1
          memoryInGb: 0.4
        limits:
          cpu: 1
          memoryInGb: 0.6
  osType: Linux

What does resources-requests and -limits mean?

Is it like "this container needs one CPU Core" and the other one needs one CPU Core too? So i have 2 cores for the group?

Because i dont need 2 cores for both, i just need one core shared by these two containers.

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
758 questions
Azure
Azure
A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.
1,483 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Manu Philip 20,211 Reputation points MVP Volunteer Moderator
    2023-03-08T17:55:56.5133333+00:00

    requests define a set amount of CPU that the pod needs regularly.

    limits set the maximum amount of CPU that a pod can use.

    If you wish to limit the cpu for all the pods, you may need to limit at the name space level. Below tutorial helps on define at the limit and requests at the name space level

    https://jamesdefabia.github.io/docs/admin/limitrange/


    --please don't forget to upvote and Accept as answer if the reply is helpful--

    0 comments No comments

  2. vipullag-MSFT 26,492 Reputation points Moderator
    2023-03-09T03:57:19.8866667+00:00

    Hello Moritz

    Welcome to Microsoft Q&A Platform, thanks for posting your query here.

    Adding to previous response of Manu, In the YAML file you shared, resources-requests and resources-limits are used to specify the minimum and maximum amount of CPU and memory resources that each container in the container group requires.
    resources-requests specify the minimum amount of resources that a container requires to run properly. In your example, each container requires 1 CPU core and 0.4 GB of memory.

    resources-limits specify the maximum amount of resources that a container is allowed to use. In your example, each container can use up to 1 CPU core and 0.6 GB of memory.
    The requests and limits are used by the container orchestrator to schedule containers on a suitable host that can meet their resource requirements. If a container requires more resources than specified in its limits, it may be terminated or restricted by the container orchestrator to prevent it from overusing the host resources.

    In your case, if you want to share the same CPU core between the two containers, you can reduce the CPU request and limit for each container to 0.5 instead of 1. This way, the total CPU required by both containers would be 1, and they can share the same CPU core.

    Hope this helps.

    If the suggested response helped you resolve your issue, please 'Accept as answer', so that it can help others in the community looking for help on similar topics.

    0 comments No comments

  3. Eddie Neto 1,251 Reputation points Microsoft Employee
    2023-03-09T08:56:00.1266667+00:00

    Hi @Moritz

    Thanks for reaching Microsoft Q&A

    The difference is below:

    Requests: defines requests as a guaranteed minimum amount of a resource to be used by a container.

    Limits: defines limits as a maximum amount of a resource to be used by a container.

    Hope this helps. Please "Accept as Answer" if it helped, so that it can help others in the community looking for help on similar topics.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.