Postgres, why is swap usage increasing? How to reduce it? - AWS RDS

The availability of the postgres database on AWS-RDS is Swap Usageconstantly growing.

Why is it growing? I tried to restart, but it does not sink. AWS writes that using a large number of swaps "indicates performance issues"

I am writing data to this database. The processor and memory look healthy: enter image description here

To be precise, I have db.t2.micro-Instance and currently ~ 30/100 GB. The data in 5 tables is a general purpose SSD. By default, postgresql.conf.

The summary chart is as follows:

enter image description here

Swap Warning:

enter image description here

+4
source share
3 answers

Well, it seems that your queries are using the amount of memory over your available. Therefore, you should look at the query execution plan and find the biggest loads. These queries exceed the memory available for postgresql. Usually excessive aggregation (i.e., a poor database structure that would be better denonarmalized, if applicable) or a lot of nested queries or queries with IN clauses are typical suspects. I assume that amazon is delivered as much as possible for postgresql.conf, and these default values ​​are not bad for this tiny machine.

But again, if your swap size does not exceed your available memory, and you are on an SSD - there would be no harm to it

+1
source

, . db.t2.micro 1 . htop, , . pgtop (http://ptop.projects.pgfoundry.org/), , .. . , pgtop, posgres - postgres stats collector https://www.postgresql.org/docs/9.6/static/monitoring-stats.html

, , db.t2.micro - . , biggier, .

+1

check

select * from pg_stat_activity;

and see which process takes a lot of time and how many processes to sleep, try changing your RDS DBparameter to suit your needs.

+1
source

Source: https://habr.com/ru/post/1667893/


All Articles