0

So I have a postgres db in a machine A and I have configured grafana in machine B.

Grafana has at least 10 dashboards with average of 10 panels each

The issue I am facing is After few days there are many sleeping processes running in machine where I am running postgres and it is consuming all the system resources

enter image description here

So in regular intervals I have to restart postgres service in order to stop those sleeping processes.

What I am missing here or how this can be optimized?

5
  • The question doesn't get any better if you ask it again. Asked before here. Feb 5 at 14:49
  • 2
    They are sleeping only because there are more of them than there are CPUs, so they need to take turns. Without knowing what those queries are doing or why they are doing it or why they are taking so long to do it, there is no way to answer this.
    – jjanes
    Feb 5 at 17:04
  • 1
    Yes your processes aren't sleeping, they're stuck running queries. You need to find why these queries take forever, and the first thing to do would be to check pg_stat_activity and pg_stat_statements
    – bobflux
    Feb 5 at 21:09
  • I have checked the pg_stat_activity and found out that one wrong query was running in one of the test instances of grafana which was using the same database. Every time that test instance was started It will add 1 more query in the queue. So removed the query and issue is fixed Feb 6 at 13:00

1 Answer 1

-1

The problem needs to be analyzed in detail, perhaps you should see if the SQL really takes up so much CPU (use explain (analyse,verbose,buffers) your sql, or is it affected by other sql)?

Not the answer you're looking for? Browse other questions tagged or ask your own question.