DataSource stepped on the pit-spring datasource configuration

Source: Internet
Author: User

1, in front of the pit after the resttemplate, the problem comes again, because the data volume concurrent up, the database pressure is very big. The CPU has soared relative to the previous pressure. Locating issues in a Linux server Ps-ef | grep service name View PID view entire JVM memory state &NBSP;JMAP-HEAP [PID] Note that in the case of a CMS GC, the execution of jmap-heap may cause the Java process to hang to view the detailed usage of objects in the JVM heap Jmap- Histo [PID] Export memory information jmap-dump:format=b,file= file name in the entire JVM [pid]dump This step is critical jhat is a tool for analyzing JVM heap dump files from Sun 1.6 and later Based on this tool, you can analyze the memory consumption of objects in the JVM HEAP jhat-j-xmx1024m [file] waits for input in console to enter start HTTP server on port 7000 to access the Ip:7000eclipse Memory Analyzereclipse provides a plugin for analyzing JVM heap dump files. This plugin allows you to see the memory footprint of an object, reference relationships, analyze memory leaks, and more. Collected files need for the bin type, in the process of analysis, the use of Windows computer opened, direct error, after careful review, suspected memory overflow, directly into the Mac opened, then waited 10 minutes to open. Specific operation to my detailed collation and then provide reference.   When you navigate to the problem, you find that the number of configured links is too large. The default database has been unable to eat so many links. The configuration at that time was: <bean id= "DataSource" class= "Org.springframework.jdbc.datasource.DriverManagerDataSource" >< Property Name= "Driverclassname" value= "${db. Jdbc. DRIVER} "/><property name=" url "value=" ${db. Jdbc. URL} "/><property name=" username "value=" ${db. USERNAME} "/><property name=" password "value=" ${db. PASSWORD} "/></bean>  See the source code is also no related to the configuration of the number of links    so chose Ali Druid Modification, the code volume changes control in the smallest range. Maven Reference  <dependency><groupid>com.alibaba</groupid><artifactid>druid</ Artifactid><version>1.0.29</version></dependency> <bean id= "DataSource" class= " Com.alibaba.druid.pool.DruidDataSource "><!--configuration initialization size, MIN, max--><property name=" initialsize "value=" ${db . Jdbc. InitialSize} "/><property name=" Minidle "value=" ${db. Jdbc. Minldle} "/><property name=" maxactive "value=" ${db. Jdbc. Maxactive} "/><property name=" Driverclassname "value=" ${db. Jdbc. DRIVER} "/><property name=" url "value=" ${db. Jdbc. URL} "/><property name=" username "value=" ${db. USERNAME} "/><property name=" password "value=" ${db. PASSWORD} "/></bean>  and Druid also configured a number of monitoring matters, in particular, can refer to Wikihttps://github.com/alibaba/druid/wiki/%e5%b8%b8 %e8%a7%81%e9%97%ae%e9%a2%98  when the configuration is complete, go live. It found that CPU efficiency increased by more than 50% and memory was reduced by 50%.   have a picture of the truth  

From this summary, the test environment on the demo code to production, the corresponding project needs to load capacity and configuration information to evaluate, under reasonable conditions for the pressure test, so that the subsequent encounter unnecessary eight elder brother winding. The pit has passed smoothly.

DataSource stepped on the pit-spring datasource configuration

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.