buffer-slayer持久层吞吐量优化组件
buffer-slayer 是一个把请求在内存中 buffer 并批量发送的工具,适用于批量能显著提升性能的组件(redis-client、jdbc), 支持一对一的回调。
快速启动
io.bufferslayer
buffer-spring-jdbc
1.1.0
ReporterProperties reporterProperties = new ReporterProperties()
.setBufferedMaxMessages(500)
.setPendingMaxMessages(10000)
.setMetrics("inmemory")
.setMetricsExporter("http")
.setParallelismPerBatch(5)
.setSenderExecutor(new ThreadPoolExecutor(200,
200, 0, TimeUnit.MILLISECONDS, new SynchronousQueue()));
BatchedJdbcTemplate template = new BatchedJdbcTemplate(reporterProperties);
template.setDataSource(dataSource);
Promise promise = template.update(...);
promise.done(success -> ...)
.fail(reject -> ...);
吞吐量对比
Benchmark Mode Cnt Score Units
BatchedJdbcTemplateBenchmark.high_contention_batched thrpt 15 8709.042 ops/s
BatchedJdbcTemplateBenchmark.high_contention_unbatched thrpt 15 271.529 ops/s
BatchedJdbcTemplateBenchmark.mild_contention_batched thrpt 15 2146.595 ops/s
BatchedJdbcTemplateBenchmark.mild_contention_unbatched thrpt 15 262.621 ops/s
BatchedJdbcTemplateBenchmark.no_contention_batched thrpt 15 1194.852 ops/s
BatchedJdbcTemplateBenchmark.no_contention_unbatched thrpt 15 201.806 ops/s
评论