EF registers as scoped service, which means it creates many short connections to database. One http request - one connection. PostgreSQL doesn't handle a lot of concurrent connections very well. Like a maximum of 100. Is PgBouncer needed for .NET Core applications with Entity Framework (Npgsql)? PgBouncer manages the connection pool. Or can Npgsql manage the connection pool correctly? Or is this only relevant for Python and PHP? Thanks!
Asked
Active
Viewed 1,135 times
1 Answers
3
Npgsql includes its own in-process connection pool (as is common with .NET database drivers), so using an external connection pool such as PgBouncer isn't mandatory (though it can still make sense in some scenarios for pooling connections across several client machines, etc.).

Shay Rojansky
- 15,357
- 2
- 40
- 69
-
Thanks! but MARS is not implemented in Npgsql or is it not related to correct management of connection pool? – Bogdan Rudnytskyi Dec 11 '20 at 09:21
-
Npgsql (or rather PostgreSQL) indeed has no support for MARS (it's generally a SQL Server-only feature AFAIK). And it's indeed not related to connection pooling in any way: MARS is about having multiple commands active on the *same* connection, whereas connection pooling is about pooling the connections themselves. – Shay Rojansky Dec 11 '20 at 11:12