Skip to content

Commit b507329

Browse files
authored
[POA-2944] Add agent cpu and memory limits when running on ec2 (#94)
Adds CPU and Memory limits to the postman insights service file. Summary: - Agent process CPU time will be prioritized lower than other services. - Agent process will be restricted to 85% of a single CPU core. - Agent process will be throttled by the OS if it exceeds 750MB of memory. - Agent process will be OOM Killed if it exceeds 1GB of memory. - Agent process will be restarted on failure.
1 parent 446d064 commit b507329

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cmd/internal/ec2/postman-insights-agent.service.tmpl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,18 @@ EnvironmentFile=/etc/default/postman-insights-agent
1010
# Reference: https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines
1111
ExecStart={{.AgentInstallPath}} apidump --project "${PROJECT_ID}" --interfaces "${INTERFACES}" --filter "${FILTER}" {{.ExtraApidumpArgs}} $EXTRA_APIDUMP_ARGS
1212

13+
# CPU resource controls
14+
CPUWeight=90 # lower relative CPU priority; default is 100. In case of contention main process will be prioritized.
15+
CPUQuota=50% # aboslute CPU time limit (85% of CPU core). Process won't be able to take advantage of multi core.
16+
17+
# Memory resource controls
18+
MemoryHigh=750M # requested limit
19+
MemoryMax=1G # hard limit that triggers OOM kill if exceeded
20+
21+
# Restart on OOMs
22+
Restart=on-failure
23+
RestartSec=10s
24+
25+
1326
[Install]
1427
WantedBy=multi-user.target

0 commit comments

Comments
 (0)