JMeter test for database connection pooling performance

Source: Internet
Author: User
Tags connection pooling flush http request thread

Use JMeter to test the performance of a database connection pool:

1. Download JMeter

2. servlet with no connection pool

Java code

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

response.setContentType("text/html");
PrintWriter out = response.getWriter();
out
.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println("  <BODY>");
out.print("    This is ");
out.print(this.getClass());
out.println(", using the GET method");
out.println("test 1000 add");

DBManager db=new DBManager();
db.getConnection();

db.addUser("persia", "persia");

out.println("  </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}

servlet condition with connection pooling:

Java code

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

response.setContentType("text/html");
PrintWriter out = response.getWriter();
out
.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println("  <BODY>");
out.print("    This is ");
out.print(this.getClass());
out.println(", using the GET method");
out.println("test 1000 add");

DBManagerByPool dbp=new DBManagerByPool();
try {
dbp.addUser("persia", "persia");
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

out.println("  </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}

3.JMeter Test Configuration:

(1) New thread group in new test plan by default

Thread number 5, loop 1000

(2) Set the HTTP request default value

(3) Add (Sampler inside)

2 HTTP requests corresponding to a pool with no connection

(4) Add listener--Aggregation report

(5) Run--Start

4. Test results:

Java code

Label # Samples Average Median 90% line Min Max Error% Throughput kb/sec

No connection Pool 5000 88 44 89 17 1012 0 35.57680677 7.052823998

Connection Pool 5000 50 45 68 10 236 0 35.59098836 7.194662686

Total 10000 69 45 78 10 1012 0 71.14247704 14.24239042

The average reaction time of the connectionless pool was found to be 88 milliseconds, while the average reaction time of the connection pool was 50 milliseconds.

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.