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 1ujlTJ-00BkEP-Ou for pgsql-performance@arkaria.postgresql.org; Wed, 06 Aug 2025 21:14:54 +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 1ujlTG-001Ejw-V1 for pgsql-performance@arkaria.postgresql.org; Wed, 06 Aug 2025 21:14:50 +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 1ujlTG-001Ejn-Ke for pgsql-performance@lists.postgresql.org; Wed, 06 Aug 2025 21:14:50 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ujlTC-0018NW-2T for pgsql-performance@lists.postgresql.org; Wed, 06 Aug 2025 21:14:49 +0000 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-6154d14d6b7so354536a12.2 for ; Wed, 06 Aug 2025 14:14:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754514886; x=1755119686; darn=lists.postgresql.org; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:from:to:cc:subject:date:message-id :reply-to; bh=RZMIe95KgyHcg7HQW8Ys+ZkKNTwes0F1uMOKTeqzg3c=; b=mmN4vv32UyvyI+UnQSZwySAFRKVDCPD2zpV0KUtLX7fglzzbS4FuT1F40Yac0VHG/N dMEDSfx+3L5j5fDWJD1tq7W/ckm1p6GINsWkflFbFM/jjKNPxrkSyUme/7v4lhCLRa31 Gg2IhU0Q2uS+uI8qFnQxLUYHJ2zbEXDuPeQWvD7unL07CdovaANy0cPlitPm+auSUkNu nfRRlHM+FnGIFzVT4Bet3kKMI5iIK9HWVoZLvULpbPsQI7nGJXfEbZ8NZ7G4UTdoDY2N rrhIXTXALWIWx8GBg1a504mBrvDp6IeorySb8kIAPdGA+/ACFUnvvin/rXxy52rVvmvm Fk6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754514886; x=1755119686; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RZMIe95KgyHcg7HQW8Ys+ZkKNTwes0F1uMOKTeqzg3c=; b=UJ+8Fxe6duNOpLaZqKPV1NhS3sf6mya/Y5VkDQnytQHRIgJccBxqv6BK7D5T5ss44Z RTAXgSrQBED+NgpBO28VX631zmoI2jLaVtmyOIIfYUYZBVXwCXaUig7nToVI+H020Tgd OmeN47jlBXYvPaRrxSdBT1BFCZrH8H9XHGv6PBDVAgovoxoVGqKtwAKdLv0l3sE2F9th QEP5GuKDTu7HaveYwpZNOU8yRRxcBOVH+5Zej04qNHwUzJdRjScSJuUnq6xw2jYxtLEr k7UOPWQlOwOALUSZPwF4eTT1mcUy1NnrZ6fnvX1L0srV6yo25dWaO8eDkhUZp0cjS/PJ s+ug== X-Forwarded-Encrypted: i=1; AJvYcCWz7SB35u+eoDChdE/RxZFRxgZVh3jgXObRwguQhwUY7CbhFALgfW53YGFgnjh/+M4PZTYyZ+c+IpHRygmFwKd6fA==@lists.postgresql.org X-Gm-Message-State: AOJu0Yx/Cp371cGe4i+Lm025qbi+j34D+zanmpILXcXLnJkwZA0xQoFA 236odzT3A7XpYR2ov45cA4JXE7zkqBY8yIaIn/5q088/r8CAFSPzsr0Mp06bcQ== X-Gm-Gg: ASbGncvn3Mnc92QGtbKsL6Kf9xEQVdEeIp0gEQnsfL8GvLg3ZwV8QgPz+sGIvijpW7m cwSTMlkr1BhmC7QJuWs9c+R1nBmGZkv4mOjp5AQ2rAaLFwirgIrfWo4E77uDwjE2pKI3uzqjwnb o/uuaFWTdCTTEYbWA2U4SDffn0EKv90X2RvgSvPQdeuC6BSwDERn9xuL0RK1LQsA9FKjE8zEf/E +tYmI+/jAo2bZkiAzwO9UlmUqaX8YNgyer3IPQXtz+HuxCNBIkbCAIuBdmE2HDFk/H/2QPEKDVj Ct1LOP7zlyAWmIS1U65fAFTY6hpV8rl0pHzWLuHUaUeTEbdBakt4+qustddMknShCFDxWasYlxt 9UyhhmBmFnDUj3Mu19c97lO5cY/KVqis4PmgOfTceU7HOIADr5MoodqVK3Y9PpSdAk4SgUy526o 6QqvlVxt5T967K0/Z0iH7sq350b3Xx4uDqw5dPZaL9X7djAsl97t2c++XkMw== X-Google-Smtp-Source: AGHT+IHrCoHC1cZJf6rtsZ3y5pLRdLMlcn6BpLbHpNHPfTZ0s4ixgnPTUe+hVqZTUDuDgH65Md6JBQ== X-Received: by 2002:a05:6402:524b:b0:615:b6b9:d859 with SMTP id 4fb4d7f45d1cf-61797c57f06mr3684576a12.3.1754514885595; Wed, 06 Aug 2025 14:14:45 -0700 (PDT) Received: from smtpclient.apple (2001-1c04-0681-7700-dd55-7e3b-79bf-57d7.cable.dynamic.v6.ziggo.nl. [2001:1c04:681:7700:dd55:7e3b:79bf:57d7]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-615a8f2d554sm10635243a12.27.2025.08.06.14.14.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Aug 2025 14:14:45 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Frits Hoogland Mime-Version: 1.0 (1.0) Subject: Re: Safe vm.overcommit_ratio for Large Multi-Instance PostgreSQL Fleet Date: Wed, 6 Aug 2025 23:14:34 +0200 Message-Id: <3A250F65-F5DE-4E24-ADE7-BEFF4A18A8B9@gmail.com> References: Cc: Priya V , pgsql-performance@lists.postgresql.org In-Reply-To: To: Joe Conway X-Mailer: iPad Mail (22G86) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > As I said, do not disable swap. You don't need a huge amount, but maybe 16= GB or so would do it. Joe, please, can you state a technical reason for saying this? All you are saying is =E2=80=98don=E2=80=99t do this=E2=80=99.=20 I=E2=80=99ve stated my reasons for why this doesn=E2=80=99t make sense, and y= ou don=E2=80=99t give any reason. The article you cite does seem to point to general usage, not database usage= . Frits > Op 6 aug 2025 om 18:33 heeft Joe Conway het volgende g= eschreven: >=20 > =EF=BB=BF(Both: please trim and reply inline on these lists as I have done= ; > Frits, please reply all not just to the list -- I never received your > reply to me) >=20 >> On 8/6/25 11:51, Priya V wrote: >> *cat /proc/sys/vm/overcommit_ratio* >> 50 >> $ *cat /proc/sys/vm/swappiness* >> 60 >> *Workload*: Multi-tenant PostgreSQL >> *uname -r* >> 4.18.0-477.83.1.el8_8.x86_64 >=20 > IMHO you should strongly consider getting on a more recent distro with a n= ewer kernel. >=20 >> *free -h* >> total used free shared buff/cache available >> Mem: 249Gi 4.3Gi 1.7Gi 22Gi 243Gi 221Gi >> Swap: 0B 0B 0B >=20 > As I said, do not disable swap. You don't need a huge amount, but maybe 16= GB or so would do it. >=20 >> if we set overcommit_memory =3D 2, what should we set the overcommit_rati= on value to ? Can you pls suggest ? >> Is there a rule of thumb to go with ? >=20 > There is no rule of thumb that I am aware of. Every workload is different.= Start with something like 80 and do your own testing to refine that number.= >=20 >> *Our goal is to not run into OOM issues, no memory wastage and also not s= tarve kernel ? * >=20 > With overcommit_memory =3D 2, swap on (and reasonably sized), and overcomm= it_ratio to something reasonable (certainly below 100), I think you will hav= e a difficult time getting an OOM kill even if you try during testing. But y= ou have to do your own testing for your workloads -- there is no magic butto= n here. >=20 > That is, unless you run postgres in a cgroup with memory.limit (cgroup v1)= or memory.max (cgroup v2) set. Note, running in containers with memory limi= ts set e.g. via Kubernetes will do that under the covers. That is a complete= ly different story. >=20 >> On Wed, Aug 6, 2025 at 3:47=E2=80=AFAM Frits Hoogland > wrote: >> Can you name any technical reason why not having swap for a database >> is an actual bad idea? >=20 > Did you read the blog I linked? Do your own experiments. >=20 > * Swap is what is used when anonymous memory must be reclaimed to allow fo= r an allocation of anonymous memory. >=20 > * The Linux kernel will aggressively use all available memory for file buf= fers, pushing usage against the limits. >=20 > * Especially in the older 4 series kernels, file buffers often cannot be r= eclaimed fast enough >=20 > * With no swap and a large-ish anonymous memory request, it is easy to pus= h over the limit to cause the OOM killer to strike. >=20 > * On the other hand, with swap enabled anon memory can be reclaimed giving= the kernel more time to deal with file buffer reclamation. >=20 > At least that is what I have observed. >=20 > HTH, >=20 > -- > Joe Conway > PostgreSQL Contributors Team > Amazon Web Services: https://aws.amazon.com