buffer-slayer是一个把请求在内存中buffer并批量发送的工具,适用于批量能显著提升性能的组件(redis-client、jdbc),支持一对一的回调。
快速启动io.bufferslayerbuffer-spring-jdbc1.1.0ReporterProperties 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 -> ...);吞吐量对比BenchmarkModeCntScoreUnitsBatchedJdbcTemplateBenchmark.high_contention_batchedthrpt158709.042ops/sBatchedJdbcTemplateBenchmark.high_contention_unbatchedthrpt15271.529ops/sBatchedJdbcTemplateBenchmark.mild_contention_batchedthrpt152146.595ops/sBatchedJdbcTemplateBenchmark.mild_contention_unbatchedthrpt15262.621ops/sBatchedJdbcTemplateBenchmark.no_contention_batchedthrpt151194.852ops/sBatchedJdbcTemplateBenchmark.no_contention_unbatchedthrpt15201.806ops/s
评论