I would like to create an async client pool for my FastAPI Endpoint to allow high concurrency with low latency. I navigated through the pages below (new user can only post 2 links thus contracted to start and end), only to find a line indicating:
# used in v3 only
I haven’t found any recent discussion about this within 2025. Have you supported built-in connection pool or do I have to downgrade to V3 / build the connection pool by myself?
The basic suggestion we can give for this scenario is to use the client as a singleton, and if/when it get’s disconnected, you catch that error and reconnect the client.
Other then that, there isn’t a builtin pool.
The worse you can do it: not closing the client, and instantiating a new client for each operation
Thanks for your swift answer Duda! Actually, I ran into problems with V3 before: it doesn’t allow me to re-instantiating a new client upon catching the errors like this:
@contextlib.contextmanager
def get_client(self):
if not self._client:
self._client = self._create_client()
try:
yield self._client
except Exception as e:
# If connection error, try to reconnect
self._client = self._create_client()
raise
The error message says I’m not allowed to create a client on catching the error, probably because that’s because I didn’t close the client?
And still:
If I need a connection pool to allow multiple requests simultaneously (say 5), I think I would have to instantiate 5 clients, and do client management as you suggested (once disconnected, catch and reconnect) for each of them?
import weaviate
import weaviate.classes as wvc
from weaviate.config import ConnectionConfig
with weaviate.connect_to_local(additional_config=wvc.init.AdditionalConfig(connection=ConnectionConfig(session_pool_connections=10,..other settings…))) as client: