Wednesday, February 20, 2019

[google-cloud-sql-discuss] Cloud PostgreSQL Autovacuum causing significant performance degradation

Our Postgres DB (hosted on Cloud SQL with 1 CPU, 3.7 GB of RAM, see below) consists mostly of one big ~90GB table with about ~60 million rows. The usage pattern consists almost exclusively of appends and a few indexed reads near the end of the table. From time to time a few users get deleted, deleting a small percentage of rows scattered across the table.

This all works fine, but every few months an autovacuum gets triggered on that table, which significantly impacts our service's performance for ~8 hours:

- Storage usage increases by ~1GB for the duration of the autovacuum (several hours), then slowly returns to the previous value (might eventually drop below it, due to the autovacuum freeing pages)
- Database CPU utilization jumps from <10% to ~20%
- Disk Read/Write Ops increases from near zero to ~50/second
- Database Memory increases slightly, but stays below 2GB
- Transaction/sec and ingress/egress bytes are also fairly unaffected, as would be expected

This has the effect of increasing our service's 95th latency percentile from ~100ms to ~0.5-1s during the autovacuum, which in turn triggers our monitoring. The service serves around ten requests per second, with each request consisting of a few simple DB reads/writes that normally have a latency of 2-3ms each.

Here are some monitoring screenshots illustrating the issue:

Screen Shot 2019-01-16 at 19.00.58.png

Screen Shot 2019-01-16 at 19.01.08.png

Screen Shot 2019-01-16 at 19.01.18.png

Screen Shot 2019-01-16 at 19.01.30.png

Screen Shot 2019-01-16 at 19.00.30 2.png


The DB configuration is fairly vanilla:

Screen Shot 2019-02-20 at 12.51.45.png


The log entry documenting this autovacuum process reads as follows:


system usage: CPU 470.10s/358.74u sec elapsed 38004.58 sec
avg read rate
: 2.491 MB/s, avg write rate: 2.247 MB/s
buffer usage
: 8480213 hits, 12117505 misses, 10930449 dirtied
tuples
: 5959839 removed, 57732135 remain, 4574 are dead but not yet removable
pages
: 0 removed, 6482261 remain, 0 skipped due to pins, 0 skipped frozen
automatic vacuum of table
"XXX": index scans: 1


Any suggestions what we could tune to reduce the impact of future autovacuums on our service? Or are we doing something wrong?

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/c404966d-d064-4d0f-890f-26ae07e11d64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment