Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Pooling with Entity Framework

I'm using entity framework 6 on multiple applcations. All of this applications (around 10) make use of the same database. In some cases (when there are lots of connections at the same time, I believe), applications won't work, the exception is "underlying provider failed on open". I made some research and I found out entity framework's default max pool connections is 100, so I increase that number to 1,000 in most of the applications. Is it poosible that if I left one application with the 100 default, my other applications will stop working too? As I understand, entity framework tells SQL how many connections will be available, but are this connections for the application only or is it general?

like image 337
user1416072 Avatar asked Dec 08 '25 07:12

user1416072


1 Answers

As I suspected, all the applications making connections to the same sql instance must change it's connection string to allow more than entity's framework default connections (100).

Scenario:

Application 1 and 2 have MaxPoolSize = 1000. Application 3 has MaxPoolSize = 100.

Application 1 and 2 are making connections to SQL, the current connections are 200... Everything works fine.

Application 3 tries to make a connection to SQL, it's configuration tells SQL that the max pool size is only 100, so SQL blocks the pooling, until connections timeout and are under 100.

In other words, you have to make sure all MaxPoolSize are changed from the default 100 to avoid this problem, in this case I changed all of them to allow a max of 1000 connections.

like image 78
user1416072 Avatar answered Dec 12 '25 12:12

user1416072



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!