I'm using a Linux server (Ubunto 18.04) that hosts the Postgres database. PostgreSQL makes CPU Usage up-to 100% and sometimes the related web site is down and after server restarting the site turns to work fine.
Running the query:
SELECT
(now() - pg_stat_activity.query_start) as interval, state
FROM pg_stat_activity
Results more than complex queries running at the same time responding to site navigation requests and depending on the number of connected users.
The problem is of the number of connected users increases the site is blocked and after restarting the database server it turns to work fine.
Could you please tell me how to solve this problem?
The server RAM is more than 23GB.