为什么从 ODP.Net 调用 Oracle 会使我的 asp.net webapi 核心的吞吐量降低 1525%?
我正在进行一些研究,以便在使用 Oracle (12g) 数据库时提高我的 ASP.NET WebAPI 核心 (5.0) 的性能。 我在此 API 中创建了两个用于测试目的的端点:
原始 helloworld api 端点:
此端点只会发回 helloworld 字符串。这是一个简单的代码。
Oracle Odp.Net api 端点: 在此端点中,我打开一个 Oracle 连接,检索 Oracle 版本并将此响应发送回客户端。
使用的代码是这样的:
string constr = "user id=scott;password=tiger;data source=oracle;CONNECTION LIFETIME=90000;MAX POOL SIZE=300;MIN POOL SIZE=20;INCR POOL SIZE=5;DECR POOL SIZE=3";
OracleConnection con = new OracleConnection(constr);
con.Open();
string connectionVersion = con.ServerVersion;
con.Dispose();
对于我的测试,我还更改了一些设置:
- ThreadPool:100 wordkerThread 和 100 iocpThread
- 数据库最大进程:500
我遇到的问题,是我在 500 个客户端线程锤击我的 API 的负载下观察到以下结果:
Api 端点 1(原始 helloworld):13 000 请求/秒
Api 端点 2(使用 odp.net):800 请求/秒
经过一些分析后,我发现大部分时间都花在了SocketPal.Receive方法上(肯定是ODP.Net使用的) :
在 odp.net 中使用 oracle 时如何获得更好的吞吐量?
这个吞吐量除以几乎 15.5(这是近 1525% 的损失)是否正常?
I am doing some research in order to increase the performance of my asp.net webapi core (5.0) when working with an oracle (12g) database.
I have made two endpoints for tests purpose in this API :
Raw helloworld api endpoint :
this endpoind will only send back a helloworld string. This is a trivial code.
Oracle Odp.Net api endpoint :
in this endpoint I am opening an oracle connection retrieve the version of oracle and send back this response to the client.
The code used is this one :
string constr = "user id=scott;password=tiger;data source=oracle;CONNECTION LIFETIME=90000;MAX POOL SIZE=300;MIN POOL SIZE=20;INCR POOL SIZE=5;DECR POOL SIZE=3";
OracleConnection con = new OracleConnection(constr);
con.Open();
string connectionVersion = con.ServerVersion;
con.Dispose();
For my tests, I had also changed some settings :
- ThreadPool : 100 wordkerThread and 100 iocpThread
- Database max process : 500
The problem that I have, is that I am observing the following results under load with 500 client threads hammering my API :
Api endpoint 1 (raw helloworld) : 13 000 request/second
Api endpoint 2 (using odp.net) : 800 request/second
After doing some profiling, I had found that most of the time is spent on the SocketPal.Receive method (surely used by ODP.Net) :
How could I get a better throughtput when using oracle with odp.net ?
Is it normal that this throughtput is divided by almost 15,5 (this is a loss of nearly 1525%) ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论