containerd / cgroups

cgroups package for Go
https://containerd.io
Apache License 2.0
1.09k stars 236 forks source link

Unable to control #186

Open uppercaveman opened 3 years ago

uppercaveman commented 3 years ago

!/bin/sh

echo "start" echo "scale=50000; 4*a(1)" | bc -l -q echo "end"

When executing shell scripts, "bc -l -q" is always 100% image

Is the child process out of control?

uppercaveman commented 3 years ago

env : CentOS Linux release 7.8.2003 (Core)

yogihardi commented 3 years ago

hi @uppercaveman ,

i am not sure if our case are similar, but, i am able to limit the cpu usage by setting the Quota and Period (https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/resource_management_guide/sec-cpu)

    shares := uint64(256) 
    quota := int64(500000) // 50% of CPU (quota/period)
    period := uint64(1000000)

    cgroupPath := cgroups.StaticPath("/test")
    pCGroup, err := cgroups.New(cgroups.V1, cgroupPath, &specs.LinuxResources{
        CPU: &specs.LinuxCPU{
            Shares: &shares,
            Quota:  &quota,
            Period: &period,
        },
    })