0

I have three Docker containers: one running Postgres and two others running LoopbackJS (the actual setup is more complex, but I'm simplifying here for clarity). The Loopback servers read/write to a database in the Postgres container.

The host machine has 6 CPU cores and Postgres is configured with:

max_worker_processes = 6
max_parallel_workers_per_gather = 3
max_parallel_workers = 3

Just after staring, I check the number of processes of Postgres, which is usually around 4:

mydb=# SELECT COUNT(*) FROM pg_stat_activity;
 count 
-------
     4
(1 row)

When there are 3 or 4 users interacting simultaneously with the system, I can see the number of processes rising past the limit defined in max_worker_processes:

mydb=# SELECT COUNT(*) FROM pg_stat_activity;
 count 
-------
     12
(1 row)

The processes quickly become idle and after a few seconds they are terminated, which I believe is the expected behaviour. But when there are many simultaneous requests, the number of processes quickly reaches 14, and the last Loopback server to communicate with the database simply stops responding (with no errors on the logs) and I have to restart its container in order for it to become responsive again. When I restart the container, the number of processes drops to around 4 again.

So, I guess I have two questions:

  1. Why is the number of processes allowed to go past max_worker_processes?
  2. What could be causing the crash when it reaches 14 processes?

Please let me know if I missed some important piece of information.

gfields
  • 1
  • 1

0 Answers0