在多线程应用程序中,所有线程都获取与数据库的连接。这是预期的还是存在问题?

发布于 2024-09-18 04:42:32 字数 321 浏览 1 评论 0原文

我在我的应用程序中使用 NService 和 NHibernate。对于NServicebus,我们在配置文件中定义线程数。根据工作线程的线程数,它在多线程环境中工作。 有时,当所有线程都在使用并且线程获取与数据库的连接时,它不允许应用程序创建与数据库的连接。当达到最大池大小时,工作日志中出现异常。 所有线程根据连接超时释放连接。

我的问题是所有线程是否应该在使用后释放连接而不是将它们置于非活动状态 或者 它运行良好。 如果工作正常,我可以通过什么方式增加我的工人。 因为增加它会给我最大池大小的错误

I am using NService and NHibernate for my Application. As for NServicebus we define number of threads in configuration file. As per the worker's number of threads it works in multithreaded environment.
Sometime when all threads are in use and threads acquires connection with database ,it does not allow application to create connection with database. Exception comes in worker log as Max Pool size reached.
And all the threads releases the connection as per the connection timeout.

My question is whether all thread should release connection after use instead of putting them in Inactive state
Or
It is working fine.
If it is working fine what's the way by which I can increase my worker.
Because on increasing it give me error of max pool size

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深者入戏 2024-09-25 04:42:32

我认为您应该将允许的线程数设置为不超过数据库连接的最大池大小。

I think you should set the number of threads you allow to be no more then the max pool size for database connections.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文