Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJDFE-0005k4-3e for pgsql-admin@arkaria.postgresql.org; Fri, 18 Sep 2020 10:03:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kJDFC-0003og-Sv for pgsql-admin@arkaria.postgresql.org; Fri, 18 Sep 2020 10:03:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJDFC-0003oY-JR for pgsql-admin@lists.postgresql.org; Fri, 18 Sep 2020 10:03:54 +0000 Received: from mail4.neteven.com ([5.135.111.119]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJDF9-0006J3-Oh for pgsql-admin@postgresql.org; Fri, 18 Sep 2020 10:03:54 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail4.neteven.com (Postfix) with ESMTP id 8C676A1D5 for ; Fri, 18 Sep 2020 12:03:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 mail4.neteven.com 8C676A1D5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=neteven.com; s=dkim; t=1600423430; bh=jWDcF+tqALmH3FofWmUXVi5Ro0ygtzzVCr/sSJwcx3A=; h=From:Subject:Reply-To:To:Date:From; b=bVlKQ1iUlzesNSZsgYaKFM4gSuBlmm6b86HGeNFLnn9TTy93ZzpQPD4jx6HyRdJKh S+yFxuqVQME5x7zK4Ahc1oJkg7XZ8MPFyeKG758iX5Ye7SXNGLgDedu687duWsQyPJ lGt4px8tWnPRRgyiIe1PUMT9Q2oitHjBQldnMIQk= X-Virus-Scanned: Debian amavisd-new at mail4.neteven.com Received: from mail4.neteven.com ([127.0.0.1]) by localhost (mail4.neteven.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id blq9z2aKMH1T for ; Fri, 18 Sep 2020 12:03:50 +0200 (CEST) From: "JOIGNY Michael @Neteven" Subject: Cannot allocate memory Reply-To: mjoigny@neteven.com To: pgsql-admin@postgresql.org Message-ID: Date: Fri, 18 Sep 2020 12:03:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------60321B41343FAF25F9D437A4" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------60321B41343FAF25F9D437A4 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hi Community, I'm asking for your lights because i'm having memory problems with postgres. Examples of logs : /FATAL: could not fork new process for connection: Cannot allocate memory could not fork new process for connection: Cannot allocate memory out of memory  DETAIL:  Failed on request of size 32800 in memory context "HashBatchContext". out of memory DETAIL Failed on request of size 288 in memory context "CacheMemoryContext". / We use postgresql (primary/standby) with pgbouncer as a pooler, and repmgr as replication manager. We have ~ 2000 connections at the same time with ~ 20/30 are active. (we need to set a high number of connexion on postgres, because our app uses a lot of different users, and each user on each app server needs multiple and constant connexions). Here is my configuration : _system : _ Debian : 9.13 Memory : 380 Go Postgres : 12.4-1.pgdg90+1 Pgbouncer : 1.14 kernel.shmmax = 202591600640 kernel.shmall = 49460840 _postgres : _ dynamic_shared_memory_type = posix    # the default is the first option max_connections = 2600            # (change requires restart) work_mem = 96MB                # min 64kB maintenance_work_mem = 8GB        # min 1MB shared_buffers = 64GB            # min 128kB temp_buffers = 32MB            # min 800kB wal_buffers = 16MB            # min 32kB, -1 sets based on shared_buffers effective_cache_size = 270GB pgbouncer : max_client_conn = 6000 default_pool_size = 2590 reserve_pool_size = 5 pool_mode = session Do you think that our parameters are not correct compared to our configuration? Do you have an idea ? Best regards. Michael. --------------60321B41343FAF25F9D437A4 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

Hi Community,

I'm asking for your lights because i'm having memory problems with postgres.

Examples of logs :

FATAL: could not fork new process for connection: Cannot allocate memory could not fork new process for connection: Cannot allocate memory
out of memory  DETAIL:  Failed on request of size 32800 in memory context "HashBatchContext".
out of memory DETAIL Failed on request of size 288 in memory context "CacheMemoryContext".


We use postgresql (primary/standby) with pgbouncer as a pooler, and repmgr as replication manager.

We have ~ 2000 connections at the same time with ~ 20/30 are active. (we need to set a high number of connexion on postgres, because our app uses a lot of different users, and each user on each app server needs multiple and constant connexions).

Here is my configuration :

system :

Debian : 9.13
Memory : 380 Go
Postgres : 12.4-1.pgdg90+1
Pgbouncer : 1.14
kernel.shmmax = 202591600640
kernel.shmall = 49460840

postgres :

dynamic_shared_memory_type = posix    # the default is the first option
max_connections = 2600            # (change requires restart)
work_mem = 96MB                # min 64kB
maintenance_work_mem = 8GB        # min 1MB
shared_buffers = 64GB            # min 128kB
temp_buffers = 32MB            # min 800kB
wal_buffers = 16MB            # min 32kB, -1 sets based on shared_buffers
effective_cache_size = 270GB

pgbouncer :

max_client_conn = 6000
default_pool_size = 2590
reserve_pool_size = 5
pool_mode = session

Do you think that our parameters are not correct compared to our configuration? Do you have an idea ?

Best regards.

Michael.

--------------60321B41343FAF25F9D437A4--