사용자 도구

사이트 도구


database:aurora

Aurora - AWS Database

JDBC

aws-advanced-jdbc-wrapper - Read/Write Cluster

서버 설정

log

  • log_output=FILE, slow_query=1(true), long_query_time=1(1초) 등의 설정을 해서 슬로우 쿼리를 로그로 남긴다.
  • RDS Instance Modify 에서 Log Exports > Slow Query Log를 로그로 Cloud Watch로 전송한다.
  • Clow Watch 에서 RDS 이름으로 검색하면 볼 수 있고 알림도 걸 수 있다.

TimeZone

  • (접속을 클러스터로 하면) Cluster Parameter Group 에서, (접속을 인스턴스 단위로 하면) DB Parameter Group 에서 time_zone 값을 Asia/Seoul로 변경.
  • 적용 후에 접속해서 아래 값들 올바른 지 확인
    SELECT @@time_zone; -- Asia/Seoul
    SELECT NOW(); -- 현재 한국 시간

End Point

  • Aurora 는 cluster endpoint, readonly endpoint, instance endpoint 를 지원한다. readonly endpoint는 replicas 들 사이에서 load balancing도 해준다.
  • Cluster Endpoint는 자체적으로 Read/Write 모두에 대한 정보를 포함하고 있다. Aurora MariaDB JDBC 드라이버 사용시 Read/Write 분기가 가능하다. Cluster Endpoint로 접속한 경우 Master가 죽으면 자동으로 Slave를 Master로 승격하여 연결해준다.

Blocked Transaction

Performance

max_connections

Replica(reader instance) history list length 줄이기

  • READ Only / Reader Instance 로 접속한 경우 아래와 같이 커넥션 접속시 설정해주면 history length 가 줄어든다.
  • Aurora 는 writer/reader 인스턴스가 storage 를 공유하는데, 이 때 reader 쪽의 쿼리로 인해 history list length 가 증가하면 writer 쪽에도 성능 저하 영향을 주게 된다.
  • Aurora Replica 가 기본적으로 tx_isolation=REPEATABLE_READ 인 상태인데, MySQL의 mvcc 모델 특성상 REPEATABLE READ 상태에서 일관된 정보를 제공하려고 트랜잭션이 완료될 때 까지 변경 전 데이터를 저장하고, commit이 될 때까지 데이터를 유지한다. 따라서 long query 가 실행되면 변경전 데이터를 저장하는 기간이 계속 길어져 성능저하를 유발한다.
SET SESSION aurora_read_replica_read_committed = ON;
SET SESSION TRANSACTION isolation level READ committed;
  • aurora_read_replica_read_committed 는 connection 초기화 시에 해준다. 테스트 결과 이 설정값은 writer 에 할경우에는 아무런 효과가 발생하지 않으므로 reader/writer 구분없이 해줘도 된다.
  • set session transaction isolation level read committed는 Transaction 설정에서 해주면 될 것으로 보인다. 즉, readOnly=true 인 트랜잭션에 대해서 isolationLevel=READ_COMMITTED 를 하면 될 것으로 보인다.

Aurora for MySQL 8

비용 절감

참고

database/aurora.txt · 마지막으로 수정됨: 2023/11/17 10:14 저자 kwon37xi