I have written programs in PostgreSQL and npgsql recently. Since there are more than 300 customers, some of them cannot be connected.
When max_connection is adjusted to 500, the problem is solved, but the memory usage is also soaring. When some data is missing, it is estimated that the problem can be solved through two aspects:
PostgreSQL connection pool, such as pgbouncer;
Npgsql connection parameters include pooling, minpoolsize, maxpoolsize, and connectionlifetime. For more information, see npgsql's usermanual.
Solution:
1. Add pooling = false to the connection string;
In this way, the client npgsql does not keep the connection in the pool, and the connection is actually closed every time it is closed, so that the PostgreSQL Server
The related mongos.exe process is also ended. If the parallel degree is not very high, max_connection is 100 enough.
In this case, the number of worker s.exe processes on the server is reduced, and the memory usage is also reduced. The disadvantage is that you need to create a new server every time you connect to it.
The cmds.exe process wastes some CPU resources. Select whether to use this option based on the project characteristics and server configurations. If the memory is a bottleneck
2. Changed connectionlifetime, which seems to have no effect.
3. Call clearallpools (), clearpool (), and other functions to promptly clear unused connections.
4. PostgreSQL supporting software pgpool and pgbouncer on Windows platforms are currently unavailable.
You can use them to tune performance.
Http://www.powerpostgresql.com/PerfList
Http://npgsql.projects.postgresql.org/docs/manual/UserManual.html
Http://www.revsys.com/writings/postgresql-performance.html
Http://blog.sina.com.cn/s/blog_4e808acf0100afrt.html
Http://www.kakapo.cn/blog/read.php? 142