cancel
Showing results for 
Search instead for 
Did you mean: 

High CPU Usage

Adventurer

High CPU Usage

Hi,

 

Currently my CPU usage in server that running EDB Postgres database is very high arround 80-90%. 

Is there any way to check the root cause that make the CPU high? 

here is the top result from the server

top - 15:14:59 up 266 days, 23:20, 5 users, load average: 22.47, 18.08, 16.28
Tasks: 718 total, 30 running, 688 sleeping, 0 stopped, 0 zombie
%Cpu(s): 89.1 us, 9.3 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 1.6 si, 0.0 st
KiB Mem : 16255076 total, 2679872 free, 2059944 used, 11515260 buff/cache
KiB Swap: 8384508 total, 7905172 free, 479336 used. 12733996 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
71820 poswchat 20 0 5501328 43124 11624 S 17.8 0.3 0:00.54 java
47519 poswchat 20 0 1361988 496104 490688 R 14.8 3.1 0:29.87 edb-postgres
58093 poswchat 20 0 1842668 945312 464176 R 14.5 5.8 0:35.95 edb-postgres
29891 poswchat 20 0 1367112 341372 330608 R 14.1 2.1 1:01.76 edb-postgres
120316 poswchat 20 0 1373324 630928 613752 R 14.1 3.9 2:29.25 edb-postgres
24215 poswchat 20 0 1381760 572220 546512 R 12.5 3.5 1:49.68 edb-postgres
69541 poswchat 20 0 1357984 216460 213148 R 12.5 1.3 0:04.76 edb-postgres
71841 poswchat 20 0 1356428 171636 169556 R 12.5 1.1 0:00.38 edb-postgres
35828 poswchat 20 0 1381104 383364 358296 S 10.5 2.4 1:15.33 edb-postgres
58094 poswchat 20 0 1365324 257416 248600 R 10.5 1.6 0:19.87 edb-postgres
69925 poswchat 20 0 1361284 451360 446820 R 10.2 2.8 0:04.43 edb-postgres
58654 poswchat 20 0 1362712 520720 514852 R 9.9 3.2 0:13.57 edb-postgres
71846 poswchat 20 0 1356428 143140 141060 R 9.9 0.9 0:00.30 edb-postgres
58089 poswchat 20 0 1360776 258984 254984 S 7.6 1.6 0:08.19 edb-postgres
71858 poswchat 20 0 1355372 139308 137740 R 6.9 0.9 0:00.21 edb-postgres
71863 poswchat 20 0 1356428 96404 94324 R 6.2 0.6 0:00.19 edb-postgres
36683 poswchat 20 0 1358136 148800 144724 S 5.6 0.9 0:30.84 edb-postgres
71871 poswchat 20 0 1355372 116336 114768 R 5.6 0.7 0:00.17 edb-postgres
42264 poswchat 20 0 1358120 146740 142680 S 4.9 0.9 0:26.17 edb-postgres
71866 poswchat 20 0 1355376 176532 175048 R 4.9 1.1 0:00.15 edb-postgres
90901 poswchat 20 0 1364376 440492 432336 S 4.9 2.7 2:11.81 edb-postgres
114262 poswchat 20 0 1368524 602424 589824 S 4.9 3.7 1:57.82 edb-postgres
23714 poswchat 20 0 1370728 425272 411244 S 4.6 2.6 1:07.02 edb-postgres
69539 poswchat 20 0 1359468 219104 215724 S 4.6 1.3 0:03.91 edb-postgres
120840 poswchat 20 0 1384388 643056 614576 S 4.6 4.0 2:19.96 edb-postgres
\

 

Thanks for the help.

Regards,

Bryan

3 REPLIES 3
EDB Team Member

Re: High CPU Usage

Hi BryanSiswoyo,

 

Can you share the command details of the top running processes? 

Highlighted
Adventurer

Re: High CPU Usage

Hi @chaitalirs ,

 

The command details of the top running processes is always change quickly and when i query from pg_stat_activity it always change rapidly to different query.

 

EDB Team Member

Re: High CPU Usage

Hi BryanSiswoyo,

 

Without the command details, it would be difficult to comment on this issue. From the database perspective, you might have to tune the parameters if they are set to a higher value or increase memory if the usage is more.

 

However, you can verify a few points to start the investigation which is specified below :

If the top running processes are :

  1. Database queries then you need to verify the parameter settings on the databases handling that type of queries.
  2. Postgres administrator processes like (archiver, checkpoint, bgwriter) then we need to tune parameters related to those.
  3. Postgres backup processes, you can think of changing the backup strategy i.e initiate backups in non-peak hours, initiate backups from slave/remote servers so that the resources are used of the remote server, etc.

You can generate a pgbadger report for calculating the number of connections/disconnections you get every minute/hours.

  • From this connection data, you can figure out that the memory configuration of the server and parameters are sufficient to handle the load which we are receiving on the system.

Pgbadger will also give you other stats related to checkpoints occurrences, details of the heavily loaded database on the cluster. 

Make sure the logging parameter is enabled to log the connection and disconnection of data.

 

Hope this helps.