0

In my application n microservices are running on m nodes. Each microservice has its own database and is responsible for issuing VACUUM ANALYZE once in a while.

Since the scheduling of this routine job is the same for each microservice, in my naive implementation I have m instances of the same microservice executing the VACUUM ANALYZE command at the same time.

Can this pose a problem?

I guess not, because PostgreSQL will detect the parallel invocations and handle this situation gracefully. But I'd like to be sure.

tobi
  • 81
  • 6

1 Answers1

0

No, you could end up with many VACUUM processes running at the same time that way, which might be bad for overall performance.

The better solution is to let autovacuum deal with this. The parameter autovacuum_max_workers limits the number of autovacuum workers that can run at the same time in a single PostgreSQL cluster.

Tune autovacuum appropriately, then it should run as often and as fast as you need it to.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
  • Autovacuum isn't an immediate solution right now, because of our access patterns that seem to prohibit successful autovacuum runs. I can fully understand, why someone would see this as a configuration problem, since autovacuum obviously is not configured to be aggressive enough. However, nightly routine vacuums have the following benefits: * No DB configuration necessary of not interfering with the usage patterns of our customers, while providing – tobi Aug 28 '20 at 11:56