是否有理由将数据库连接池与 ActiveRecord 一起使用?
使用外部连接池有什么好处?
我听说大多数其他应用程序都会为每个工作单元打开一个连接。例如,在 Rails 中,我认为这意味着每个请求都可以打开一个新连接。我假设连接池将使这成为可能。
我能想到的唯一好处是它允许您拥有 1,000 个前端进程,而无需运行 1,000 个 postgres 进程。
还有其他好处吗?
What are the benefits to using an external connection pool?
I've heard that most other applications will open up a connection for each unit of work. In Rails, for example, I'd take that to mean that each request could open a new connection. I'm assuming a connection pool would make that possible.
The only benefit I can think of is that it allows you to have 1,000 frontend processes without having 1,000 postgres processes running.
Are there any other benefits?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Rails 具有内置连接池:
自版本 2.2 起可用。您将在
database.yml
中看到一个pool
参数来控制它:我认为在其下面分层另一个池系统没有多大意义,如果您尝试的话,它甚至可能会混淆 AR 的池化。
Rails has connection pooling built in:
This has been available since version 2.2. You'll see a
pool
parameter in yourdatabase.yml
for controlling it:I don't think there would be much point in layering another pooling system underneath it and it could even confuse AR's pooling if you tried it.