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 1na0Hz-0007Jm-SN for pgsql-performance@arkaria.postgresql.org; Thu, 31 Mar 2022 19:17:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1na0Hy-0007Vn-M7 for pgsql-performance@arkaria.postgresql.org; Thu, 31 Mar 2022 19:16:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1na0Hy-0007VV-0W for pgsql-performance@lists.postgresql.org; Thu, 31 Mar 2022 19:16:58 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1na0Hu-0006TS-IF for pgsql-performance@lists.postgresql.org; Thu, 31 Mar 2022 19:16:56 +0000 Received: by mail-ej1-x633.google.com with SMTP id bi12so1367067ejb.3 for ; Thu, 31 Mar 2022 12:16:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=MAJNVek7z0FQnQCfr32mB2Wc5VVvnIb3Z1VBBE55bvI=; b=Wez+KXSGA44pL2hsWio5S47bi5vf4X2DRKo2pZGiC/RI7TTappceb8IADSr3F0suwt bZcKjgXpQpRpjwaB1kTaW4icS8C7a2CkFNU+i7PKBgmcP6DRDctFGAIqqLBP1x7FcsAk 3daMw+nIFeTBYqL1QZiB7AlKi3XwfLcxbccY5mdgPq5HFhctXyrW021hud78WVL68Jto dfzZ392ldx5ZopEKHZtnDIMhY5MRYX6F/gSIa2OsW41dYgw0EdER+Rx3aeVULJlGv+jH JfzLmFxhOMNqJzC9Dqdv3d+hc565VAFqGrZj4AQ/iMrZvgyx9aJwwTISEG4OSJq4cy0E HSyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=MAJNVek7z0FQnQCfr32mB2Wc5VVvnIb3Z1VBBE55bvI=; b=xxhuZxYFS4N8+uOeZACT+7hiN1PowrsOcfwA+HCkhvFa4dut0Ls2wz9XxQ3/dcxe+1 waFRj9tZBb3VS6qq2hBAgm5u3tASS6EXrbOw5o4QMk+NQqxFvWT4agi8WxJVCbFo1nnd gVfNu383aJJyfweCAc9bYUEjgyn2S2rsQCrOQRlnY8fLA7hfuL6/65n4wamxR7kR6VVz 1+hG8N5jJ9qblCxIsSAIbFLyhy+egkHRM/ju7UrTXuzao8/Ojm8GpKsf8fMVfXUTFiu/ rImQwvRFqLhHzcTluim3/IEJ2b7vNMdvh1BJfwvuV2UmfAia7B4lSiPILXOEvZbrghSi fWnQ== X-Gm-Message-State: AOAM5310SUoUIhYFJ2USb0opLFekiTrb9+pUAVptOXD3DwigyeHUt3+t xzLqEr4Mbhh0MiXYB9r9/a+9025i5Ca5y6JC4r9OQKmUf1w2URzFR3RjuUe8hRfZEGGWm3Etuut 5LFBVYAuputPr7SvhS8MWXqvb84Vvp02Z/G5s2va3gaInWcb3v6+Ho8CTVLUz2dPJ8hgIpiUSyK aWxb6s75bo4otgmp5miaDakU8utByEy+8SYAsxbwmQh4wqzy8ZFjL20u1g3A/gYYQ= X-Google-Smtp-Source: ABdhPJx7piu3Wh7VZU46raKyUDkFmsXtjwD46/henYdy7nt95f6bY6mcWJFwm6gshQjpqY7oOOcsag== X-Received: by 2002:a17:906:9c90:b0:6df:9eea:cda3 with SMTP id fj16-20020a1709069c9000b006df9eeacda3mr6422894ejc.89.1648754213061; Thu, 31 Mar 2022 12:16:53 -0700 (PDT) Received: from [10.137.0.17] (ip-86-49-250-165.net.upcbroadband.cz. [86.49.250.165]) by smtp.gmail.com with ESMTPSA id z8-20020a170906270800b006bbd3efa6b8sm113957ejc.80.2022.03.31.12.16.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 31 Mar 2022 12:16:52 -0700 (PDT) Message-ID: Date: Thu, 31 Mar 2022 21:16:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: Postgresql TPS Bottleneck Content-Language: en-US To: wakandavision@outlook.com, "pgsql-performance@lists.postgresql.org" References: From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/31/22 13:50, wakandavision@outlook.com wrote: > Hi everyone, > > I am a bachelor's student and writing my thesis about the scaling and > performance of an application. The application is using postgresql as a > database but we can't scale any further currently as it seems postgres > is hitting the limit. > > With the application, as well as with pgbench, we don't get more than > (max) 70k TPS on postgres. But the servers' resources are not utilized > completely (more below). > > I've tried many different configurations but none of them had any major > performance impact (unless fsync and synchronous_commit = off). > > This is the (custom) configuration I am using: > > shared_buffers=65551953kB > effective_cache_size=147491895kB > huge_pages=on > min_wal_size=20GB > max_wal_size=200GB > wal_buffers=1GB > max_wal_senders=0 > archive_mode=off > wal_level=minimal > work_mem=2GB > maintenance_work_mem=4GB > checkpoint_completion_target=0.9 > checkpoint_timeout = 30min > random_page_cost=1.1 > bgwriter_flush_after = 2MB > effective_io_concurrency = 200 > # Disabled just for performance experiments > fsync = off > synchronous_commit = off > full_page_writes = on > max_worker_processes=64 > max_parallel_workers=64 > max_parallel_workers_per_gather=10 > max_parallel_maintenance_workers=12 > > The system is as follows: > > * 64 Cores (Intel Xeon Gold 6130 (Skylake, 2.10GHz, 2 CPUs/node, 16 > cores/CPU)) > * 192 GiB RAM (12 * 16GiB DIMM DDR4 Synchronous Registered (Buffered) > 2666 MHz (0.4 ns)) > * 2 * SSD SATA Samsung MZ7KM240HMHQ0D3 (one is used for the WAL and the > other for the data) > * 10 Gbps network link > * OS: Debian 11 > * Postgres 13 from apt > > (I've also written a stackoverflow post about it - > https://stackoverflow.com/questions/71631348/postgresql-bottleneck-neither-cpu-network-nor-i-o > > ) > > > performance - Postgresql bottleneck neither CPU, network nor I/O - Stack > Overflow > > We are testing our application for performance, which is using > Postgresql 13 as a database. It is very insert and update heavy and we > cannot get more than 65k TPS on the database. But none of the m... > stackoverflow.com > > > > Below is just an example of the pgbench I ran: > > pgbench -i -s 50 -U postgres -h -d > pgbench -c 64 -j 32 -t 100000 -h -U postgres > I'd bet you need to use "pgbench -N" because the regular transaction updates the "branch" table, and you only have 50 branches. Which probably means a lot of conflicts and locking. The other thing you might try is "-M prepared" which saves time on query planning. FWIW I really doubt "fsync=off" will give you any meaningful results. Maybe try assessing the hardware capability first, using tools like fio to measure IOPS with different workloads. Then try pgbench with a single client, and finally increase the number of clients and see how it behaves and compare it to what you expect. In any case, every system has a bottleneck. You're clearly hitting one, otherwise the numbers would go faster. Usually, it's either CPU bound, in which case "perf top" might tell us more, or it's IO bound, in which case try e.g. "iostat -x -k 1" or something. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company