简体   繁体   中英

Do threads in rails automatically open database connections?

I have a rails app running on Heroku that makes use of threads, and it occasionally runs into database connection errors. Is this just because I am accessing the database within the threads or does each thread automatically open a database connection? I would like to learn more about threading in rails, and any resources are appreciated.

This question varies largely depending on how many instances you have running, how many requests your receiving, and more importantly your database. Databases can and will have a maximum number of concurrent connections. You can read more about Heroku/concurrent connections here in the Heroku official documentary , it's probably more informative than what I can tell you in a single comment.

That being said, your question was a little vague and it's hard to figure out what's going on. Can you tell us a little more about what error you're getting (like the specific error) and maybe a small backtrace? Are you getting these errors on the same pages or different pages? Would you say your site is particularly high traffic?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM