记忆正在泄漏Docker中的Postgres
我为公司服务进行负载测试。 撰写版本:Docker撰写版本v2.4.1
我对DB的组合:
version: '3.4'
x-check: &default-healthcheck
healthcheck:
test: [ "CMD", "/data/.prepare" ]
interval: 30s
timeout: 30s
services:
postgres-api:
image: postgres:11
container_name: 'load-POSTGRES-API'
restart: unless-stopped
environment:
- POSTGRES_USER=test
- POSTGRES_PASSWORD=test
command: [
"postgres",
"-c",
"log_statement=all",
"-c",
"log_destination=stderr",
"-c",
"max_connections=50",
"-c",
"shared_buffers=1GB",
"-c",
"effective_cache_size=4GB",
"-c",
"work_mem=16MB",
"-c",
"maintenance_work_mem=512MB",
"-c",
"random_page_cost=1.1",
"-c",
"temp_file_limit=10GB",
"-c",
"log_min_duration_statement=200ms",
"-c",
"idle_in_transaction_session_timeout=10s",
"-c",
"lock_timeout=1s",
"-c",
"statement_timeout=60s",
"-c",
"shared_preload_libraries=pg_stat_statements",
"-c",
"pg_stat_statements.max=10000",
"-c",
"pg_stat_statements.track=all"
]
ports:
- "${EXT_IP}:${POSTGRES_EXPOSE_API}"
volumes:
- ./postgres-l3/data:/data:rw
deploy:
resources:
limits:
cpus: '1'
memory: 4G
reservations:
memory: 256M
<<: *default-healthcheck
分配的内存持续5-10分钟(取决于负载),然后发生溢出,服务不会连接到数据库,我观察到错误:
"message":"the database system is in recovery mode"
连接丢失了,清除了数据库内存和数据库内存开始迅速融化。 所有桌子的大小为〜50MB。
如何解决?它的正常程度如何?
I make loading testing for companies service.
Compose version: Docker Compose version v2.4.1
My compose for DB:
version: '3.4'
x-check: &default-healthcheck
healthcheck:
test: [ "CMD", "/data/.prepare" ]
interval: 30s
timeout: 30s
services:
postgres-api:
image: postgres:11
container_name: 'load-POSTGRES-API'
restart: unless-stopped
environment:
- POSTGRES_USER=test
- POSTGRES_PASSWORD=test
command: [
"postgres",
"-c",
"log_statement=all",
"-c",
"log_destination=stderr",
"-c",
"max_connections=50",
"-c",
"shared_buffers=1GB",
"-c",
"effective_cache_size=4GB",
"-c",
"work_mem=16MB",
"-c",
"maintenance_work_mem=512MB",
"-c",
"random_page_cost=1.1",
"-c",
"temp_file_limit=10GB",
"-c",
"log_min_duration_statement=200ms",
"-c",
"idle_in_transaction_session_timeout=10s",
"-c",
"lock_timeout=1s",
"-c",
"statement_timeout=60s",
"-c",
"shared_preload_libraries=pg_stat_statements",
"-c",
"pg_stat_statements.max=10000",
"-c",
"pg_stat_statements.track=all"
]
ports:
- "${EXT_IP}:${POSTGRES_EXPOSE_API}"
volumes:
- ./postgres-l3/data:/data:rw
deploy:
resources:
limits:
cpus: '1'
memory: 4G
reservations:
memory: 256M
<<: *default-healthcheck
The allocated memory lasts for 5-10 minutes (depending on the load), then an overflow occurs, the services will not connect to the database and I observe an error:
"message":"the database system is in recovery mode"
Connections are lost, the database memory is cleared and starts to melt quickly again.
The size of all tables is ~50Mb.
How can this be solved? How normal is it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论