trafficserver icon indicating copy to clipboard operation
trafficserver copied to clipboard

ATS memory continuous increase caused by free list

Open dboyzhong opened this issue 4 years ago • 7 comments

ATS memory much larger than expected(how to sloved?)

env

  • CPU: 64 core
  • memory :256G
  • OS: CentOS
  • ATS Version: 8.1.3

ATS configuration

  • ram_cache: 100G

what happended

  • memory cost upto 200G even ram_cache only configured 100G: image

why?

  • the freelist held by ioBufAllocator alloc too much memory and never free, the memory dump below: image

  • It is an known issue that freelist[i] (i from 0 ~ 14) maybe "in use" and cost memory then "not use" but never return memory to OS, example below has a maxim memory twice then expeceted, and if 100G ram_cache, the worse case, it will exhaust 15 * 100G = 1500 G memory: image

  • i know the reclaimable-free-list has been introduced in ATS 4.0.x to solve the problem but then removed,i want to know how to solve this issue in alternatively?

dboyzhong avatar Oct 25 '22 06:10 dboyzhong

Have you tried turning off freelist? This is how we are running ATS in production:

-bash-4.2$ grep binary records.config
CONFIG proxy.config.proxy_binary_opts STRING -M -f -F

Documentation on the options: https://docs.trafficserver.apache.org/appendices/command-line/traffic_server.en.html#traffic-server

bryancall avatar Oct 26 '22 16:10 bryancall

While -f will return memory allocated back to the OS, it will also greatly increase the number of malloc, free and (sometimes most importantly) madvise calls. On a high transaction server, this can have an impact on performance. If you run with the -f option, I recommend that you configure jemalloc or mimalloc as well as they have their own internal freelists that will return memory to the OS eventually. The -F option doesn't apply to ioBufAllocator as these are not proxy allocated.

cmcfarlen avatar Oct 26 '22 20:10 cmcfarlen

Have you tried turning off freelist? This is how we are running ATS in production:

-bash-4.2$ grep binary records.config
CONFIG proxy.config.proxy_binary_opts STRING -M -f -F

Documentation on the options: https://docs.trafficserver.apache.org/appendices/command-line/traffic_server.en.html#traffic-server

thanks for your suggestion, i will try to turn off free list and using jemalloc to instead of free list

dboyzhong avatar Oct 27 '22 02:10 dboyzhong

While -f will return memory allocated back to the OS, it will also greatly increase the number of malloc, free and (sometimes most importantly) madvise calls. On a high transaction server, this can have an impact on performance. If you run with the -f option, I recommend that you configure jemalloc or mimalloc as well as they have their own internal freelists that will return memory to the OS eventually. The -F option doesn't apply to ioBufAllocator as these are not proxy allocated.

i will configure jemalloc, thanks

dboyzhong avatar Oct 27 '22 02:10 dboyzhong

While -f will return memory allocated back to the OS, it will also greatly increase the number of malloc, free and (sometimes most importantly) madvise calls. On a high transaction server, this can have an impact on performance. If you run with the -f option, I recommend that you configure jemalloc or mimalloc as well as they have their own internal freelists that will return memory to the OS eventually. The -F option doesn't apply to ioBufAllocator as these are not proxy allocated.

i will configure jemalloc, thanks

dboyzhong avatar Oct 27 '22 02:10 dboyzhong

the reclaimable-free-list has been introduced in ATS 4.0.x, then remove the feature in ATS 5.0.x, i want to know whether the "buddy allocation scheme" still be considered ? image

dboyzhong avatar Oct 27 '22 02:10 dboyzhong

@dboyzhong I'm facing the same set of problems you are regarding RAM consumption by TrafficServer. Could you please tell me how you've enabled Jemalloc with the systemd setup? I already have an ATS build compiled with Jemalloc support, any help would be appreciated. Thanks.

dhairav avatar May 30 '23 09:05 dhairav