【发布时间】:2021-05-24 12:30:02
【问题描述】:
我有一个身份api,该项目或多或少是具有Aspnet核心身份的入门模板。它部署在 GKE 集群上,并使用 Google Cloud sql PostgresSql 作为数据库。
我的 jmeter 测试:在 api Account/LogIn 上 30 秒内有 6000 个请求;拥有 500 万 用户的数据库
使用 npgsql 的内部轮询器和连接字符串Pooling=true;Minimum Pool Size=100;Maximum Pool Size=500
| P99 | P95 | AVG |
|---|---|---|
| 700 ms | 80 ms | 40 ms |
结果很好,但是在测试过程中 pod 的 cpu 接近 100%
在与Pooling=false的连接字符串中使用一个PgBouncer
| P99 | P95 | AVG |
|---|---|---|
| 53.22s | 48.39s | 9s |
数字不言自明
查看 postgres 日志,查询解析和绑定似乎花费了 256 毫秒,查询执行后连接在 589 毫秒后关闭。
我是否缺少一些 npgsql 配置? 为什么每个查询都有解析和绑定?
[2186] => queryPerProcess Object
(
[numQuery] => 4
[pidProcess] => 6030
[processStartTime] => 2021-02-17 16:07:10.437
[totalQueryTime] => 0.338
[lastQueryTime] => 2021-02-17 16:07:10.438
[discardQueryTime] => 2021-02-17 16:07:12.006
[closeTimeDiff] => 568
[lines] => Array
(
[0] => 6030 2021-02-17 16:07:10.437 UTC identity Identity LOG: duration: 0.112 ms parse <unnamed>: SELECT a."Id" ... etc"
[1] => 6030 2021-02-17 16:07:10.438 UTC identity Identity LOG: duration: 0.144 ms bind <unnamed>: SELECT a."Id" .. etc "
[2] => 6030 2021-02-17 16:07:10.438 UTC identity Identity LOG: duration: 0.039 ms execute <unnamed>: SELECT a."Id" .. etc"
[3] => 6030 2021-02-17 16:07:12.006 UTC identity Identity LOG: duration: 0.043 ms statement: DISCARD ALL
)
)
【问题讨论】:
标签: asp.net-core kubernetes entity-framework-core asp.net-identity npgsql