Presto Memory
각 Memory Pool 에서 메모리를 할당한다. 무조건 General Pool에서 먼저 할당한다. 메모리의 종류는 2가지이다.
- user 메모리
- group by, join 등 쿼리에 따른 메모리이다.
- system 메모리
- input/output buffer 등에 대한 메모리이다.
Presto Memory Pool
headroom 메모리를 제외한 나머지 메모리(General, Reserved)가 Presto Worker가 실제 사용할 수 있는 메모리이다.
![](https://blog.kakaocdn.net/dn/dZHuho/btqFZzBvkj6/JoBSV3GzQEPTOTkd2hWbP1/img.png)
(1) General Pool
- 쿼리를 실행하면 General Pool에서 제일 먼저 메모리가 할당된다.
-
jvm 메모리 용량에서 headroom 메모리 용량을 뺀 나머지가 모두 General Pool 에 잡힌다.
- jvm - Reserved Pool - headroom
(2) Reserved Pool
- General Pool 할당 메모리를 초과하는 무거운 쿼리를 실행 할 때, 해당 쿼리를 Reserved Pool로 보낸다.
- 단 1개의 쿼리만 보낼 수 있다.
- 메모리 사용량이 제일 많은 쿼리부터 실행한다.
- query.max-total-memory-per-node (default = jvm * 0.3)
Reserved Pool을 사용하고 싶지 않다면, (General Pool 만 사용함) 아래 설정을 해준다.
experimental.reserved-pool-enabled = false
jvm 메모리 용량에서 headroom 메모리 용량을 뺀 나머지가 모두 General Pool 에 잡힌다.
![](https://blog.kakaocdn.net/dn/7lsT9/btqFYZubvZx/lJp4Mu9dOkq0W7Kh9vNnl0/img.png)
General Pool 만 사용하면 쿼리 동시성은 더 높아진다. Reserved Pool 에서는 1개의 쿼리만 실행 가능하므로.
그렇게 따지면 Reserved Pool 사용해서 좋은 점은 뭘까?
(3) heap headroom
- 해당 메모리 할당은 presto에서 추적되지 않는다.
- 용도가 뭘까?
- memory.heap-headroom-per-node (default = jvm * 0.3)
메모리 설정 주의사항
- query.max-memory-per-node <= query.max-total-memory-per-node
- query.max-memory-per-node 값이 query.max-total-memory-per-node에 포함된다.
- query.max-total-memory-per-node <= jvm - headroom
설정파일 (예시)
1) Reserved Pool 을 사용하는 경우
jvm.config (Coordinator & Worker)
-server
-Xmx4G
-XX:-UseBiasedLocking
-XX:+UseG1GC
-XX:+ExplicitGCInvokesConcurrent
-XX:+HeapDumpOnOutOfMemoryError
-XX:+UseGCOverheadLimit
-XX:+ExitOnOutOfMemoryError
-XX:ReservedCodeCacheSize=512M
config.properties (Coordinator)
coordinator=true
node-scheduler.include-coordinator=false
http-server.log.path=/var/log/presto/http-request.log
http-server.http.port=9080
discovery-server.enabled=true
discovery.uri=http://dss02.nexr.com:9080
http-server.authentication.type=PASSWORD
http-server.https.enabled=true
http-server.https.port=9443
http-server.https.keystore.path=/etc/presto/presto-keystore.jks
http-server.https.keystore.key=1prestosuperpass!
# Reserved Pool 메모리 할당 설정
query.max-total-memory-per-node = 1.8GB
config.properties (Coordinator)
coordinator=false
node-scheduler.include-coordinator=false
http-server.log.path=/var/log/presto/http-request.log
http-server.http.port=9080
discovery.uri=http://dss03.nexr.com:29080
# Reserved Pool 메모리 할당 설정
query.max-total-memory-per-node = 1.8GB
2) Reserved Pool 을 사용하지 않는 경우 (headroom을 제외한 나머지 메모리가 모두 General에 잡힘)
jvm.config (Coordinator & Worker)
-server
-Xmx4G
-XX:-UseBiasedLocking
-XX:+UseG1GC
-XX:+ExplicitGCInvokesConcurrent
-XX:+HeapDumpOnOutOfMemoryError
-XX:+UseGCOverheadLimit
-XX:+ExitOnOutOfMemoryError
-XX:ReservedCodeCacheSize=512M
config.properties (Coordinator)
coordinator=true
node-scheduler.include-coordinator=false
http-server.log.path=/var/log/presto/http-request.log
http-server.http.port=9080
discovery-server.enabled=true
discovery.uri=http://dss02.nexr.com:9080
http-server.authentication.type=PASSWORD
http-server.https.enabled=true
http-server.https.port=9443
http-server.https.keystore.path=/etc/presto/presto-keystore.jks
http-server.https.keystore.key=1prestosuperpass!
experimental.reserved-pool-enabled = false
config.properties (Coordinator)
coordinator=false
node-scheduler.include-coordinator=false
http-server.log.path=/var/log/presto/http-request.log
http-server.http.port=9080
discovery.uri=http://dss03.nexr.com:29080
experimental.reserved-pool-enabled = false
마치며
Presto worker 노드에 메모리를 할당할 때 Pool 개념이 있다는 걸 알게 되었다.
또한 user메모리, system 메모리가 용도별로 나뉘어져 있고 상황에 따라 튜닝을 해야겠다는 것을 배웠다. (user메모리는 query.max-memory-per-node 로 설정함)
참고링크
Memory Management in Presto ·
In a multi-tenant system like Presto careful memory management is required to keep the system stable and prevent individual queries from taking over all the resources. However, tracking the memory usage of data structures in an application (Presto) running
prestodb.io
Presto – Troubleshooting Query Exceeded Per-Node Total Memory Limit – resource_overcommit, query.max-total-memory-per-node,
I had a SQL query that failed on one of the Presto 0.208 clusters with the “Query exceeded per-node total memory” (com.facebook.presto.ExceededMemoryLimitException) error. How can you solve this problem? I will consider a few possible solutions, but fi
cloudsqale.com
'BigData 기술 > Hive,Presto,Trino' 카테고리의 다른 글
[Hive] export, import (127) | 2021.03.09 |
---|---|
Hive 트랜잭션 테이블 (Hive update, delete) (677) | 2021.01.03 |
IntelliJ에서 Presto Query 날리기 (2) | 2020.05.14 |
hive udf 등록하는 방법 (2) | 2019.11.28 |
Hive Metastore 종류 및 설정 (mysql/mariadb hive-metastore) (4) | 2019.10.18 |
댓글