Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tDih0-002jd7-FT for pgsql-general@arkaria.postgresql.org; Wed, 20 Nov 2024 11:16:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tDigy-004naG-NO for pgsql-general@arkaria.postgresql.org; Wed, 20 Nov 2024 11:16:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tDigy-004nZr-BZ for pgsql-general@lists.postgresql.org; Wed, 20 Nov 2024 11:16:16 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tDigv-002ujm-GG for pgsql-general@lists.postgresql.org; Wed, 20 Nov 2024 11:16:15 +0000 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a9a6b4ca29bso797122066b.3 for ; Wed, 20 Nov 2024 03:16:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732101371; x=1732706171; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=g+tOBiJdHrsDFQE0SIaz/xcAVpbptKV5QyZAWVIKa+0=; b=VFUQAT9nIO+/jUpDF4ryurRj2bqZKQ4hatbp9nYLROtEs1c8tcUjndBnp1OxtDs6lj VttZRnz17/DvRfW5mGawqFVoNgpRGztflXASZ8810/lxSr3rlj8ZN/4Gd/nro3qhpUYW Kov/2O4ROAKi9yBfpzbgRl9LlWaewSryF3Uu6ZGWrb1U4Kw7ZppWN394ecDhQXKTrS1z aV8OiN1P/hJRvyv1sbzNC5w4Gi1JbV2GIAN8nf/eo7QrkVRKVAqQRITFdEieBO/jjSbc +mr3aZHyB+hYsFb5iUvBWTyFdonNg1X00Wjuc9Kq7wRR6RhiGty0BKM2RR2m0j95XAbC xBTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732101371; x=1732706171; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=g+tOBiJdHrsDFQE0SIaz/xcAVpbptKV5QyZAWVIKa+0=; b=flA+Kf1YJXAZFYKuAjQjzge9UE7WY46mR8G90qsIksyQ3gu2huovkuMSAfX0jxTao8 XQBYwniY/0czg+H8n6yPYJzBVK9zGez+P/5SYBNaN25HMWkWMX7M9iWwO8+sTP6lFgbS 9TMvhAR1MiMVCPBGj66pKCfmpThOW9NLe6ygk4yA7ae2iISEICkUV+jPhlYfmFo4YeFH G36Ki/lKQL3B9cM0uoamQ+fmwyo8f4+Sn1vfkPzTpEKtYBuSP7tSCpeM5CzHAHODfeeK 1AU4dOOhYa9Gqtd7wgaAoVRGTQ470S3jcVvNkaUEMTjtSTOoedmJP31WyC+HJUDTKxvZ fSXA== X-Gm-Message-State: AOJu0YyXQsrnt1FfrWIq1zLXoWRKJDEVufT3ZlkP0bJafAmrxU1xmyxI e9pTamIP4yWCf/q+3hMoNiO6YpEXiL4tPTUlVuVwXlWjaM3yZqsbC7WMXssyo/pYiBBIkMs2O3k OH6V1KQ1Weq+QOcP5eYBKVC8V6EITUTf7 X-Google-Smtp-Source: AGHT+IEOvgbt2Zu7sb4bDuFOeEeh3EkDx1O1Q7S3UlwEN6t9Wy4nWqmLwWLhy4EsNUsk07arbdxqYtWSB4I+M7fJRBM= X-Received: by 2002:a17:907:9493:b0:aa4:d861:127f with SMTP id a640c23a62f3a-aa4dd751d9amr210982766b.53.1732101371383; Wed, 20 Nov 2024 03:16:11 -0800 (PST) MIME-Version: 1.0 From: Koen De Groote Date: Wed, 20 Nov 2024 12:16:00 +0100 Message-ID: Subject: Memory settings when running postgres in a docker container To: PostgreSQL General Content-Type: multipart/alternative; boundary="000000000000f4d63b06275646a3" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000f4d63b06275646a3 Content-Type: text/plain; charset="UTF-8" Assuming a machine with: * 16 CPU cores * 64GB RAM Set to 500 max connections A tool like this: https://pgtune.leopard.in.ua/ Will output recommended settings: max_connections = 500 shared_buffers = 16GB effective_cache_size = 48GB maintenance_work_mem = 2GB checkpoint_completion_target = 0.9 wal_buffers = 16MB default_statistics_target = 100 random_page_cost = 1.1 effective_io_concurrency = 200 work_mem = 8388kB huge_pages = try min_wal_size = 1GB max_wal_size = 4GB max_worker_processes = 16 max_parallel_workers_per_gather = 4 max_parallel_workers = 16 max_parallel_maintenance_workers = 4 And they basically use up all the memory of the machine. 16GB shared buffers, 48GB effective cache size, 8MB of work_mem for some reason... This seems rather extreme. I feel there should be free memory for emergencies and monitoring solutions. And then there's the fact that postgres on this machine will be run in a docker container. Which, on Linux, receives 64MB of /dev/shm shared memory by default, but can be increased. I feel like I should probably actually lower my upper limit for memory, regardless of what the machine actually has, so I can have free memory, and also not bring the container process itself into danger. Is it as straightforward as putting my limit on, say 20GB, and then giving more /dev/shm to the container? Or is there more to consider? Regards, Koen De Groote --000000000000f4d63b06275646a3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Assuming a machine with:

* 16 CPU cores=
* 64GB RAM

Set to 500 max connections

A tool like this:=C2=A0https://pgtune.leopard.in.ua/

Wi= ll output recommended settings:

max_connections =3D 500=
shared_buffers =3D 16GB
effective_cache_size =3D 48GB
maintenance= _work_mem =3D 2GB
checkpoint_completion_target =3D 0.9
wal_buffers = =3D 16MB
default_statistics_target =3D 100
random_page_cost =3D 1.1effective_io_concurrency =3D 200
work_mem =3D 8388kB
huge_pages =3D= try
min_wal_size =3D 1GB
max_wal_size =3D 4GB
max_worker_processe= s =3D 16
max_parallel_workers_per_gather =3D 4
max_parallel_workers = =3D 16
max_parallel_maintenance_workers =3D 4

And the= y basically use up all the memory of the machine.

= 16GB shared buffers, 48GB effective cache size, 8MB of work_mem for some re= ason...

This seems rather extreme. I feel there sh= ould be free memory for emergencies and monitoring solutions.
And then there's the fact that postgres on this machine wil= l be run in a docker container. Which, on Linux, receives 64MB of /dev/shm = shared memory by default, but can be increased.

I = feel like I should probably actually lower my upper limit for memory, regar= dless of what the machine actually has, so I can have free memory, and also= not bring the container process itself into danger.

Is it as straightforward as putting my limit on, say 20GB, and then givi= ng more /dev/shm to the container? Or is there more to consider?
=
Regards,
Koen De Groote

<= br>




--000000000000f4d63b06275646a3--