Repository navigation
Description
Is your feature request related to a problem?
The opensearch-java client has no performance benchmarking infrastructure. There is currently no way to:
- Measure the throughput or latency of BulkIngester under different configurations
- Detect performance regressions introduced by code changes
- Compare the cost of different serialization strategies (e.g. raw POJO vs BinaryData)
- Validate that optimizations like increased maxConcurrentRequests or batch sizing actually improve end-to-end throughput
Without a benchmark module, performance work relies entirely on ad-hoc scripts written outside the repository, making results hard to reproduce and compare across contributors.
What solution would you like?
A benchmarks/ submodule using JMH (Java Microbenchmark Harness) (https://github.com/openjdk/jmh) via the me.champeau.jmh(https://github.com/melix/jmh-gradle-plugin) Gradle plugin.
Proposed module structure
benchmarks/
├── build.gradle.kts # JMH plugin + dependencies
└── src/jmh/java/org/opensearch/client/benchmarks/
└── BulkIngesterBenchmark.java # end-to-end throughput benchmark
BulkIngesterBenchmark — initial benchmark
Measures end-to-end BulkIngester throughput (ops/s) against a live OpenSearch cluster, parameterized on:
- maxOperations — operations per bulk flush (e.g. 1000, 5000, 10000)
- maxSize — max bytes size per bulk flush (e.g. 5MB, 10MB)
- maxConcurrentRequests — in-flight bulk request limit (e.g. 1, 2, 4, 8)
Key design decisions:
- Uses @threads(Threads.MAX) to simulate concurrent producers and reach steady-state throughput
- Pre-serializes documents to BinaryData once at @setup to isolate transport cost from serialization cost
- Creates a fresh timestamped index per trial and deletes it in @teardown
- Supports HTTPS + basic auth via system properties for testing against remote clusters
Run against a local cluster
./gradlew :benchmarks:jmh -Pbenchmark=BulkIngesterBenchmark
Run against a remote cluster with HTTPS + basic auth
./gradlew :benchmarks:jmh -Pbenchmark=BulkIngesterBenchmark
-Dbenchmark.scheme=https
-Dbenchmark.host=my-cluster.example.com
-Dbenchmark.port=443
-Dbenchmark.user=admin
-Dbenchmark.password=secret
Sample output:
Benchmark (batchSize) (maxConcurrentRequests) Mode Cnt Score Error Units
BulkIngesterBenchmark.bulkIndexThroughput 1000 1 thrpt 10 28,776 ± 1,839 ops/s
BulkIngesterBenchmark.bulkIndexThroughput 5000 1 thrpt 10 35,395 ± 1,423 ops/s
BulkIngesterBenchmark.bulkIndexThroughput 10000 1 thrpt 10 35,507 ± 2,873 ops/s
BulkIngesterBenchmark.bulkIndexThroughput N/A 1 thrpt 10 35,241 ± 1,102 ops/s
What alternatives have you considered?
OpenSearch Benchmark (OSB) maybe an option, but OSB drives OpenSearch directly using its own internal HTTP client. It measures what the cluster can handle — indexing throughput, query latency, segment merge cost. It has no knowledge of the Java client's internal architecture: BulkIngester's buffer management, the maxConcurrentRequests semaphore, the ReentrantLock contention, serialization cost, or connection pool behavior.
If a code change in BulkIngester introduces a lock contention bug that halves throughput, OSB would never detect it — because OSB never calls BulkIngester.
Activity
gaobinlong commentedon Aug 18, 2026
Hi @reta , could you help take a look? Thanks!
reta commentedon Aug 18, 2026
Thanks @gaobinlong , I think indeed we don't have dedicated benchmarking suite for
opensearch-javaclient. The JMH benchmarks (to my knowledge) would not be a fit when we have external system (like OpenSearch in this case) involved (those would not be microbenchmarks anymore).The OpenSearch used to have older benchmarking suite that we never used and deprecated recently: opensearch-project/OpenSearch#21839. Would that be useful / something to replicate over?
gaobinlong commentedon Aug 20, 2026
Thanks @reta , I saw this blog: https://www.elastic.co/blog/benchmarking-rest-client-transport-client,
client/benchmarkandclient/client-benchmark-noop-api-plugintarget for benchmarking client, but the projectopensearch-benchmarktargets for benchmarking opensearch server, they're different.The benchmark module for the high level rest client can be deprecated since the high level rest client is deprecated, but for now we don't have a way to benchmark the java client in this repo(benchmark is needed for the adaptive parameters for BulkInjester what I'm doing recently), without a benchmark module, I think the contributors have to build their own benchmark suite, not friendly I think.
Also found this early feature request: #807
reta commentedon Aug 21, 2026
Thanks @gaobinlong , I am not against the benchmarking component, I am just pointing out we need to find the right sizing:
The one from Elastic / OpenSearch was targeting client (leaving aside the specifics of rest client), since opensearch-java is also a client, my question was - is the approach viable / helpful in general? Or the scaffolding is completely off and is not solving the problem.
gaobinlong commentedon Aug 27, 2026
Thanks for the clarification @reta, for BulkIngester throughput benchmarking specifically, JMH actually works well — it produces parameterized comparison tables across (maxOperations, maxSize, maxConcurrentRequests) configurations, handles JVM warmup, and gives statistically rigorous results with confidence intervals. Writing a custom harness — achieves the same comparison table but duplicates much of what JMH already provides.
It needs some investigation to find a general tool for benchmarking client, so in your opinion, if we haven't found one, we should write custom benchmark code firstly, right?
reta commentedon Aug 28, 2026
Sure, @gaobinlong , if we could use
BulkIngesterwithout externally connecting to OpenSearch (which by definition will introduce variability), self-contained test harness - that would be great.The
BulkIngesterseems to be very specific toopensearch-javaclient, I think we may not be able to find general purpose tool to benchmark it (some simple req / resp flow would certainly be easier to generalize).