提问人:Tinyden 提问时间:11/20/2022 更新时间:11/20/2022 访问量:245
Grpc 服务无法在 kubernetes pod 中分配内存
Grpc service fails to allocate memory within kubernetes pod
问:
我在 kubernetes 上部署了一个 grpc 服务,所有内存分配都通过 tcmalloc 进行。我经常在 pod 中发现内存不足问题。
Stacktrace 在这里:
terminate called after throwing an instance of 'std::length_error'
what(): basic_string::_M_create
*** Aborted at 1668932192 (unix time) try "date -d @1668932192" if you are using GNU date ***
PC: @ 0x0 (unknown)
*** SIGABRT (@0x1) received by PID 1 (TID 0x7f2e45bd3700) from PID 1; stack trace: ***
@ 0x7f2e4c7d63c0 (unknown)
@ 0x7f2e4c4a918b gsignal
@ 0x7f2e4c488859 abort
@ 0x7f2e4c8a1951 (unknown)
@ 0x7f2e4c8ad47c (unknown)
@ 0x7f2e4c8ad4e7 std::terminate()
@ 0x7f2e4c8ad799 __cxa_throw
@ 0x7f2e4c8a4366 std::__throw_length_error()
@ 0x7f2e4c9459fc std::__cxx11::basic_string<>::_M_create()
@ 0x561821534960 __gnu_cxx::new_allocator<>::construct<>()
@ 0x56182153390b metrics::ReadReporter::Report()
@ 0x56182125cb54 std::_Function_handler<>::_M_invoke()
@ 0x56182151f2aa std::_Function_handler<>::_M_invoke()
@ 0x56182154092e std::_Function_handler<>::_M_invoke()
@ 0x56182153f5e5 file::HttpRequest::Invoke()
@ 0x7f2e4c8d9d84 (unknown)
@ 0x7f2e4c7ca609 start_thread
@ 0x7f2e4c585293 clone
@ 0x0 (unknown)
terminate called recursively
terminate called recursively
external/com_google_tcmalloc/tcmalloc/tcmalloc_policy.h:102] Unable to allocate (new failed) 8111000728417 @ 0x561822037742 0x56182200fc67 0x561822003b0f 0x561821534960 0x56182153390b 0x56182125cb54 0x56182125d10a 0x56182151f2aa 0x56182154092e 0x56182153f5e5 0x561821545432 0x7f2e4c8d9d84
See https://github.com/google/tcmalloc/tree/master/docs/stats.md for an explanation of this page
我已为该服务注册了就绪情况和活动性探测。它只是一个线程侦听和响应 TCP。
我的困惑是:
- 为什么 pod 不会作为 OOM 失败(因为 SIGABRT 已被抛出,正如您在堆栈跟踪中看到的那样),并且将由 Kubernetes 重新启动?
- 我知道也许我可以向容器添加更多内存分配,并添加速率限制器来解决此问题,但想知道这是解决此问题的最佳实践吗?
答: 暂无答案
评论
kubectl get pod
kill