开发者

Connection Pooling in a small application

开发者 https://www.devze.com 2023-02-25 16:26 出处:网络
I\'ve got a few simple questions about connection pooling and best practices. I\'m planning and writing a small application which relies on a MySQL database. In this application I use modules and plug

I've got a few simple questions about connection pooling and best practices. I'm planning and writing a small application which relies on a MySQL database. In this application I use modules and plug-ins which can create connections. The application has direct access to the MySQL database and it will probably be the only client connecting to the database.

Here are my first questions: Will connection pooling make sense? Is it irrelevant or should I disable it? What are your experiences?

On the other hand in my company we develop another software which has one MySQL database server and many clients. Every client can open multiple windows in which multiple connections can be active. There is a good chance that this software will be using the basic concept of my new application. The clients connect directly with the database. So I guess it would make a lot of sense to write a server application which handles the pooling and organizes the connections, am I right? How much sense would it make to let every client use it's own connection pool? We're talking about 1-50 clients with 1-10 connections.

Do you think it's the best to write a small server application to handle the connection pooling?

I'm asking because I don't really know 开发者_开发知识库when connection pooling makes sense and when not and how to handle it with small and medium sized client applications. I'm looking for some input of your experiences. :) I hope the questions is not to awkward. ^^

Greetings,

Simon

P.S.: It's a windows based application. Not a web service.


Connection pooling will give you extra performance, actually without it performance may be an issue even for a small application (it depends on the number of calls, data, etc).

Consider properly handling your connections in order to avoid 'max pool size reached' errors and timeouts. A good practice is to handle your connection like this:

using (SqlConnection conn = new SqlConnection(myConnectionString))
  {
        conn.Open();
        doSomething(conn);
  }

using guaranties than the connection will be properly closed/disposed. Check this article that provides some tips that can be applied either for MSSQL or MySQL.

Consider also the use of stored procedures. Hope this help you getting started.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号