Skip to content

High CPU usage on starved connection pool #4500

@steve-chavez

Description

@steve-chavez

Problem

When there are lots of requests coming to a slow function (due to unoptimized queries), postgREST consumes a lot of CPU (more than pg itself):

Image

This is likely due to db-pool-acquisition-timeout, for this case it was 10 (the default).

This needs more digging, but maybe there's a lot of queued/spawned threads that contribute to CPU usage.
If so, reducing the pool acquisition timeout should also be a solution.

Solution

WIP. Could there be a way to limit the amount of queued/spawned threads to prevent high CPU usage? So if db-pool-acquisition-timeout=10 and there are many requests waiting then reject right away instead of queuing up?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions