Interpreting Supabase Grafana CPU charts #27022
TheOtherBrian1 announced in Troubleshooting
Replies: 1 comment
-
| Very helpful, this and the other Grafana guides should be added as links in the Supabase docs! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Examples of stressed CPU

Showing high busy kernel CPU (yellow). Symptomatic of extension or connection-related issues.
High busy user CPU (blue). Symptomatic of problematic queries or database overload:

High busy IOWait (red). Even though the amount is relatively low, because disk is so much slower than CPU, a small amount is a sign of inadequate memory or disk IOPS/throughput:

Completely overwhelmed. Symptomatic of misuse and problematic data access patterns

Interpreting charts
The CPU chart shows 4 distinct metrics of interest:
As the CPU peaks towards 100%, queries and database tasks will begin to throttle, as they won't have enough time or access to the CPU.
Identifying problematic queries:
You should review your query performance advisor. Alternatively, you can access pg_stat_statements view. If you query it directly, you should focus on queries that create extremes:
PostgreSQL will produce a lot of activity in the background, so it's preferable to focus only on requests made by your application. This usually means filtering results from just the postgres role and, if you're using the DB API, the API roles, too.
Frequently called queries are the most insightful, so you should limit your observations to only the 15 to 30 most called. If this number is too narrow, expand as needed.
Examples on how to find the most problematic queries
Find the top 15 most frequent queries from the postgres, anon, authenticated, and service_role with an average runtime over 200ms and extreme standard deviations.
Special emphasis should be placed on queries that have a higher likelihood of CPU usage:
- Functions that utilize loops
Besides the query explorer, queries that generate timeout and duration events in the logs can also be of interest. You can go to the Logs Explorer, and run the following query to identify the events:
Optimizing:
Other useful Supabase Grafana guides:
Beta Was this translation helpful? Give feedback.
All reactions