
내 systemd 서비스에 대해 몇 가지 제한을 설정하고 싶습니다. 예를 들면 다음과 같습니다.
- 네트워크 대역폭
- CPU 견적
제한을 초과하면 systemd 서비스가 중지되어야 합니다.
미리 감사드립니다
답변1
바라보다man systemd.exec
:
PROCESS PROPERTIES
LimitCPU=, LimitFSIZE=, LimitDATA=, LimitSTACK=, LimitCORE=, LimitRSS=, LimitNOFILE=, LimitAS=,
LimitNPROC=, LimitMEMLOCK=, LimitLOCKS=, LimitSIGPENDING=, LimitMSGQUEUE=, LimitNICE=,
LimitRTPRIO=, LimitRTTIME=
Set soft and hard limits on various resources for executed processes. See setrlimit(2) for
details on the resource limit concept. Resource limits may be specified in two formats:
either as single value to set a specific soft and hard limit to the same value, or as
colon-separated pair soft:hard to set both limits individually (e.g. "LimitAS=4G:16G").
Use the string infinity to configure no limit on a specific resource. The multiplicative
suffixes K, M, G, T, P and E (to the base 1024) may be used for resource limits measured in
bytes (e.g. "LimitAS=16G"). For the limits referring to time values, the usual time units
ms, s, min, h and so on may be used (see systemd.time(7) for details). Note that if no time
unit is specified for LimitCPU= the default unit of seconds is implied, while for
LimitRTTIME= the default unit of microseconds is implied. Also, note that the effective
granularity of the limits might influence their enforcement. For example, time limits
specified for LimitCPU= will be rounded up implicitly to multiples of 1s. For LimitNICE=
the value may be specified in two syntaxes: if prefixed with "+" or "-", the value is
understood as regular Linux nice value in the range -20..19. If not prefixed like this the
value is understood as raw resource limit parameter in the range 0..40 (with 0 being
equivalent to 1).
대역폭의 경우 다음에서 여러 옵션을 정의할 수 있습니다.man systemd.resource-control
. .service
, .socket
, .slice
, .scope
, .swap
, 또는 .mount
단위는 다음 중 하나를 사용할 수 있습니다.
IOWeight=weight, StartupIOWeight=weight
Set the default overall block I/O weight for the executed processes, if the
unified control group hierarchy is used on the system. ...
kernel.org에 따르면IO 인터페이스 파일
가중치 범위는 [1, 10000]이며 cgroup이 형제 그룹과 비교하여 사용할 수 있는 상대적인 IO 시간을 지정합니다.
IOReadBandwidthMax=device bytes, IOWriteBandwidthMax=device bytes
Set the per-device overall block I/O bandwidth maximum limit for the executed
processes, if the unified control group hierarchy is used on the system. This
limit is not work-conserving and the executed processes are not allowed to use
more even if the device has idle capacity. ...
IOReadIOPSMax=device IOPS, IOWriteIOPSMax=device IOPS
Set the per-device overall block I/O IOs-Per-Second maximum limit for the
executed processes, if the unified control group hierarchy is used on the
system. This limit is not work-conserving and the executed processes are not
allowed to use more even if the device has idle capacity. ...