Skip to content

Conversation

@byashimov
Copy link
Contributor

@byashimov byashimov commented Jan 27, 2026

Resolves NEX-2296.

Add singleflight to deduplicate concurrent GET/HEAD/OPTIONS/TRACE requests.

Deduplicate concurrent requests to shared list endpoints using singleflight.
Many resources, such as databases, do not have individual endpoints and instead share a single "list" endpoint (e.g., ServiceDatabaseList).
In practice, the deduplication applies to any identical request (same method + host + path + query), with list endpoints being the primary motivation.

This often results in multiple simultaneous requests for the same data, which can cause redundant API calls and unnecessary load. With singleflight enabled, identical in-flight requests are coalesced into one HTTP call and the buffered response bytes are fanned out to all callers (no persistent caching). Currently, the client uses only GET for reading, but additional safe methods may be supported in the future.

Tests use testing/synctest to deterministically validate deduplication and method isolation.

Singleflight can be disabled via AIVEN_CLIENT_ENABLE_SINGLE_FLIGHT/EnableSingleFlightOpt (default: true).

@byashimov byashimov requested a review from a team as a code owner January 27, 2026 07:24
@byashimov byashimov force-pushed the byashimov/NEX-2296/add-singleflight branch from 877fc70 to c8ea18d Compare January 27, 2026 07:27
@byashimov byashimov force-pushed the byashimov/NEX-2296/add-singleflight branch 2 times, most recently from 4a14759 to aa4fe87 Compare January 27, 2026 08:33
@byashimov byashimov marked this pull request as draft January 27, 2026 17:11
@ndk ndk self-requested a review January 28, 2026 07:21
@ndk ndk force-pushed the byashimov/NEX-2296/add-singleflight branch from aa4fe87 to 5a7a71f Compare January 29, 2026 18:15
@ndk ndk marked this pull request as ready for review January 30, 2026 09:06
@ndk ndk marked this pull request as draft January 30, 2026 09:22
@ndk ndk force-pushed the byashimov/NEX-2296/add-singleflight branch from 5a7a71f to 659778b Compare January 30, 2026 10:11
@ndk ndk marked this pull request as ready for review January 30, 2026 10:11
@byashimov byashimov marked this pull request as draft February 1, 2026 21:38
@byashimov byashimov marked this pull request as ready for review February 1, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants