In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Recently, there is a web application with a large number of 5W-10W users, which frequently causes weblogic to crash, which makes the operation and maintenance team very uncomfortable.
By tracking Syslog and weblogic operation status for several days, it is found that there are many postures that report errors, among which the key ones for positioning problems are:
ExecuteThread: '496' for queue: 'weblogic.kernel.Default (self-tuning)' has beenbusy for "712" seconds working on the request "XXXX", which is more than the configured time (StuckThreadMaxTime) of "600" seconds.
The maximum response return period assigned by weblogic to web applications is 10 minutes, and the delay in returning results by threads leads to blocking, and there are more and more such prickly threads.
After running for a period of time to reach the threshold of weblogic blocking threads, weblogic naturally crashes.
At first, try to increase the threshold of the weblogic response cycle / blocking thread, but the blocking thread still exists and reaches the threshold quickly.
Carefully compare the logs before and after the crash to see the details of weblogic blocking threads. The main culprit for blocking is that it takes a long time to query the database.
The system has data exchange with many manufacturers' systems, and there is a mixed db_link/synonyms/view/procedure in the database.
And it is an old project, the code has been modified by many people, has been crumbling, I want to recreate it is not a day or two, because many reasons can not be carried out, very helpless.
Standardize the interaction process in the database? And then change the code? Oh,no! The time limit for settlement is coming up and cannot be delayed.
So the final focus on database connection pooling also forced me to re-examine its importance to the web project. All right, let's get down to business.
Back to the top.
1. The relationship among DataSource / ConnectionPool / JNDI
DataSource: data source is a concept introduced in JDBC2.0
The Java.sql.DataSource interface is defined in the JDBC expansion pack, which is responsible for establishing a connection to the database
In the application program to access the database, there is no need to write code to connect to the database, you can obtain the database connection directly from the data source.
ConnectionPool: multiple database connections are initialized in the data source, which are stored in the connection pool (ConnectionPool).
When the Java program accesses the database, it only needs to take the idle database connection from the connection pool and return the database connection to the connection pool when the access is over.
JNDI: (Java Naming and Directory Interface) Java naming and directory interface
It provides developers with a common and unified interface to find and access various naming and directory services.
In fact, you can think of JNDI as a technology for binding objects and names, that is, specifying a resource name and associating that name with a resource or service.
Combined with the diagram and the above description, the key objects in the data layer have been exposed and are also easy to understand.
JNDI avoids the tight coupling between the program and the database, and makes the application easier to configure and deploy.
Back to the top.
two。 How and how to configure JNDI data sources
Weblogic is equipped with JNDI as a graphical interface, which is very convenient to operate, and that is the business of the operation and maintenance group, which specializes in the technical industry.
Let me take Tomcat as an example (it is impossible for you to install weblogic debugging on this machine during development), and briefly describe several ways to configure JDNI:
a. Global use: add to the context.xml configuration file under the conf folder of Tomcat:
b. Local use: add to the tag of server.xml under the conf folder of Tomcat:
Context path= "/ demo_jndi" docBase= "/ demo_jndi" >
c. Local use: apply new context.xml under META-INFO to add:
The data sources used in the above configurations are all javax.sql.DataSource, of course, you can also introduce other open source data sources.
That is, the web container uses other open source database connection pools, such as the following centralized pose (remember to add the dependent jar to the container's lib):
After the configuration, it is also quite easy to use. The core is as follows:
Context ctx = new InitialContext (); DataSource ds = (DataSource) ctx.lookup ("java:comp/env/jndi/db_test")
If Spring is introduced into the project, the above two lines of code can be saved, and changes are injected into the data source configuration, as follows:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.