Mihir Shah
Mihir Shah

Reputation: 1809

AWS RDS instance 100% CPU utilisation for PostgreSQL for normal usage

I am using AWS RDS PostgreSQL 9.4. I am facing an issue of very high CPU utilization. Instance type is t2.xlarge (16 gb ram).

All the time I can see very low ram usage i.e. 14-1 GB free.

But in contrast, cpu utilization is 100%, with 100 active connection.

I have checked all my query in pg_stat_activity, slow query logs. Nothing found wrong. Though it touches 100% CPU utilization and my app becomes non functional even for very less active connections.

What is solution to reduce high CPU utilization against such high RAM?

When it reaches 100% CPU, my write IOPS was 400 count/second and read IOPS was 8.5 count/second.

I need to handle 300 concurrent connections sometimes when there is very high traffic on my website. What should be the ideal configuration of the RDS instance?

Upvotes: 0

Views: 2165

Answers (1)

MBer
MBer

Reputation: 2524

While I support taking questions about the configuration (such as the ideal work_mem setting that would allow more queries to be served from memory instead of disk) elsewhere, high CPU usage is also related to sub-optimal queries, and thus partly a software question.

From a software perspective: even if there are no extremely long queries getting stuck, there may still be extra capacity available by making the current ones return faster.

  1. The load in this question sounds biased towards write operations, but if these include many updates or if the reads are taking disproportionately long, it may still be possible to finish these more efficiently with indexes covering those columns.

  2. If there are frequent inserts or deletes, it may help to batch these in the application and save of the queries' overhead in exchange for extra latency. This would also let you reduce the application's pool size and avoid some overhead from having 100 parallel connections when 50 may actually let queries finish faster.

Upvotes: 0

Related Questions