Comparison of random update and insert performance of mysql under different database connection pools (DBCP,C3P0,Druid,Hikari)

The second part tests insert and update:

1 Environmental preparation

Two scenarios, Insert and Update, are prepared respectively. For the Update scenario, two scenarios are also prepared: Update through index and Update without index.

1.1 Update

The code is as follows:

package com.dhb.gts.javacourse.week6.mysqltest;

import com.dhb.gts.javacourse.fluent.dao.intf.OrderSummaryDao;
import com.dhb.gts.javacourse.fluent.entity.OrderSummaryEntity;
import com.google.common.base.Stopwatch;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

@RestController
@Slf4j
public class UpdateOrderTable {

	@Autowired
	OrderSummaryDao orderSummaryDao;

	@RequestMapping("/randomOneModifyByKey")
	public String randomModifyByKey() {
		Stopwatch stopwatch = Stopwatch.createStarted();
		Random random = new Random(System.currentTimeMillis());
//		int maxOrderId = orderSummaryDao.selectMaxOrderId();
//		int orderId = maxOrderId;
//		if(maxOrderId > 50000) {
//			orderId = random.nextInt(maxOrderId-50000)+50000;
//		}else {
//			orderId = random.nextInt(maxOrderId);
//		}
		int orderId = random.nextInt(2100000-50000)+50000;
		OrderSummaryEntity where = new OrderSummaryEntity()
				.setOrderId(orderId);
		OrderSummaryEntity 	update = new OrderSummaryEntity()
				.setConsigneeAddress("No. 19, Fangzhuang South Road, Fengtai District, Beijing")
				.setPaymentMethod(2);
		orderSummaryDao.updateBy(update,where);
		stopwatch.stop();
		System.out.println("adopt key modify key is["+where.getOrderId()+"] cost is : " + stopwatch);
		return "success";
	}

	@RequestMapping("/randomOneModifyByNo")
	public String randomOneModifyByNo() {
		Stopwatch stopwatch = Stopwatch.createStarted();
		Random random = new Random(System.currentTimeMillis());
//		int maxOrderNo = orderSummaryDao.selectMaxOrderNo();
//		int orderNo = maxOrderNo;
//		if(maxOrderNo > 10000) {
//			orderNo = random.nextInt(maxOrderNo-10000)+5000;
//		}else {
//			orderNo = random.nextInt(maxOrderNo);
//		}
		int orderNo = random.nextInt(1998425-50000)+50000;
		OrderSummaryEntity where = new OrderSummaryEntity()
				.setOrderNo(orderNo);
		OrderSummaryEntity 	update = new OrderSummaryEntity()
				.setConsigneeAddress("No. 19, Fangzhuang South Road, Fengtai District, Beijing")
				.setPaymentMethod(2);
		orderSummaryDao.updateBy(update,where);
		stopwatch.stop();
		System.out.println("adopt key modify orderNo is["+where.getOrderNo()+"] cost is : " + stopwatch);
		return "success";
	}
	
}

Although two methods are provided, one is to walk the index and one is to walk the full table scan. However, after verification, the full table scanning takes a long time, about 5 seconds. Therefore, it is meaningless to carry out load test by full table scanning.

1.2 Insert

insert method:

	@RequestMapping("/randomInsertOneOrder")
	public String randomInsertOneOrder() {
		Stopwatch stopwatch = Stopwatch.createStarted();
		int orderNo = getMaxOderNo();
		insertOrder(orderNo+1);
		log.info("randomInsertOneOrder cost time :"+ stopwatch.stop());
		return "success";
	}

Insert a row of data randomly using the method in the batch insert class provided earlier.

2.DBCP

2.1 update

$ sb -u http://127.0.0.1:8084/randomOneModifyByKey -c 2 -N 60

Starting at 2021/9/14 16:34:26
[Press C to stop the test]
11965   (RPS: 188.1)
---------------Finished!----------------
Finished at 2021/9/14 16:35:30 (took 00:01:03.8028754)
Status 200:    11965

RPS: 195.6 (requests/second)
Max: 270ms
Min: 3ms
Avg: 9.4ms

  50%   below 7ms
  60%   below 8ms
  70%   below 9ms
  80%   below 10ms
  90%   below 14ms
  95%   below 18ms
  98%   below 29ms
  99%   below 60ms
99.9%   below 117ms

$ sb -u http://127.0.0.1:8084/randomOneModifyByKey -c 5 -N 60

Starting at 2021/9/14 16:35:46
[Press C to stop the test]
19225   (RPS: 300.8)
---------------Finished!----------------
Finished at 2021/9/14 16:36:50 (took 00:01:04.1057964)
Status 200:    19225

RPS: 314.3 (requests/second)
Max: 285ms
Min: 4ms
Avg: 15ms

  50%   below 11ms
  60%   below 13ms
  70%   below 15ms
  80%   below 18ms
  90%   below 25ms
  95%   below 34ms
  98%   below 62ms
  99%   below 95ms
99.9%   below 153ms

$ sb -u http://127.0.0.1:8084/randomOneModifyByKey -c 10 -N 60

Starting at 2021/9/14 16:37:41
[Press C to stop the test]
25655   (RPS: 402.9)
---------------Finished!----------------
Finished at 2021/9/14 16:38:45 (took 00:01:03.7073633)
25656   (RPS: 402.9)                    Status 200:    25656

RPS: 419.5 (requests/second)
Max: 284ms
Min: 4ms
Avg: 22.8ms

  50%   below 17ms
  60%   below 20ms
  70%   below 23ms
  80%   below 28ms
  90%   below 38ms
  95%   below 53ms
  98%   below 94ms
  99%   below 122ms
99.9%   below 213ms

$ sb -u http://127.0.0.1:8084/randomOneModifyByKey -c 20 -N 60

Starting at 2021/9/14 16:39:16
[Press C to stop the test]
24877   (RPS: 390.7)
---------------Finished!----------------
Finished at 2021/9/14 16:40:20 (took 00:01:03.7967098)
Status 200:    24877

RPS: 406.7 (requests/second)
Max: 396ms
Min: 4ms
Avg: 47.7ms

  50%   below 38ms
  60%   below 43ms
  70%   below 49ms
  80%   below 58ms
  90%   below 79ms
  95%   below 111ms
  98%   below 152ms
  99%   below 195ms
99.9%   below 312ms

2.2 Insert

$ sb -u http://127.0.0.1:8084/randomInsertOneOrder -c 2 -N 60

Starting at 2021/9/14 16:40:56
[Press C to stop the test]
6111    (RPS: 96.1)
---------------Finished!----------------
Finished at 2021/9/14 16:42:00 (took 00:01:03.7607069)
Status 200:    6111

RPS: 99.9 (requests/second)
Max: 3529ms
Min: 7ms
Avg: 19ms

  50%   below 16ms
  60%   below 17ms
  70%   below 19ms
  80%   below 21ms
  90%   below 26ms
  95%   below 31ms
  98%   below 37ms
  99%   below 43ms
99.9%   below 80ms

$ sb -u http://127.0.0.1:8084/randomInsertOneOrder -c 5 -N 60

Starting at 2021/9/14 16:42:36
[Press C to stop the test]
11722   (RPS: 184.2)
---------------Finished!----------------
Finished at 2021/9/14 16:43:40 (took 00:01:03.8341984)
Status 200:    11722

RPS: 191.6 (requests/second)
Max: 140ms
Min: 8ms
Avg: 25ms

  50%   below 22ms
  60%   below 24ms
  70%   below 28ms
  80%   below 32ms
  90%   below 39ms
  95%   below 47ms
  98%   below 56ms
  99%   below 65ms
99.9%   below 99ms

$ sb -u http://127.0.0.1:8084/randomInsertOneOrder -c 10 -N 60

Starting at 2021/9/14 16:44:11
[Press C to stop the test]
15552   (RPS: 243.9)
---------------Finished!----------------
Finished at 2021/9/14 16:45:14 (took 00:01:03.8915896)
Status 200:    15552

RPS: 254.3 (requests/second)
Max: 150ms
Min: 11ms
Avg: 38ms

  50%   below 34ms
  60%   below 38ms
  70%   below 43ms
  80%   below 50ms
  90%   below 60ms
  95%   below 71ms
  98%   below 84ms
  99%   below 95ms
99.9%   below 123ms

$ sb -u http://127.0.0.1:8084/randomInsertOneOrder -c 20 -N 60

Starting at 2021/9/14 16:45:45
[Press C to stop the test]
16114   (RPS: 251.9)
---------------Finished!----------------
Finished at 2021/9/14 16:46:49 (took 00:01:04.0614060)
Status 200:    16114

RPS: 263.5 (requests/second)
Max: 216ms
Min: 19ms
Avg: 74ms

  50%   below 69ms
  60%   below 75ms
  70%   below 83ms
  80%   below 93ms
  90%   below 109ms
  95%   below 121ms
  98%   below 139ms
  99%   below 151ms
99.9%   below 180ms

3 C3P0

3.1 update

$ sb -u http://127.0.0.1:8084/randomOneModifyByKey -c 2 -N 60

Starting at 2021/9/14 16:53:46
[Press C to stop the test]
13215   (RPS: 206.5)
---------------Finished!----------------
Finished at 2021/9/14 16:54:50 (took 00:01:04.0950495)
Status 200:    13215

RPS: 216.1 (requests/second)
Max: 230ms
Min: 3ms
Avg: 8.5ms

  50%   below 6ms
  60%   below 7ms
  70%   below 8ms
  80%   below 9ms
  90%   below 12ms
  95%   below 17ms
  98%   below 28ms
  99%   below 50ms
99.9%   below 140ms

$ sb -u http://127.0.0.1:8084/randomOneModifyByKey -c 5 -N 60

Starting at 2021/9/14 16:54:57
[Press C to stop the test]
20706   (RPS: 325.5)
---------------Finished!----------------
Finished at 2021/9/14 16:56:00 (took 00:01:03.7819929)
Status 200:    20706

RPS: 338.5 (requests/second)
Max: 211ms
Min: 3ms
Avg: 13.9ms

  50%   below 10ms
  60%   below 11ms
  70%   below 13ms
  80%   below 17ms
  90%   below 23ms
  95%   below 32ms
  98%   below 65ms
  99%   below 95ms
99.9%   below 164ms

$ sb -u http://127.0.0.1:8084/randomOneModifyByKey -c 10 -N 60

Starting at 2021/9/14 16:57:40
[Press C to stop the test]
28039   (RPS: 439.3)
---------------Finished!----------------
Finished at 2021/9/14 16:58:44 (took 00:01:03.9884322)
Status 200:    28039

RPS: 458.4 (requests/second)
Max: 383ms
Min: 3ms
Avg: 20.8ms

  50%   below 15ms
  60%   below 18ms
  70%   below 22ms
  80%   below 27ms
  90%   below 38ms
  95%   below 53ms
  98%   below 90ms
  99%   below 121ms
99.9%   below 204ms

$ sb -u http://127.0.0.1:8084/randomOneModifyByKey -c 20 -N 60

Starting at 2021/9/14 16:58:52
[Press C to stop the test]
34082   (RPS: 535.1)
---------------Finished!----------------
Finished at 2021/9/14 16:59:56 (took 00:01:03.8173913)
Status 200:    34082

RPS: 557.2 (requests/second)
Max: 2495ms
Min: 4ms
Avg: 34.7ms

  50%   below 24ms
  60%   below 29ms
  70%   below 35ms
  80%   below 44ms
  90%   below 63ms
  95%   below 86ms
  98%   below 134ms
  99%   below 175ms
99.9%   below 367ms

3.2 Insert

$ sb -u http://127.0.0.1:8084/randomInsertOneOrder -c 2 -N 60
Starting at 2021/9/14 17:01:47
[Press C to stop the test]
7300    (RPS: 114.6)
---------------Finished!----------------
Finished at 2021/9/14 17:02:50 (took 00:01:03.8533378)
Status 200:    7300

RPS: 119.4 (requests/second)
Max: 2204ms
Min: 6ms
Avg: 15.8ms

  50%   below 14ms
  60%   below 15ms
  70%   below 16ms
  80%   below 18ms
  90%   below 22ms
  95%   below 27ms
  98%   below 34ms
  99%   below 40ms
99.9%   below 66ms

$ sb -u http://127.0.0.1:8084/randomInsertOneOrder -c 5 -N 60

Starting at 2021/9/14 17:03:56
[Press C to stop the test]
14092   (RPS: 221.5)
---------------Finished!----------------
Finished at 2021/9/14 17:04:59 (took 00:01:03.7887214)
Status 200:    14092

RPS: 230.3 (requests/second)
Max: 107ms
Min: 8ms
Avg: 20.7ms

  50%   below 18ms
  60%   below 20ms
  70%   below 23ms
  80%   below 26ms
  90%   below 31ms
  95%   below 37ms
  98%   below 45ms
  99%   below 52ms
99.9%   below 75ms

$ sb -u http://127.0.0.1:8084/randomInsertOneOrder -c 10 -N 60

Starting at 2021/9/14 17:05:37
[Press C to stop the test]
21272   (RPS: 333.9)
---------------Finished!----------------
Finished at 2021/9/14 17:06:40 (took 00:01:03.8715456)
Status 200:    21272

RPS: 347.8 (requests/second)
Max: 146ms
Min: 7ms
Avg: 27.6ms

  50%   below 24ms
  60%   below 27ms
  70%   below 30ms
  80%   below 36ms
  90%   below 43ms
  95%   below 53ms
  98%   below 63ms
  99%   below 72ms
99.9%   below 114ms

$ sb -u http://127.0.0.1:8084/randomInsertOneOrder -c 20 -N 60

Starting at 2021/9/14 17:06:47
[Press C to stop the test]
28066   (RPS: 440.7)
---------------Finished!----------------
Finished at 2021/9/14 17:07:50 (took 00:01:03.8444867)
Status 200:    28066

RPS: 458.8 (requests/second)
Max: 200ms
Min: 9ms
Avg: 42.2ms

  50%   below 37ms
  60%   below 42ms
  70%   below 47ms
  80%   below 54ms
  90%   below 67ms
  95%   below 79ms
  98%   below 97ms
  99%   below 110ms
99.9%   below 158ms

4.Druid

4.1 update

$ sb -u http://127.0.0.1:8084/randomOneModifyByKey -c 2 -N 60

Starting at 2021/9/14 16:10:41
[Press C to stop the test]
13300   (RPS: 209.2)
---------------Finished!----------------
Finished at 2021/9/14 16:11:44 (took 00:01:03.7482328)
Status 200:    13300

RPS: 217.5 (requests/second)
Max: 206ms
Min: 3ms
Avg: 8.4ms

  50%   below 6ms
  60%   below 7ms
  70%   below 8ms
  80%   below 9ms
  90%   below 12ms
  95%   below 17ms
  98%   below 28ms
  99%   below 55ms
99.9%   below 136ms

$ sb -u http://127.0.0.1:8084/randomOneModifyByKey -c 5 -N 60

Starting at 2021/9/14 16:12:17
[Press C to stop the test]
21599   (RPS: 338.8)
---------------Finished!----------------
Finished at 2021/9/14 16:13:21 (took 00:01:03.9229244)
Status 200:    21599

RPS: 353.2 (requests/second)
Max: 250ms
Min: 3ms
Avg: 13.3ms

  50%   below 9ms
  60%   below 11ms
  70%   below 13ms
  80%   below 16ms
  90%   below 22ms
  95%   below 30ms
  98%   below 56ms
  99%   below 85ms
99.9%   below 174ms

$ sb -u http://127.0.0.1:8084/randomOneModifyByKey -c 10 -N 60

Starting at 2021/9/14 16:14:07
[Press C to stop the test]
25938   (RPS: 406.4)
---------------Finished!----------------
Finished at 2021/9/14 16:15:11 (took 00:01:03.9032480)
Status 200:    25938

RPS: 424.1 (requests/second)
Max: 358ms
Min: 3ms
Avg: 22.6ms

  50%   below 17ms
  60%   below 19ms
  70%   below 23ms
  80%   below 28ms
  90%   below 39ms
  95%   below 56ms
  98%   below 96ms
  99%   below 124ms
99.9%   below 214ms

$ sb -u http://127.0.0.1:8084/randomOneModifyByKey -c 20 -N 60

Starting at 2021/9/14 16:16:45
[Press C to stop the test]
27083   (RPS: 425.8)
---------------Finished!----------------
Finished at 2021/9/14 16:17:49 (took 00:01:03.7526193)
Status 200:    27083

RPS: 442.9 (requests/second)
Max: 531ms
Min: 4ms
Avg: 43.8ms

  50%   below 34ms
  60%   below 38ms
  70%   below 44ms
  80%   below 53ms
  90%   below 73ms
  95%   below 106ms
  98%   below 153ms
  99%   below 186ms
99.9%   below 406ms

4.2 Insert

sb -u http://127.0.0.1:8084/randomInsertOneOrder -c 2 -N 60

Starting at 2021/9/14 16:20:58
[Press C to stop the test]
7224    (RPS: 113.7)
---------------Finished!----------------
Finished at 2021/9/14 16:22:02 (took 00:01:03.7367591)
Status 200:    7224

RPS: 118.1 (requests/second)
Max: 3212ms
Min: 6ms
Avg: 16ms

 50%   below 13ms
 60%   below 14ms
 70%   below 16ms
 80%   below 18ms
 90%   below 22ms
 95%   below 27ms
 98%   below 35ms
 99%   below 41ms
99.9%   below 70ms

$ sb -u http://127.0.0.1:8084/randomInsertOneOrder -c 5 -N 60

Starting at 2021/9/14 16:22:13
[Press C to stop the test]
14139   (RPS: 222.4)
---------------Finished!----------------
Finished at 2021/9/14 16:23:17 (took 00:01:03.7148356)
Status 200:    14139

RPS: 231.3 (requests/second)
Max: 102ms
Min: 7ms
Avg: 20.6ms

  50%   below 18ms
  60%   below 20ms
  70%   below 22ms
  80%   below 26ms
  90%   below 32ms
  95%   below 39ms
  98%   below 48ms
  99%   below 56ms
99.9%   below 79ms

$ sb -u http://127.0.0.1:8084/randomInsertOneOrder -c 10 -N 60

Starting at 2021/9/14 16:23:31
[Press C to stop the test]
18935   (RPS: 296.8)
---------------Finished!----------------
Finished at 2021/9/14 16:24:35 (took 00:01:03.9473026)
Status 200:    18935

RPS: 309.6 (requests/second)
Max: 159ms
Min: 8ms
Avg: 31.1ms

  50%   below 27ms
  60%   below 30ms
  70%   below 35ms
  80%   below 41ms
  90%   below 51ms
  95%   below 60ms
  98%   below 72ms
  99%   below 80ms
99.9%   below 107ms

$ sb -u http://127.0.0.1:8084/randomInsertOneOrder -c 20 -N 60

Starting at 2021/9/14 16:25:41
[Press C to stop the test]
20411   (RPS: 320.6)
---------------Finished!----------------
Finished at 2021/9/14 16:26:44 (took 00:01:03.7828596)
Status 200:    20411

RPS: 333.7 (requests/second)
Max: 209ms
Min: 15ms
Avg: 58.3ms

  50%   below 53ms
  60%   below 58ms
  70%   below 66ms
  80%   below 75ms
  90%   below 88ms
  95%   below 101ms
  98%   below 119ms
  99%   below 134ms
99.9%   below 183ms

5.Hikari

5.1 update

$ sb -u http://127.0.0.1:8084/randomOneModifyByKey -c 2 -N 60

Starting at 2021/9/14 15:50:10
[Press C to stop the test]
13091   (RPS: 205.8)
---------------Finished!----------------
Finished at 2021/9/14 15:51:14 (took 00:01:03.7557339)
Status 200:    13091

RPS: 214.1 (requests/second)
Max: 207ms
Min: 3ms
Avg: 8.6ms

  50%   below 6ms
  60%   below 7ms
  70%   below 8ms
  80%   below 10ms
  90%   below 13ms
  95%   below 18ms
  98%   below 30ms
  99%   below 58ms
99.9%   below 106ms

$ sb -u http://127.0.0.1:8084/randomOneModifyByKey -c 5 -N 60

Starting at 2021/9/14 15:52:06
[Press C to stop the test]
21052   (RPS: 331)9)
---------------Finished!----------------
Finished at 2021/9/14 15:53:10 (took 00:01:03.7767948)
Status 200:    21052

RPS: 344.2 (requests/second)
Max: 269ms
Min: 3ms
Avg: 13.7ms

  50%   below 10ms
  60%   below 11ms
  70%   below 13ms
  80%   below 16ms
  90%   below 23ms
  95%   below 32ms
  98%   below 61ms
  99%   below 97ms
99.9%   below 152ms

$ sb -u http://127.0.0.1:8084/randomOneModifyByKey -c 10 -N 60

Starting at 2021/9/14 15:53:52
[Press C to stop the test]
30200   (RPS: 475)9)
---------------Finished!----------------
Finished at 2021/9/14 15:54:56 (took 00:01:03.7583124)
Status 200:    30200

RPS: 493.7 (requests/second)
Max: 353ms
Min: 3ms
Avg: 19.3ms

  50%   below 14ms
  60%   below 16ms
  70%   below 20ms
  80%   below 25ms
  90%   below 34ms
  95%   below 48ms
  98%   below 84ms
  99%   below 110ms
99.9%   below 226ms

$ sb -u http://127.0.0.1:8084/randomOneModifyByKey -c 20 -N 60

Starting at 2021/9/14 15:55:43
[Press C to stop the test]
29998   (RPS: 469.5)
---------------Finished!----------------
Finished at 2021/9/14 15:56:47 (took 00:01:03.9178287)
30005   (RPS: 469.6)                    Status 200:    30005

RPS: 490.6 (requests/second)
Max: 359ms
Min: 4ms
Avg: 39.5ms

  50%   below 31ms
  60%   below 35ms
  70%   below 41ms
  80%   below 49ms
  90%   below 66ms
  95%   below 97ms
  98%   below 143ms
  99%   below 171ms
99.9%   below 275ms

5.2 Insert

$ sb -u http://127.0.0.1:8084/randomInsertOneOrder -c 2 -N 60

Starting at 2021/9/14 16:00:08
[Press C to stop the test]
7907    (RPS: 124.5)
---------------Finished!----------------
Finished at 2021/9/14 16:01:12 (took 00:01:03.6645126)
Status 200:    7907

RPS: 129.3 (requests/second)
Max: 83ms
Min: 6ms
Avg: 14.6ms

  50%   below 13ms
  60%   below 14ms
  70%   below 15ms
  80%   below 17ms
  90%   below 22ms
  95%   below 26ms
  98%   below 32ms
  99%   below 37ms
99.9%   below 58ms

$ sb -u http://127.0.0.1:8084/randomInsertOneOrder -c 5 -N 60

Starting at 2021/9/14 16:02:01
[Press C to stop the test]
13950   (RPS: 219)1)
---------------Finished!----------------
Finished at 2021/9/14 16:03:05 (took 00:01:03.8706084)
Status 200:    13950

RPS: 228.1 (requests/second)
Max: 96ms
Min: 8ms
Avg: 20.9ms

  50%   below 19ms
  60%   below 21ms
  70%   below 23ms
  80%   below 26ms
  90%   below 32ms
  95%   below 38ms
  98%   below 45ms
  99%   below 52ms
99.9%   below 81ms

$ sb -u http://127.0.0.1:8084/randomInsertOneOrder -c 10 -N 60

Starting at 2021/9/14 16:03:44
[Press C to stop the test]
20816   (RPS: 327.4)
---------------Finished!----------------
Finished at 2021/9/14 16:04:48 (took 00:01:03.7252700)
Status 200:    20816

RPS: 340.4 (requests/second)
Max: 114ms
Min: 9ms
Avg: 28.3ms

  50%   below 25ms
  60%   below 28ms
  70%   below 31ms
  80%   below 36ms
  90%   below 45ms
  95%   below 53ms
  98%   below 64ms
  99%   below 73ms
99.9%   below 94ms

$ sb -u http://127.0.0.1:8084/randomInsertOneOrder -c 20 -N 60

Starting at 2021/9/14 16:05:30
[Press C to stop the test]
21108   (RPS: 331.6)
---------------Finished!----------------
Finished at 2021/9/14 16:06:34 (took 00:01:03.8185660)
Status 200:    21108

RPS: 345.1 (requests/second)
Max: 183ms
Min: 17ms
Avg: 56.3ms

  50%   below 52ms
  60%   below 57ms
  70%   below 64ms
  80%   below 73ms
  90%   below 86ms
  95%   below 98ms
  98%   below 112ms
  99%   below 122ms
99.9%   below 144ms

6. Summary

Summarize the above test results

6.1 update

Concurrent numberDBCPC3P0DruidHikari
2C195.6R/S216.1R/S217.5R/S214.1R/S
5C314.3R/S325.5R/S353.2R/S344.2R/S
10C419.5R/S458.4R/S424.1R/S493.7R/S
20C406.7R/S557.2R/S442.9R/S490.6R/S

It can be found that the random update performance of C3P0 is the best, and the random update performance of DBCP is the worst. And Hikari will be better than Druid.
C3P0 > Hikari >= Druid > DBCP.

6.2 insert

Concurrent numberDBCPC3P0DruidHikari
2C99.9R/S119.4R/S118.1R/S129.3R/S
5C184.2R/S230.3R/S231.3R/S228.1R/S
10C254.3R/S347.8R/S309.6R/S340.4R/S
20C263.5R/S458.8R/S333.7R/S345.1R/S

It can be found that the random insert of C3P0 is roughly the same as that of Hikari, and the insert performance of DBCP is the worst. Druid is better than DBCP.
C3P0 >= Hikari > Druid > DBCP.

6.3 select

Review the test results of the previous select section.

Number of testsDBCPC3P0DruidHikari
5c1908.2 R/S2901.6 R/S2865.2 R/S3030.2 R/S
10c2482.5 R/S3580.4 R/s3481.4 R/S3680.4 R/S
20c2504.4 R/S3192 R/S3322.7 R/S3276.1 R/S
30c2288.4 R/S2905.8 R/S2964.6 R/S3106.4 R/S

Hikari > Druid >= C3P0 > DBCP.

6.4 summary

Summarize the test results of the above three scenarios. It can be found that:
Hikari's select performance is the best, random update is weaker than C3P0, and insert is almost the same as C3P0. Therefore, you can also understand why the default connection pool in springboot is Hikari.
Druid is relatively balanced and at the upper middle level. It belongs to the upper middle level in the three aspects of select, insert and update. Considering that Druid also has rich monitoring functions, it is also worth using in the production environment.
Although C3P0 has the same query select performance as Druid, it has the best performance in the update random modification scenario. The insert scenario is not weak. Therefore, it is also worth using in the appropriate scenario.
At present, DBCP seems that this connection pool is inferior in three dimensions. I don't know if there are any other advantage scenarios that haven't been measured.

Keywords: Java MySQL Big Data

Added by bocasz on Mon, 20 Sep 2021 22:16:23 +0300