Is it acceptable to keep a db connection open for the life of the page?

前端 未结 10 2047
执念已碎
执念已碎 2021-01-18 07:11

Everybody knows that you should close a connection immediately after you finish using it.

Due to a flaw in my domain object model design, I\'ve had to leave the conn

10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-18 07:34

    No, it is not OK.

    If your application will ever need to grow or scale, you'll want to fix this issue. By holding that connection open you're reducing your ability to scale. Keep in mind that open connections take up memory on the server, memory on the client, hold open locks, etc.

提交回复
热议问题