【发布时间】:2017-01-04 07:12:56
【问题描述】:
我已经使用 Ebean 设置了一个具有大量数据库访问权限的 play 2.5 项目。我将 hikaricp 配置为 maximumPoolSize=100 和 minimumIdle=100 和 hikaricp 池 100 连接成功,我还像这样配置线程池:
akka {
actor {
default-dispatcher {
executor = "thread-pool-executor"
throughput = 1
thread-pool-executor {
fixed-pool-size = 109 # db conn pool (100) + number of cores (8) + housekeeping (1)
}
}
}
}
我使用 CompletionStage 实现异步操作:
public CompletionStage<Result> asyncDb() {
CompletableFuture<Integer> future = new CompletableFuture<>().supplyAsync(() -> {
Ebean.createSqlQuery("select sleep(3)").findUnique();
return 0;
});
return future.thenApplyAsync(integer -> ok("done"));
}
我使用 sbt start 运行系统并使用 apache benchmark 对其进行测试:
ab -n 10000 -c 100 -r -k http://localhost:9000/asyncDb
问题是play只使用池中的7或8个连接,其他mysql连接空闲同时有请求,为什么?
【问题讨论】:
标签: java playframework threadpool connection-pooling playframework-2.5