Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to limit the resources for each session #96

Open
chunhualiao opened this issue Nov 5, 2019 · 2 comments
Open

Need to limit the resources for each session #96

chunhualiao opened this issue Nov 5, 2019 · 2 comments

Comments

@chunhualiao
Copy link
Owner

right now all cpus and mem are used by each session

@chunhualiao
Copy link
Owner Author

We use 8 vCPU for the AWS instance. Less a problem for now. Ideally, we want to limit 4 vCPU for each session.

@ouankou
Copy link
Collaborator

ouankou commented Mar 31, 2020

This issue can be solved by adding the following code to the GO source code for the session configuration.

// set up the container memory limit to 600 MB
h.Resources.Memory = int64(600) * Megabyte
// set up the CPU time usage to 0.5 CPU, no matter how many CPUs the server has.
// for 4 CPU, the value should be 400000
h.Resources.CPUQuota = int64(50000)

We can hardcore the code above to replace the following section, such as 8GB memory and 2 or 4 CPU time.
https://github.com/freeCompilerCamp/play-with-compiler/blob/e0ce49d9b3930d16c6625612a9dabddb33fa2e12/docker/docker.go#L316-L321
We can use docker inspect <container_id/name> and docker stats <container_id/name> command to verify the resource limit of containers. However, inside the container, it still shows all the resources in the host, such as 32GB memory and 8 CPU on our AWS instance.

In the attached screenshot, you can see for the sandbox container created by PWC, the memory limit is 600MB and CPU limit is 0.5 CPU (50000 CPU Quota). Value 0 normally means no limit specified. The cloud server has 1GB memory and 1 CPU.
cpu_mem_limit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants