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 1tDsua-003pjW-68 for pgsql-general@arkaria.postgresql.org; Wed, 20 Nov 2024 22:11:00 +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 1tDsuY-009X9f-Sv for pgsql-general@arkaria.postgresql.org; Wed, 20 Nov 2024 22:10:58 +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 1tDsuY-009X9X-DS for pgsql-general@lists.postgresql.org; Wed, 20 Nov 2024 22:10:58 +0000 Received: from mail-oo1-xc30.google.com ([2607:f8b0:4864:20::c30]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tDsuV-0030ED-GT for pgsql-general@lists.postgresql.org; Wed, 20 Nov 2024 22:10:57 +0000 Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-5ebc1af9137so162910eaf.2 for ; Wed, 20 Nov 2024 14:10:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732140653; x=1732745453; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=1Byx764fnSggduUT8UTKoUklmu4S1BziAqOrSrhXjFs=; b=YHTMXAK2V8ENWDTqaVP2N+HtdUL1k27GZy72BS7GWGssfXM82kuEeyDjiXsVgo7kIK PkT2cJRniR+/8GV4rdjSLg6T1qYemIA10HTrHPpZwu8DP49AXz8yX+gdPnX56h7EcZou TfxLbz5IiGfhkW4CQS5U7OK3xAkNwZ6k/p5shDXYKaSWkqGUPTVBARD7CFfdLVoZjC/I qpslyyQ8gFttQV0N5Dp4FB13UWzw3SRjWlREjqGnS6N3nhYdXkUY9wZxcHRxG4CvMVSc rKY9kOgz/iDoF41gaN6IjPj1LmUCNxY5dnBAG7JpH+pFegn3INxS53J9M+d78veT98hq l7rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732140653; x=1732745453; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1Byx764fnSggduUT8UTKoUklmu4S1BziAqOrSrhXjFs=; b=Y/pS/DzoCJ5wP9Oe/YogO1Y+mpNyKoOiksENYWcejZSRUxxf958PW+Z319Hk/XDLZw 34gKrjP7Xd/lULdPJnAbqWbo+34CcCHzZPIFXydL5Qb0mEjm6arJUQrav0FHTud0W3bV 3fg7Yi5h+0bDFDZF4VmXPYgsn2osbuzPXu4g3or7Z8Gxp2JQgAEKBBzwsTewLIhqOMV8 Erqi+KFCjY8QMW11cfgxgoCGjgDCci5vOxptYEvce4DuipiZpWX6UwMbI0ErgVhyf6Cr TUzrIu3HjjUqI3Y0P6qY/ZOHg19lG5QamOiJZve+po3xOqVxRfIzZS1CLd6mnbWYYaGb q/6g== X-Gm-Message-State: AOJu0Yya1FDNqI4C2QuhmiUAK5Abvhk6DCOLiSMuJg5WtoGm5Mv3Lo6L hr5F2ShpPUcjJNokjVDnwGCHbh03bIbOLZDgIB8z6KFpxijsKpKPGhZhBxBBCZmA8PGenMZ5SF6 9Df2EpN4k/ShH2E+KSg4+zYTsT0k= X-Gm-Gg: ASbGncsGEd6eckYWGnY62MShfhRoxFbcAWKNovJ5t2iVxR21vR1aOniyYq+Jr9NLsVd V92F149j0yLqBNGRNqX1lKp0fNFWw8RU= X-Google-Smtp-Source: AGHT+IEVt76/e+i4e3/H7A5GEl+3jy24UbHPJ2ke+Ic+iiBzLahulaYDfDL+ahRBDR1WOsHDhK5vkN8aW5WClTg7XgU= X-Received: by 2002:a05:6820:12e:b0:5ee:e899:3654 with SMTP id 006d021491bc7-5eee8993b94mr3255591eaf.2.1732140652197; Wed, 20 Nov 2024 14:10:52 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: David Mullineux Date: Wed, 20 Nov 2024 22:10:40 +0000 Message-ID: Subject: Re: Memory settings when running postgres in a docker container To: Koen De Groote Cc: PostgreSQL General Content-Type: multipart/alternative; boundary="000000000000467e7206275f6c04" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000467e7206275f6c04 Content-Type: text/plain; charset="UTF-8" i dont get why you think all memroy will be used. When you say shared_buffers = 16GB effective_cache_size = 48GB ...then this is using only 16GB for shared buffers. The effective _cache_size doesn't cause any memory to.be allocated. It's just a hint to optomizer .... On Wed, 20 Nov 2024, 11:16 Koen De Groote, wrote: > 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 > > > > > > > --000000000000467e7206275f6c04 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
i dont get why you think all memroy will be used.
=C2=A0When you say
shared_buffers =3D 16GB
effective_cache_size =3D 48GB

...then this is using only 16GB for= shared buffers.

Th= e effective _cache_size doesn't cause any memory to.be allocated. It's just a hint to optomizer ....
=
= On Wed, 20 Nov 2024, 11:16 Koen De Groote, <kdg.dev@gmail.com> wrote:
Assuming a machine with:

* 16 CP= U cores
* 64GB RAM

Set to 500 max connec= tions

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

Will 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_ta= rget =3D 100
random_page_cost =3D 1.1
effective_io_concurrency =3D 20= 0
work_mem =3D 8388kB
huge_pages =3D try
min_wal_size =3D 1GB
m= ax_wal_size =3D 4GB
max_worker_processes =3D 16
max_parallel_workers_= per_gather =3D 4
max_parallel_workers =3D 16
max_parallel_maintenance= _workers =3D 4

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

16GB shared buffers, 48GB effectiv= e cache size, 8MB of work_mem for some reason...

T= his seems rather extreme. I feel there should be free memory for emergencie= s and monitoring solutions.

And then there's t= he fact that postgres on this machine will be run in a docker container. Wh= ich, on Linux, receives 64MB of /dev/shm shared memory by default, but can = be increased.

I feel like I should probably actual= ly 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 i= tself into danger.

Is it as straightforward as put= ting my limit on, say 20GB, and then giving more /dev/shm to the container?= Or is there more to consider?

Regards,
= Koen De Groote




<= /div>


--000000000000467e7206275f6c04--