From: Jeremy Schneider <schnjere@amazon.com>
To: Azul <mail@azulinho.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: select count(id) on RDS replica causing high CPU load on RDS master
Date: Wed, 3 Jun 2020 06:59:16 -0700
Message-ID: <fbcddcf5-d825-50d7-fbb9-6d2518af199b@amazon.com> (raw)
In-Reply-To: <CAMP=owg4R=fB_U0cY12vkvo4Twa7tgJwf5CER2Q4hq-=6+7UxA@mail.gmail.com>
References: <CAMP=owg4R=fB_U0cY12vkvo4Twa7tgJwf5CER2Q4hq-=6+7UxA@mail.gmail.com>
On 6/3/20 04:04, Azul wrote:
> so I have a RDS 9.5 master 16vcpu/64GB RAM/5000 IOPS which is RDS
> replicating to a replica with the same specs.
If you're not already making plans to upgrade this, many people would
strongly urge you start now. The final release for 9.5 is less than a
year away, after which you will no longer be able to get security
updates or bug fixes.
https://www.postgresql.org/support/versioning/
Please consider moving in the direction of v12.
Just for posterity in case someone googles this email thread in the
future, an RDS "read replica" is a "hot standby" in PostgreSQL terminology.
https://www.postgresql.org/docs/9.5/high-availability.html> I am running the above on the replica to avoid causing an extra load on
> the master, that query takes a long time (lets ignore the fact that it
> badly needs an analyse to finish), roughly an hour or so.
Just curious, did you happen to enable the hot_standby_feedback
parameter? Looks to me like it's off by default in 9.4.
> Now what is baffling me is the CPU load on the master goes up steadily
> all the way to 100% while this select count is running on the slave.
> Worth mentioning that CPU on the slave increases by about 10% of so.
Which PIDs/processes are using the CPU? (Vacuum? App connections running
queries?) For people who manage PostgreSQL themselves, they'd use normal
unix utilities like top, ps, etc. On RDS you want to enabled "Enhanced
Monitoring" and check the "process list". (In the web console, as of
last time I checked: go to the database, choose the "Monitoring" tab,
click the dropdown box at the top right that says "Monitoring" and
choose "OS Process List".)
If you see that it's user sessions, then you can connect with psql at
the same time as the high activity and query the contents of
pg_stat_activity to get a little more information about what the
particular process is doing.
--
Jeremy Schneider
Database Engineer
Amazon Web Services
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: schnjere@amazon.com, mail@azulinho.com
Subject: Re: select count(id) on RDS replica causing high CPU load on RDS master
In-Reply-To: <fbcddcf5-d825-50d7-fbb9-6d2518af199b@amazon.com>
References: <CAMP=owg4R=fB_U0cY12vkvo4Twa7tgJwf5CER2Q4hq-=6+7UxA@mail.gmail.com> <fbcddcf5-d825-50d7-fbb9-6d2518af199b@amazon.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox