Azure / Azure/azure-sdk-for-java

[FEATURE REQ] Allow parallelism configuration for readMany

Open
#48,442 1 comment 0 reactions 3 assignees Claimed by @pjohari-ms View on GitHub
Client Cosmos customer-reported feature-request needs-team-attention Service Attention
Dominant language
Java
Stars
2.6k
Forks
2.2k
Avg merge
2d 8h
Merged PRs (30d)
178

Description

**Is your feature request related to a problem? Please describe.**

I have cross partition queries often with high waitTime while executing readMany requests.
The parallelism in this case is tied to the CPU cores the service has.
My service is already heavily CPU under utilized and it doesn't make sense to increase the CPU cores (kubernetes) to increase parallelism and reduce wait time.

**Describe the solution you'd like**

`CosmosReadManyRequestOptions` should have a property to set parallelism.

**Describe alternatives you've considered**

Hack `CPU_CNT`'s value in `com.azure.cosmos.implementation.Configs` with aspectj LTW.

**Additional context**
`readMany` uses `ParallelDocumentQueryExecutionContext` for partitions with 2+ items. The number of partition fetches that may run concurrently is computed in `fluxSequentialMergeConcurrency`:

```
private int fluxSequentialMergeConcurrency(CosmosQueryRequestOptions options, int numberOfPartitions) {
int parallelism = options.getMaxDegreeOfParallelism();
if (parallelism < 0) {
parallelism = Configs.getCPUCnt(); // ← fallback when -1
} else if (parallelism == 0) {
parallelism = 1;
}
return Math.min(numberOfPartitions, parallelism);
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.