Answer the question
In order to leave comments, you need to log in
Why does Postgres put more and more CPU under constant load?
Platform: windows.
I have Postgres and a node.js application. During the operation of the application, about 20-30 requests per second (read and write) are made to the database.
The problem is that after running the application on node.js, Posgres starts to consume the processor incrementally. Those. at the time of application launch, the load on the processor from the base is a few percent, the base responds to requests very quickly, we can say that "everything flies". After half an hour, the load is about 10%, requests slow down a little. After another half an hour, the load from the base on the processor is already about 50%, the number of executed queries drops to 10-15, i.e. twice as compared to the launch. And so on up to the fact that the CPU load reaches 100% and "everything slows down."
At the same time, Posgres processes also increase the consumption of RAM, but it is enough and the database does not consume more than 10 GB out of 24Gb available on the machine.
The problem is solved by restarting the application on node.js. Those. if you kill it and run it again, then everything starts from the beginning. It seems that Posgres is caching something for active connections and searching in this cache is CPU intensive. Because if you go to the database through PGAdmin and execute a query from there, then it is executed quickly.
Requests from node.js are made using Sequelize through a pool of 5 connections.
The size of base is about 15Gb together with all indexes. There are no hard requests. Query execution time is calculated in milliseconds.
Postgres config: pastebin.com/Vm1jp7VB
Processor: Core i5-3570K (4 cores)
RAM: 24Gb.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question