Name
Last commit
Last update
..
README.md numa, result init
numa_cpu_20220607.png numa, result modify

logo

NUMA Configuration STEP 2 (Result)

아래와 같이 NUMA preferred 정책을 통해 초도 적용을 하였으나, 기대와 다르게 CPU 사용률이 크게 증가하였다.

STEP 1, Issue 바로가기

따라서 다음의 추가 검토를 통해 튜닝을 수행 한다.

튜닝 수행 방향

  • RDBMS의 경우 일반적으로 특정 Core를 사용하도록 고안되었는데, InfluxDB는 왜 다른가?
  • TS(Time Series)DB의 경우 오픈 소스 개발사에서 특별한 가이드가 없는 상태
  • 그렇다면, 이제 남은 것은 SMP 구조와 같이 균등한 정책을 통해 수행할 경우 NUMA hit/miss가 어떻게 될 것인가?

튜닝 설정

  • [ STEP 1 ] numactl 명령을 통한 Application을 실행하기 위해, 다음과 같이 간단한 스크립트를 작성 한다.
# cat influxdb_control.sh
#!/bin/bash

if [[ $1 == "start" ]]; then
  numactl --interleave=all /usr/bin/influxd -config /etc/influxdb/influxdb.conf &
  PID=$!
  echo $PID > /var/lib/influxdb/influxdb.pid

elif [[ $1 == "stop" ]]; then
  PID=`cat /var/lib/influxdb/influxdb.pid`
  for var in {1..3}
  do
    kill -9 $PID
  done
  rm -rf /var/lib/influxdb/influxdb.pid

else
  echo
  echo "Requirement Args start | stop "
  echo

fi

핵심 : numactl --interleave=all /usr/bin/influxd -config /etc/influxdb/influxdb.conf &

추가적으로 현재 NUMA 관련 시스템 환경은 다음과 같다.

  • numad 데몬의 경우 다음과 같이 실행 중인 상태이다.
# ps -aef |grep numad |grep -v grep
root      13741      1  0 Jun05 ?        10:15:32 /usr/bin/numad -K1 -i 15

K 옵션의 경우 기본 값은 0인데, 1로 설정할 경우 Interleaved된 메모리를 유지하는 설정이다. 즉, Application에 Interleaved 메모리를 분산된 상태로 유지하기 위한 옵션 이다(man numad 명령).

  • Automatic NUMA Balancing의 경우 해제된 상태 이다.
# sysctl -a |grep kernel.numa_balancing
kernel.numa_balancing = 0
kernel.numa_balancing_scan_delay_ms = 1000
kernel.numa_balancing_scan_period_max_ms = 60000
kernel.numa_balancing_scan_period_min_ms = 1000
kernel.numa_balancing_scan_size_mb = 256
kernel.numa_balancing_settle_count = 4
sysctl: reading key "net.ipv6.conf.all.stable_secret"
sysctl: reading key "net.ipv6.conf.default.stable_secret"
sysctl: reading key "net.ipv6.conf.enp216s0f0.stable_secret"
sysctl: reading key "net.ipv6.conf.enp216s0f1.stable_secret"
sysctl: reading key "net.ipv6.conf.lo.stable_secret"

튜닝 수행 결과

  • [ numastat 명령 결과 ]
# numastat
                           node0           node1
numa_hit              6202902202      6131238910
numa_miss               41512969        22325238
numa_foreign            22325238        41512969
interleave_hit        6102825844      6090896613
local_node            1845654244      4392163282
other_node            4398760927      1761400866

노드별 메모리가 거의 균등하게 할당되고 있다.

  • [ InfluxDB 메모리 할당 결과 ]
# numastat -p influxdb

Per-node process memory usage (in MBs) for PID 9893 (influxd)
                           Node 0          Node 1           Total
                  --------------- --------------- ---------------
Huge                         0.00            0.00            0.00
Heap                         0.00            0.00            0.00
Stack                        0.01            0.00            0.02
Private                  36515.94        36122.12        72638.06
----------------  --------------- --------------- ---------------
Total                    36515.95        36122.12        72638.08

Application 프로세스의 메모리 할당도 거의 균등하게 할당되고 있다.

  • [ 노드별 메모리 현황 ]
# numastat -m

Per-node system memory usage (in MBs):
                          Node 0          Node 1           Total
                 --------------- --------------- ---------------
MemTotal                63901.10        64500.59       128401.69
MemFree                 14322.89        13495.20        27818.09
MemUsed                 49578.21        51005.39       100583.60
Active                  17766.52        21687.01        39453.52
Inactive                28945.37        25842.24        54787.61
Active(anon)             2783.99         2793.37         5577.36
Inactive(anon)           4995.22         4856.91         9852.13
Active(file)            14982.52        18893.64        33876.16
Inactive(file)          23950.15        20985.34        44935.48
Unevictable                 0.00            0.00            0.00
Mlocked                     0.00            0.00            0.00
Dirty                     147.17          147.18          294.36
Writeback                   0.00            0.00            0.00
FilePages               38942.92        39889.27        78832.19
Mapped                  28141.79        27916.30        56058.09
AnonPages                7770.86         7641.40        15412.27
Shmem                       8.36            8.88           17.24
KernelStack                 5.88            4.22           10.09
PageTables                109.07          107.90          216.97
NFS_Unstable                0.00            0.00            0.00
Bounce                      0.00            0.00            0.00
WritebackTmp                0.00            0.00            0.00
Slab                      869.02         1501.04         2370.06
SReclaimable              816.19         1437.17         2253.36
SUnreclaim                 52.83           63.87          116.70
AnonHugePages               0.00            0.00            0.00
HugePages_Total             0.00            0.00            0.00
HugePages_Free              0.00            0.00            0.00
HugePages_Surp              0.00            0.00            0.00
  • [ CPU 사용률 개선 결과 그래프 ]

numa_after_cpu

평시 Peak 사용률이 완만해진 것을 확인할 수 있다.