Use and monitoring of proxool connection pool

Source: Internet
Author: User

Recently, I encountered a connection pool leakage problem during development, so I learned something about the connection pool and sorted it out. Most of them were obtained online.

Currently, the performance of the three mainstream connection pools is listed as follows: proxool> c3p0> DBCP. proxool also provides a visualized real-time monitoring tool for connection pools, which is stable and convenient, configuration is also very easy.

 

Currently, spring development is widely used. Let's take a look at how it is configured in spring. For specific configuration, we configure parameters in spring-properties. Here we make a reference.

<Bean id = "propertyconfigurer" <br/> class = "org. springframework. beans. factory. config. propertyplaceholderconfigurer "> <br/> <property name =" locations "> <br/> <list> <value>/WEB-INF/CONF/spring-config.properties </value> </List> <br/> </property> <br/> </bean> <br/> <bean id = "securitydatasource" class = "org. logicalcobwebs. proxool. proxooldatasource "Destroy-method =" "> <br/> <property name =" alias "> <br/> <value> securitydatasource </value> <br/> </Property> <br/> <property name = "driver"> <br/> <value >$ {security. JDBC. driver }</value> <br/> </property> <br/> <property name = "driverurl"> <br/> <value >$ {security. JDBC. URL }</value> <br/> </property> <br/> <property name = "user"> <br/> <value >$ {security. JDBC. username} </value> <br/> </property> <br/> <property name = "password"> <br/> <value >$ {security. JDBC. password }</value> <br/> </property> <br/> <property name = "maximumconnectioncount"> <br/> <value >$ {security. JDBC. maxpoolsize }</value> <br/> </property> <br/> <property name = "minimumconnectioncount"> <br/> <value >$ {security. JDBC. minpoolsize }</value> <br/> </property> <br/> <property name = "housekeepingsleeptime"> <br/> <value >$ {security. JDBC. maxidletime }</value> <br/> </property> <br/> <property name = "prototypecount"> <br/> <value >$ {security. JDBC. prototypecount }</value> <br/> </property> <br/> <property name = "trace"> <br/> <value >$ {security. JDBC. trace} </value> <br/> </property> <br/> <property name = "verbose"> <br/> <value >$ {security. JDBC. verbose} </value> <br/> </property> <br/> <property name = "maximumactivetime"> <br/> <value >$ {security. JDBC. maximumactivetime }</value> <br/> </property> <br/> <property name = "housekeepingtestsql"> <br/> <value >$ {security. JDBC. housekeepingtestsql} </value> <br/> </property> <br/> <property name = "simultaneousbuildthrottle"> <br/> <value >$ {security. JDBC. simultaneousbuildthrottle} </value> <br/> </property> <br/> <property name = "maximumconnectionlifetime"> <br/> <value >$ {security. JDBC. maximumconnectionlifetime }</value> <br/> </property> <br/> <property name = "delegateproperties"> <br/> <value >$ {security. JDBC. delegateproperties }</value> <br/> </property> <br/> </bean>

 

The following describes the configuration parameters of proxool:

House-keeping-sleep-time: the longest time for the house keeper to keep the thread in sleep state. house keeper is responsible for checking the status of each connection and determining whether to destroy or create the thread, the default value is 30 seconds.
House-keeping-test-SQL: if an idle database connection is found. house keeper will use this statement for testing. this statement should be executed very quickly. if not defined, the test process will be ignored.
Maximum-active-time: if housekeeper detects that the activity time of a thread is greater than this value. it will kill this thread. so check the bandwidth of your server. set a proper value. the default value is 5 minutes. Sometimes some people may encounter a program that is being executed and suddenly refuse to connect. The program of Mo Mingxi is suspended, which is related to the setting of this parameter. Most of our database operations will be completed within five minutes, however, some may not be completed in five minutes, and if this value is based on the default value, the connection pool will forcibly close the database connection no matter whether or not you have completed the execution, so you must set this value with caution :)
Maximum-connection-count: Maximum number of database connections. Generally, setting 30 for a large application is sufficient.
Maximum-connection-lifetime: Maximum lifetime of a thread.
Minimum-connection-count: Minimum number of database connections. Generally, it is best to initialize a part of connections in advance. For applications that connect to the database for the first time, the efficiency is relatively high. We recommend setting 5-10.
Prototype-count: number of available connections in the connection pool. if the number of connections in the current connection pool is less than this value. the new connection will be established (assuming that the maximum number of available connections is not exceeded ). for example. we have three active connections and two available connections, and our prototype-count is 4, the database connection pool will try to establish another two connections. this is different from minimum-connection-count. minimum-connection-Count counts the active connections. prototype-count is the number of spare connections.
Trace: if it is true, each executed SQL statement will be logged during the execution period (debug level). You can also register a connectionlistener (see proxoolfacade) to obtain this information.

 

We can use this bin to obtain the database connection.

 

To facilitate debugging, we also need to configure the monitoring servlet so that we can visually monitor the connection.

<Servlet> <br/> <servlet-Name> proxool </servlet-Name> <br/> <servlet-class> Org. logicalcobwebs. proxool. admin. servlet. adminservlet <rvlet-class> <br/> </servlet> <br/> <servlet-mapping> <br/> <servlet-Name> proxool </servlet-Name> <br/> <URL-pattern>/proxool </url-pattern> <br/> </servlet-mapping>

 

Enter {home_url}/proxool/in IE to access the proxool monitoring page.

 

 


 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.