Skip to content

Commit

Permalink
limit cpu usage of containers
Browse files Browse the repository at this point in the history
  • Loading branch information
srujangit123 committed Dec 26, 2024
1 parent 11185f7 commit 66f2df2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ This repository contains a remote code execution engine that allows users to sub
- Supports both `x86_64` and `arm64` architecture machines.
- Cleans up zombie containers to avoid memory leaks.
- Provides a REST API for code submission and execution.
- Restricts the usage of system resources (Memory, CPU, max processes, max files, max file size)
- Kills a container if it is taking more than a minute to complete the execution.
- Supports custom docker images and compilation commands for each programming language.

## Prerequisites
Expand Down
3 changes: 2 additions & 1 deletion pkg/container/dockerclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ func (d *dockerClient) ExecuteCode(ctx context.Context, code *Code) (string, err
// Set the memory limit to 1GB
Resources: container.Resources{
// set 500 MB as the memory limit in bytes
Memory: 500 * 1024 * 1024,
Memory: 500 * 1024 * 1024,
NanoCPUs: 500000000, // 0.5 CPU
Ulimits: []*units.Ulimit{
{
Name: "nproc",
Expand Down

0 comments on commit 66f2df2

Please sign in to comment.