清漆进程未关闭并占用大量内存
Varnish process not closed and taking huge memory
我们在 centos 服务器中使用 Varnish 缓存 4.1,当我们启动 Varnish 服务器时,许多 varnish 进程开始但没有关闭,由于这个问题我们面临内存泄漏问题,请告诉我们如何解决它
我的配置是:/etc/sysconfig/varnish
#DAEMON_OPTS="-a :80 \
# -T localhost:6082 \
# -f /etc/varnish/default.vcl \
# -S /etc/varnish/secret \
# -p thread_pools=8 \
# -p thread_pool_max=4000 \
# -p thread_pool_add_delay=1 \
# -p send_timeout=30 \
# -p listen_depth=4096 \
# -s malloc,2G"
backend default {
.host = "127.0.0.1";
.port = "8080";
.probe = {
.url = "/";
.interval = 5s;
.timeout = 1s;
.window = 5;
.threshold = 3;
}
}
34514 89208 83360 5 0.0 4.3 0:00.00 /usr/sbin/varnishd -a :80 -f /etc/varnish/default.vcl -T 127.0.0.1:6082 -t 120 -p 线程池min=50 -p t 1678 清漆 20 0 345M 89208 83360 S 0.0 4.3 0:00.03 /usr/sbin/varnishd -a :80 -f /etc/varnish/default.vcl -T 127.0.0.1:6082 -t 120 -p thread_pool_min=50 -p • 1679 清漆 20 0
您没有限制 space 临时对象。默认使用无限的 malloc(参见官方文档:https://www.varnish-cache.org/docs/4.0/users-guide/storage-backends.html#transient-storage)
根据我在您的消息中看到的情况,您没有使用参数 DAEMON_OPT
。
您的 varnishd.service 文件和 /etc/varnish/varnish.params 的内容是什么?
编辑
您的 init.d 脚本没有问题。它应该使用 /etc/sysconfig/varnish.
中的设置
清漆消耗了多少内存?
所有清漆线程都共享相同的存储空间(malloc 2G + Transient malloc 100M),因此它应该占用 2.1G 的存储空间。您需要为缓存中存储的每个对象添加平均 1KB 的开销,以获得使用的总内存。
我不认为你正在遭受内存泄漏,这个过程是正常的。您告诉清漆产生 50 个进程(使用 thread_pools
参数)所以它们是预期的。
我建议减少 thread_pools
的数量,您将其设置为 50。您应该可以将其减少到 2 到 8 之间,同时这将有助于增加thread_pool_max
到 5000 并将 thread_pool_min
设置为 1000。
我们是 运行 非常大的服务器,有 2 个池 * 1000-5000 个线程,没有问题。
我们在 centos 服务器中使用 Varnish 缓存 4.1,当我们启动 Varnish 服务器时,许多 varnish 进程开始但没有关闭,由于这个问题我们面临内存泄漏问题,请告诉我们如何解决它
我的配置是:/etc/sysconfig/varnish
#DAEMON_OPTS="-a :80 \
# -T localhost:6082 \
# -f /etc/varnish/default.vcl \
# -S /etc/varnish/secret \
# -p thread_pools=8 \
# -p thread_pool_max=4000 \
# -p thread_pool_add_delay=1 \
# -p send_timeout=30 \
# -p listen_depth=4096 \
# -s malloc,2G"
backend default {
.host = "127.0.0.1";
.port = "8080";
.probe = {
.url = "/";
.interval = 5s;
.timeout = 1s;
.window = 5;
.threshold = 3;
}
}
34514 89208 83360 5 0.0 4.3 0:00.00 /usr/sbin/varnishd -a :80 -f /etc/varnish/default.vcl -T 127.0.0.1:6082 -t 120 -p 线程池min=50 -p t 1678 清漆 20 0 345M 89208 83360 S 0.0 4.3 0:00.03 /usr/sbin/varnishd -a :80 -f /etc/varnish/default.vcl -T 127.0.0.1:6082 -t 120 -p thread_pool_min=50 -p • 1679 清漆 20 0
您没有限制 space 临时对象。默认使用无限的 malloc(参见官方文档:https://www.varnish-cache.org/docs/4.0/users-guide/storage-backends.html#transient-storage)
根据我在您的消息中看到的情况,您没有使用参数 DAEMON_OPT
。
您的 varnishd.service 文件和 /etc/varnish/varnish.params 的内容是什么?
编辑
您的 init.d 脚本没有问题。它应该使用 /etc/sysconfig/varnish.
中的设置
清漆消耗了多少内存?
所有清漆线程都共享相同的存储空间(malloc 2G + Transient malloc 100M),因此它应该占用 2.1G 的存储空间。您需要为缓存中存储的每个对象添加平均 1KB 的开销,以获得使用的总内存。
我不认为你正在遭受内存泄漏,这个过程是正常的。您告诉清漆产生 50 个进程(使用 thread_pools
参数)所以它们是预期的。
我建议减少 thread_pools
的数量,您将其设置为 50。您应该可以将其减少到 2 到 8 之间,同时这将有助于增加thread_pool_max
到 5000 并将 thread_pool_min
设置为 1000。
我们是 运行 非常大的服务器,有 2 个池 * 1000-5000 个线程,没有问题。