系统信息
应用逻辑 就是用c3p0 到数据库查询数据并http返回Json数据
1 调优前的最初的测试结果 JMeter test result
|
Type
|
Original
|
1000 data bigger
|
||||||||||||
1
|
500Connection
|
250 query/S
|
63q/S 70q/S |
||||||||||||
|
1000 connections
|
255q/S
|
57q/S 65 q/S
|
private void printDataConnections() { ComboPooledDataSource ds = (ComboPooledDataSource) DBConn.getDataSource(); StringBuffer connectionBuffer = new StringBuffer(); try { connectionBuffer.append("getMaxPoolSize=" + ds.getMaxPoolSize());// 最大连接数 connectionBuffer.append("getMinPoolSize=" + ds.getMinPoolSize());// 最小连接数 connectionBuffer.append("getNumBusyConnections=" + ds.getNumBusyConnections());// // 正在使用连接数 connectionBuffer.append("getNumIdleConnections=" + ds.getNumIdleConnections());// 空闲连接数 connectionBuffer.append("getNumConnections=" + ds.getNumConnections());//总连接数 logger.info(" connectionBuffer=" + connectionBuffer.toString()); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
SELECT* FROM infoobject_table where category = 'advertisement' and deleteflag=falseand (id in (select info_object_fk from timespan_table where vod_id = ? and deleteflag=false))Order By Rand() Limit
在 原来的小数据库中 数据较少 查询 时间 100ms 左右
在 1000个 video 的数据库中 查询的时间 达到 超过 1S
先注释掉 这个语句 ,想办法用优化的办法实现这个功能。
注释掉 这个 select 语句后得到的测试数据(还是计算从程序的log中打印出的 数据库select语句)Jmeter testresult
<Connector port="8080"protocol="HTTP/1.1" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" disableUploadTimeout="true" connectionTimeout="20000" acceptCount="200" maxThreads="800" minThreads="600" maxProcessors="1000" minProcessors="1000" useURIValidationHack="false" redirectPort="8443" /> 登录后复制 |
Type
|
Original
|
1000 bigger
|
1
|
500Connection
|
250 query/S
|
CPU 100%<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"destroy-method="close"> <propertyname="driverClass" value="com.mysql.jdbc.Driver" /> <property name="jdbcUrl"value="jdbc:mysql://192.168.4.112:3306/iod1000?useUnicode=true&characterEncoding=utf-8"/> <propertyname="checkoutTimeout" value="60000"/> <propertyname="idleConnectionTestPeriod" value="30"/> <propertyname="initialPoolSize" value="50"/> <property name="maxPoolSize"value="800"/> <property name="minPoolSize"value="50"/> <propertyname="maxStatements" value="100"/> <propertyname="properties"> <props> <propkey="preferredTestQuery">SELECT 1</prop> <propkey="c3p0.maxIdleTime">25000</prop> <propkey="c3p0.testConnectionOnCheckout">true</prop> <propkey="user">root</prop> <prop key="password">iptv4Um8</prop> </props> </property> </bean> 登录后复制 |
2
|
1000 connections
|
255q/S
|
160q/S 160q/S
|