[Varnish] Unit uses MemoryLimit=; please use MemoryMax= instead.

# systemctl status varnish
● varnish.service - Varnish Cache, a high-performance HTTP accelerator
Loaded: loaded (/etc/systemd/system/varnish.service; enabled; preset: disabled)
Active: active (running) since Thu 2024-02-08 02:10:12 UTC; 9min ago
Main PID: 10482 (varnishd)
Tasks: 217
Memory: 94.8M (limit 100.0M)
CPU: 707ms
CGroup: /system.slice/varnish.service
├─10482 /usr/sbin/varnishd -a :6081 -a localhost:8443,PROXY -f /etc/varnish/default.vcl -P /run/varnish/varnishd.pid -s file,/var/lib/varnish/storage,1G
└─10494 /usr/sbin/varnishd -a :6081 -a localhost:8443,PROXY -f /etc/varnish/default.vcl -P /run/varnish/varnishd.pid -s file,/var/lib/varnish/storage,1G

Feb 08 02:10:11 test_server systemd[1]: Starting Varnish Cache, a high-performance HTTP accelerator...
Feb 08 02:10:12 test_server varnishd[10482]: Version: varnish-7.4.2 revision cd1d10ab53a6f6115b2b4f3b2a1da94c1f749f80
Feb 08 02:10:12 test_server varnishd[10482]: Platform: Linux,5.14.0-412.el9.x86_64,x86_64,-junix,-sfile,-sdefault,-hcritbit
Feb 08 02:10:12 test_server varnishd[10482]: Child (10494) Started
Feb 08 02:10:12 test_server varnishd[10482]: Child launched OK
Feb 08 02:10:12 test_server varnishd[10482]: Child (10494) said Child starts
Feb 08 02:10:12 test_server varnishd[10482]: Child (10494) said SMF.s0 mmap'ed 1073741824 bytes of 1073741824
Feb 08 02:10:12 test_server systemd[1]: Started Varnish Cache, a high-performance HTTP accelerator.
Feb 08 02:10:26 test_server systemd[1]: /etc/systemd/system/varnish.service:19: Unit uses MemoryLimit=; please use MemoryMax= instead. Support for MemoryLimit= will be removed soon.

  위는 "systemctl status varnish"로 본 varnish 실행 상태이다.

  MemoryLimit와 MemoryMax는 Varnish 캐시의 프로세스(cache-main)에서 쓰는 최대 메모리를 조절할 수 있는 매개변수이다. MemoryLimit는 나중에 없어질 수 있으니 쓰지 말고 MemoryMax를 쓰라는 경고문이다.

  이 매개변수들을 넣을 수 있는 기본 상태의 환경설정 파일은 아래 경로에 있다.

  • /usr/lib/systemd/system/varnish.service
  • /lib/systemd/system/varnish.service
[Unit]
Description=Varnish Cache, a high-performance HTTP accelerator
After=network-online.target nss-lookup.target

[Service]
Type=forking
KillMode=mixed

# Maximum number of open files (for ulimit -n)
LimitNOFILE=131072

# Shared memory (VSM) segments are tentatively locked in memory. The
# default value for vsl_space (or shorthand varnishd -l option) is 80MB.
# There are other types of segments that would benefit from allowing
# more memory to be locked.
LimitMEMLOCK=100M

# Enable this to avoid "fork failed" on reload.
TasksMax=infinity

# Maximum size of the corefile.
LimitCORE=infinity

# A PID file makes the main process selection deterministic.
RuntimeDirectory=%N
PIDFile=%t/%N/varnishd.pid

ExecStart=/usr/sbin/varnishd \
-a :6081 \
-a localhost:8443,PROXY \
-f /etc/varnish/default.vcl \
-P %t/%N/varnishd.pid \
-p feature=+http2 \
-s malloc,256m
ExecReload=/usr/sbin/varnishreload

[Install]
WantedBy=multi-user.target

  위의 파일 내용에 아래처럼 MemoryMax 등을 끼워 넣거나 고쳐서 varnish를 쓸 수 있다.

[Unit]
Description=Varnish Cache, a high-performance HTTP accelerator
After=network-online.target nss-lookup.target

[Service]
Type=forking
KillMode=mixed

# Maximum number of open files (for ulimit -n)
LimitNOFILE=131072

# Shared memory (VSM) segments are tentatively locked in memory. The
# default value for vsl_space (or shorthand varnishd -l option) is 80MB.
# There are other types of segments that would benefit from allowing
# more memory to be locked.
#LimitMEMLOCK=100M
LimitMEMLOCK=82000

#MemoryLimit=100M
MemoryMax=100M

# Enable this to avoid "fork failed" on reload.
TasksMax=infinity

# Maximum size of the corefile.
LimitCORE=infinity

# A PID file makes the main process selection deterministic.
RuntimeDirectory=%N
PIDFile=%t/%N/varnishd.pid

ExecStart=/usr/sbin/varnishd \
-a :6081 \
-a localhost:8443,PROXY \
-f /etc/varnish/default.vcl \
-P %t/%N/varnishd.pid \
-p feature=+http2 \
-s file,/var/lib/varnish/storage,1G
ExecReload=/usr/sbin/varnishreload

[Install]
WantedBy=multi-user.target

  새로 적용시키는 설정 내용은 /etc/systemd/system/varnish.service 파일을 따른다. 아래 명령으로 편집하면 varnish를 다시 시작하지 않고 바꾸거나 새로 넣은 매개변수 설정 내용을 바로 적용시킬 수 있다.

# systemctl edit --full varnish
# systemctl status varnish
● varnish.service - Varnish Cache, a high-performance HTTP accelerator
Loaded: loaded (/etc/systemd/system/varnish.service; enabled; preset: disabled)
Active: active (running) since Thu 2024-02-08 02:10:12 UTC; 9min ago
Main PID: 10482 (varnishd)
Tasks: 217
Memory: 93.9M (max: 100.0M available: 6.0M)
CPU: 938ms
CGroup: /system.slice/varnish.service
├─10482 /usr/sbin/varnishd -a :6081 -a localhost:8443,PROXY -f /etc/varnish/default.vcl -P /run/varnish/varnishd.pid -s file,/var/lib/varnish/storage,1G
└─10494 /usr/sbin/varnishd -a :6081 -a localhost:8443,PROXY -f /etc/varnish/default.vcl -P /run/varnish/varnishd.pid -s file,/var/lib/varnish/storage,1G

Feb 08 02:10:11 test_server systemd[1]: Starting Varnish Cache, a high-performance HTTP accelerator...
Feb 08 02:10:12 test_server varnishd[10482]: Version: varnish-7.4.2 revision cd1d10ab53a6f6115b2b4f3b2a1da94c1f749f80
Feb 08 02:10:12 test_server varnishd[10482]: Platform: Linux,5.14.0-412.el9.x86_64,x86_64,-junix,-sfile,-sdefault,-hcritbit
Feb 08 02:10:12 test_server varnishd[10482]: Child (10494) Started
Feb 08 02:10:12 test_server varnishd[10482]: Child launched OK
Feb 08 02:10:12 test_server varnishd[10482]: Child (10494) said Child starts
Feb 08 02:10:12 test_server varnishd[10482]: Child (10494) said SMF.s0 mmap'ed 1073741824 bytes of 1073741824
Feb 08 02:10:12 test_server systemd[1]: Started Varnish Cache, a high-performance HTTP accelerator.
Feb 08 02:10:26 test_server systemd[1]: /etc/systemd/system/varnish.service:19: Unit uses MemoryLimit=; please use MemoryMax= instead. Support for MemoryLimit= will be removed soon.

  Memory 항목에서 "limit 100.0MB"로 나오던 것이 "max: 100.0M available: 6.0M"과 같은 형식으로 바뀌어 나오는 것을 볼 수 있다.

※ 참고한 곳

2024/02/08 11:58 2024/02/08 11:58
글 걸기 주소 : 이 글에는 글을 걸 수 없습니다.

덧글을 달아 주세요