I have Postgres w/ timescale running inside a docker container with ~30 connections to it. I've been noticing that idle connections are using a lot of CPU resources. I'm wondering what would cause that to happen, AFAIK Postgres is pretty good at managing idle connections. If anyone has any recommendations on how to optimize this I would be really grateful!
Hardware specs: 8 CPU cores, 16GB RAM
Connections are all made using postgres.js with default settings
postgresql.conf
max_connections = 100
shared_buffers = 3997MB
work_mem = 5116kB
maintenance_work_mem = 1998MB
dynamic_shared_memory_type = posix
effective_io_concurrency = 256
max_work_processes = 27
max_parallel_workers_per_gather = 4
max_parallel_workers = 8
wal_buffers = 16MB
checkpoint_completion_target = 0.9
max_wal_size = 1GB
min_wal_size = 512MB
random_page_cost = 1.1
effective_cache_size = 11991MB
log_timezone = 'UTC'
autovacuum_max_workers = 10
autovacuum_naptime = 10
shared_preload_libraries = 'timescaledb,pg_stat_statements'
max_locks_per_transaction = 128
timescaledb.max_background_workers = 16
htop
| ID | USER | PRI | NI | VIRT | RES | SHR | S | CPU% | MEM% | TIME | Command |
|----|-----------|-----|----|-------|------|------|---|------|------|---------|-----------------------------------------------------|
| 14 | dockermod | 20 | 0 | 4230M | 130M | 106M | R | 86.8 | 0.8 | 2:57.60 | postgres: server jerviswebb 172.18.0.28(51524) idle |
| 24 | dockermod | 20 | 0 | 4228M | 121M | 101M | R | 86.2 | 0.8 | 1:27.86 | postgres: server jerviswebb 172.18.0.28(48178) idle |
| 99 | dockermod | 20 | 0 | 4224M | 127M | 103M | R | 74.2 | 0.8 | 0:37.44 | postgres: server jerviswebb 172.18.0.28(59758) idle |
| 78 | dockermod | 20 | 0 | 4232M | 125M | 100M | R | 67.3 | 0.8 | 2:05.81 | postgres: server jerviswebb 172.18.0.28(36496) idle |
| 72 | dockermod | 20 | 0 | 4224M | 129M | 105M | R | 65.4 | 0.8 | 1:24.65 | postgres: server jerviswebb 172.18.0.28(57110) idle |
Subreddit
Post Details
- Posted
- 4 months ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/PostgreSQL/...