为什么从 ODP.Net 调用 Oracle 会使我的 asp.net webapi 核心的吞吐量降低 1525%?

发布于 2025-01-10 15:21:38 字数 1263 浏览 3 评论 0原文

我正在进行一些研究,以便在使用 Oracle (12g) 数据库时提高我的 ASP.NET WebAPI 核心 (5.0) 的性能。 我在此 API 中创建了两个用于测试目的的端点:

  1. 原始 helloworld api 端点:

    此端点只会发回 helloworld 字符串。这是一个简单的代码。
    
  2. 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 的负载下观察到以下结果:

  1. Api 端点 1(原始 helloworld):13 000 请求/秒

  2. 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 :

  1. Raw helloworld api endpoint :

    this endpoind will only send back a helloworld string. This is a trivial code.
    
  2. 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 :

  1. Api endpoint 1 (raw helloworld) : 13 000 request/second

  2. 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) :
Performance profiling

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文