Postgres Kubernetes 성능 측정
VM 기반 Postgres 환경에서 성능 이슈가 있다고 하여, Kubernetes 환경에서 성능 측정을 하였다. Kubernetes 환경은 1) Bare-metal 기반 NVMe Platform (Diamanti 제품 이용) 2) VM 기반 SSD/HDD (Nutanix Hybrid Disk)을 사용하였고 서로 성능을 비교 하였다.
성능 측정 결과, Bare-metal NVMe 기반 Diamanti가 VM+SSD/HDD에 비하여 약 4배 (latency 4.7 ms vs 21.5 ms, TPS 3400 vs 743) 정도 빨랐다.
상세 측정 로그는 아래와 같다. (1 Primary + 2 Read Replica 구성)
Diamanti : Bare-metal NVMe
I have no name!@postgres-postgresql-primary-0:/$ PGPASSWORD=postgres pgbench -h localhost -p 5432 -U postgres -c 16 -j 2 -T 300 -s 600 pgbenchtestscale option ignored, using count from pgbench_branches table (600)starting vacuum...end.transaction type: <builtin: TPC-B (sort of)>scaling factor: 600query mode: simplenumber of clients: 16number of threads: 2duration: 300 snumber of transactions actually processed: 1020035latency average = 4.706 mstps = 3400.090313 (including connections establishing)tps = 3400.160804 (excluding connections establishing)
Nutanix : VM SSD/HDD Hybrid Disk
I have no name!@postgres-postgresql-primary-0:/$ PGPASSWORD=postgres pgbench -h localhost -p 5432 -U postgres -c 16 -j 2 -T 300 -s 600 pgbenchtestscale option ignored, using count from pgbench_branches table (600)starting vacuum...end.transaction type: <builtin: TPC-B (sort of)>scaling factor: 600query mode: simplenumber of clients: 16number of threads: 2duration: 300 snumber of transactions actually processed: 223131latency average = 21.514 mstps = 743.703647 (including connections establishing)tps = 743.716684 (excluding connections establishing)
POD는 둘 다 Resource Limits 설정하지 않았다. 실제 Benchmark 실행 시 CPU는 1 Core 미만, Memory 1.2G 미만만 아주 작게 사용하여서 cpu, memory 스펙은 별 관련이 없었다.
VM의 경우 초기 설치 시 Memory를 설정하면 OS에서 Memory를 잡고 떠서 실제 Postgres가 사용하는 메모리 사용과 상관없이 메모리를 소비한다. 하지만 컨테이너의 경우 실제 Postgres DB가 메모리를 사용한만큼만 사용하므로 메모리를 절감 할 수 있다. 예를 들어 하드웨어 1개 Node 당 Postgres VM이 2~3개 정도 올릴 수 있다면 컨테이너는 10개 이상 가능하다.(실제 모 그룹 운영 중) 이는 노드 당 Postgres POD를 여러 개 (최소 10개 이상) 실행 가능한 것으로 기존 VM 기반에 비하여 Application 집적도가 높아 비용 절감이 가능하다.
그리고 Postgres Kubernetes 설치 역시 Bitnami Helm 기반으로 쉽게 가능하다. (HA 구성 가능)
참고
Diamanti & Nutanix CPU 비교
E5–2630 v4 @ 2.20GHz vs CPU E5–2670 0 @ 2.60GHz
두 개 구성 모두 Local PV(Persistent Volume) 환경이다.