【问题标题】:Hangfire: Too many connections opened on postgresHangfire:在 postgres 上打开了太多连接
【发布时间】:2019-10-29 10:54:08
【问题描述】:

我正在尝试使用 Postgres 在 C# API 上设置 Hangfire(版本 1.7.3),但我需要限制 Hangfire 在 Postgres 中使用的连接数。

app.UseHangfireServer(config => {
    config.UseServer(2); //that option does't exist for postgres
});

【问题讨论】:

  • 那么你的问题是什么?您可以按照您描述的方式限制hangfire并发。有什么问题?
  • 您使用哪个版本的 Hangfire.Postgres?上一个版本修复了连接泄漏问题。
  • Hanfire 版本是 1.7.3,Postgres 版本是 11.5。我正在使用 postgres 在数字海洋上运行 API,但它们将 postgres 数据库池限制为 22 个,而 Hangfire 使用几乎所有连接池,大约 18 个池连接。
  • @LucasClazerPerussolo .Net 连接默认是池化的。您可以在池中设置最大和最小空闲连接数。

标签: c# postgresql hangfire


【解决方案1】:

找到合适的解决方案:

var options = new BackgroundJobServerOptions { WorkerCount = 2 };
app.UseHangfireServer(options);

连接数从 20+ 下降到 6(在 heroku 上崩溃)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-12-15
    • 1970-01-01
    • 2013-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-19
    相关资源
    最近更新 更多