Skip to content

check if the pool has a free connection #381

Open

Description

@reifba

Hi, I am trying to optimise the size of the connection pool ( I know its a much broader topic).
I've been playing around with setting a really low timeout, and looping while counting the timeouts (this is also meaningful only in the long running mean) .

My app has no use for persistent connections/transactions and a pool is used to allow for a higher throughput and every "fetch" is called on the pool instance.

any low hanging fruits here or should I try to rebuilding the library with some tracing on the acquire context?

Activity

  1. elprans commented on Nov 28, 2018

    @elprans
    Member

    There's no public method, but you can check pool._queue.qsize() for the number of free connections in it.

  2. alvassin commented on Dec 25, 2019

    @alvassin

    @elprans thank you.

    What is the correct way to calculate busy connections? Is this the correct way?

    used_connections = sum(
        holder._in_use is not None
        for holder in pool._holders
    )
    

    I am trying to see metrics how are being used asyncpg connections, and this metric sometimes show very strange values (much more then Pool max_size value for example)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions