Files
OpenViking/tests/storage
dingbenandTRAE CLI fbeb1345e6 perf(vectordb): reuse pooled HTTP session per client (#4696)
* perf(vectordb): reuse pooled HTTP session per client

VikingDB clients issued every request through module-level
requests.request/post/get, which builds and discards a Session per
call. That means no connection pool and no keep-alive, so every
search/find pays a fresh TCP + TLS handshake.

Give each client one long-lived requests.Session backed by an
HTTPAdapter connection pool (mounted on both http:// and https://) and
route do_req through it, so repeated calls reuse warm connections.

Covers ClientForConsoleApi, ClientForDataApi, ClientForDataApiWithApiKey
and the private VikingDBClient.

Co-authored-by: TRAE CLI <traecli@bytedance.com>

* perf(vectordb): reuse one pooled client in VikingDBProject

has_collection/get_collection/_get_collections built a fresh
VikingDBClient per call, so each rebuilt a pooled Session whose
keep-alive connection died with the GC'd client. Hoist the client to an
instance attribute so all metadata calls share one warm pool.

Note: requests.Session persists Set-Cookie across calls (the old
one-shot requests.request did not). These APIs are HMAC/Bearer
authenticated and do not use cookies, so this is only relevant if a
fronting LB sets affinity cookies, which would now stick per client.

Co-authored-by: TRAE CLI <traecli@bytedance.com>

---------

Co-authored-by: TRAE CLI <traecli@bytedance.com>
2026-09-14 11:14:37 +08:00
..