커넥션 풀(Connection Pool) 관리

개요

OpenProxy의 Connection Pooling 기능과 openproxy.toml 설정파일을 변경하여 구성하는 방법에 대하여 기술합니다.

Connection Pool 정의

Connection Pool 을 정의하여 접근할 PostgreSQL 데이터베이스 및 사용자 설정을 관리합니다.

Connection Pool 기본 설정

  • openproxy.toml 에 [pools.simple_db] 섹션 작성합니다.

    [pools.simple_db]
    pool_mode = "session"
    query_parser_enabled = true
    query_parser_read_write_splitting = true
    primary_reads_enabled = true
    sharding_function = "pg_bigint_hash"

Connection Pool 사용자 정보 설정

  • openproxy.toml 에 [pools.simple_db.users.0] 섹션 작성합니다.

    [pools.simple_db.users.0]
    username = "simple_user"
    password = "simple_user"
    pool_size = 5
    statement_timeout = 30000

접속할 cluster 주소 및 database 기재

  • openproxy.toml 에 [pools.simple_db.shard.0] 섹션 작성합니다.

simple_db connection pool 생성 설정 파일 전체 예시


OpenProxy 실행

생성할 connection pool 을 설정한 openproxy.toml 파일로 OpenProxy 를 수행합니다.


Connection Pool 확인

psql -h 127.0.0.1 -p 6432 -d openproxy -U postgres 명령어를 사용하여 생성된 Connection Pool을 확인합니다.

Last updated