# sharding-jdbc-performance-test **Repository Path**: crazyYxd/sharding-jdbc-performance-test ## Basic Information - **Project Name**: sharding-jdbc-performance-test - **Description**: sharding-jdbc 和 JDBC之间的性能差异 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2021-06-30 - **Last Updated**: 2021-07-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Sharding-JDBC性能测试 ## 测试目的 > - 对比Sharding-JDBC 4.0.0-RC1与JDBC在性能上是否有较大损耗; ## 准备工作 ### 服务器 > 共使用三台windows服务器,其中两台服务器安装mysql服务,每台mysql服务器上分别有1库,每个库中分别有2个表。 > > 一台服务器部署sharding-JDBC服务,服务器配置如下: | 服务器 | 内存 | CPU | 存储 | 用途 | | ------------------------- | ---- | ---- | ---- | --------------------- | | windows server 2016 64bit | 16G | 8核 | 40GB | 安装mysql数据库 | | windows server 2016 64bit | 16G | 8核 | 40GB | 安装mysql数据库 | | windows server 2016 64bit | 8G | 8核 | 40GB | 部署sharding-JDBC服务 | ### 数据库 | 数据库 | 版本 | | ------ | ------ | | mysql | 8.0.17 | #### 建表语句 建表语句: ```sql CREATE TABLE `single_order` ( `id` bigint(50) NOT NULL AUTO_INCREMENT COMMENT '主键id', `order_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '订单id', `order_type` int(11) NULL DEFAULT NULL COMMENT '订单类型', `cust_id` int(11) NULL DEFAULT NULL COMMENT '顾客id', `cust_type` int(11) NULL DEFAULT NULL COMMENT '顾客类型', `cust_email` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '顾客邮箱', `payment_method_type` int(11) NULL DEFAULT NULL COMMENT '支付方式', `payment_provider_id` int(11) NULL DEFAULT NULL COMMENT '支付服务提供方id', `shipping_method_type` int(11) NULL DEFAULT NULL COMMENT '运输方式', `packing_type` int(11) NULL DEFAULT NULL COMMENT '包装类型', `preferred_shipping_time_type` int(11) NULL DEFAULT NULL COMMENT '发货时间类型', `receiver_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '收件人', `receiver_address` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '收件地址', `receiver_country_id` int(11) NULL DEFAULT NULL COMMENT '收件国家', `receiver_province_id` int(11) NULL DEFAULT NULL COMMENT '收件省份', `receiver_city_id` int(11) NULL DEFAULT NULL COMMENT '收件城市', `receiver_zip` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '收件邮编', `receiver_tel` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '收件人电话', `receiver_mobile_tel` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '收件人手机号', `cust_message` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '顾客备注信息', PRIMARY KEY (`id`) USING BTREE, INDEX `index_id`(`id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; SET FOREIGN_KEY_CHECKS = 1; ``` 子表结构如下: ```sql CREATE TABLE `ordert0` ( `idm` bigint(50) NOT NULL, `id` int(10) DEFAULT NULL, `order_idm` varchar(50) DEFAULT NULL, `order_typem` int(11) DEFAULT NULL, `cust_idm` int(11) DEFAULT NULL, `cust_typem` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf-8 ROW_FORMAT=DYNAMIC ``` #### 操作语句 > JDBC 插入 ```sql insert into order(order_id,order_type,cust_id,cust_type,cust_email,payment_method_type,payment_provider_id,shipping_method_type,packing_type,preferred_shipping_time_type,receiver_name,receiver_address,receiver_country_id,receiver_province_id,receiver_city_id,receiver_zip,receiver_tel,receiver_mobile_tel,cust_message) VALUES (?, 0, 10, 1, 'xzbt_yxd@163.com', 1, 6, 1, 0, 3, 'ttt ttt', '北京市朝阳区佳程广场', 9000, 111, 1, '100011', '51236117', ' ', ' '); ``` > JDBC查询 ```sql select a.id,order_id,order_type,cust_id,cust_type,cust_email,payment_method_type,payment_provider_id,shipping_method_type,packing_type,preferred_shipping_time_type,receiver_name,receiver_address,receiver_country_id,receiver_province_id,receiver_city_id,receiver_zip,receiver_tel,receiver_mobile_tel,cust_message from order? a,ordert? b where a.id=? and a.id%100=b.idm%100; ``` > JDBC更新 ```sql update order SET order_id=?,order_type=0,cust_id=10,cust_type=1,cust_email='xiaodong.yang@partner.bmw-brilliance.cn' where id=?; ``` > Sharding-JDBC 插入 ```sql INSERT INTO `order`(order_id,order_type,cust_id,cust_type,cust_email,payment_method_type,payment_provider_id,shipping_method_type,packing_type,preferred_shipping_time_type,receiver_name,receiver_address,receiver_country_id,receiver_province_id,receiver_city_id,receiver_zip,receiver_tel,receiver_mobile_tel,cust_message) VALUES (?, 0, 10, 1, 'xzbt_yxd@163.com', 1, 6, 1, 0, 3, 'ttt ttt', '北京市朝阳区佳程广场', 9000, 111, 1, '100011', '51236117', ' ', ' '); ``` > Sharding-JDBC 查询 ```sql SELECT cust_id,cust_type,cust_email,payment_method_type,payment_provider_id,shipping_method_type,packing_type,preferred_shipping_time_type,receiver_name,receiver_address,receiver_country_id,receiver_province_id,receiver_city_id,receiver_zip,receiver_tel,receiver_mobile_tel,cust_message from order a,order_item b where a.id=? and a.id%100=b.idm%100; ``` > Sharding-JDBC 更新 ```sql UPDATE order SET order_id=?,order_type=0,cust_id=10,cust_type=1,cust_email='xiaodong.yang@partner.bmw-brilliance.cn' where id=?; ``` ## 测试场景 ### JDBC业务场景 | 业务场景 | 并发请求数量 | 并发请求数量 | 并发请求数量 | 并发请求数量 | 并发请求数量 | | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | | 单库单表插入 | 200 | 500 | 1000 | 3000 | 5000 | >压测接口: > > > 汇总报告 > > 聚合报告 | 业务场景 | 数据量 | 数据量 | 数据量 | 数据量 | 数据量 | | ------------ | ------ | ------ | ------ | ------ | ------ | | 单库单表查询 | 10w | 50w | 200w | 500w | 1000w | > 压测接口: > > > > > 汇总报告 > > 聚合报告 | 业务场景 | 数据量 | 数据量 | 数据量 | 数据量 | 数据量 | | ------------ | ------ | ------ | ------ | ------ | ------ | | 单库单表更新 | 10w | 50w | 200w | 500w | 1000w | > 压测接口: > 汇总报告 > > 聚合报告 ### Sharding-JDBC业务场景 | 业务场景 | 并发请求数量 | 并发请求数量 | 并发请求数量 | 并发请求数量 | 并发请求数量 | | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | | 单库单表插入 | 200 | 500 | 1000 | 3000 | 5000 | > 压测接口: > 汇总报告 > > 聚合报告 | 业务场景 | 数据量 | 数据量 | 数据量 | 数据量 | 数据量 | | ------------ | ------ | ------ | ------ | ------ | ------ | | 单库单表查询 | 10w | 50w | 200w | 500w | 1000w | > 压测接口: > 汇总报告 > > 聚合报告 | 业务场景 | 数据量 | 数据量 | 数据量 | 数据量 | 数据量 | | ------------ | ------ | ------ | ------ | ------ | ------ | | 单库单表更新 | 10w | 50w | 200w | 500w | 1000w | > 压测接口: > 汇总报告 > > 聚合报告 ------ | 业务场景 | 并发请求数量 | 并发请求数量 | 并发请求数量 | 并发请求数量 | 并发请求数量 | | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | | 单库两表插入 | 200 | 500 | 1000 | 3000 | 5000 | > 压测接口: > 汇总报告 > > 聚合报告 | 业务场景 | 数据量 | 数据量 | 数据量 | 数据量 | 数据量 | | ------------ | ------ | ------ | ------ | ------ | ------ | | 单库两表查询 | 10w | 50w | 200w | 500w | 1000w | > 压测接口: > 汇总报告 > > 聚合报告 | 业务场景 | 数据量 | 数据量 | 数据量 | 数据量 | 数据量 | | ------------ | ------ | ------ | ------ | ------ | ------ | | 单库两表更新 | 10w | 50w | 200w | 500w | 1000w | > 压测接口: > 汇总报告 > > 聚合报告 ------ | 业务场景 | 并发请求数量 | 并发请求数量 | 并发请求数量 | 并发请求数量 | 并发请求数量 | | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | | 两库两表插入 | 200 | 500 | 1000 | 3000 | 5000 | > 压测接口: > 汇总报告 > > 聚合报告 | 业务场景 | 数据量 | 数据量 | 数据量 | 数据量 | 数据量 | | ------------ | ------ | ------ | ------ | ------ | ------ | | 两库两表查询 | 10w | 50w | 200w | 500w | 1000w | > 压测接口: > 汇总报告 > > 聚合报告 | 业务场景 | 数据量 | 数据量 | 数据量 | 数据量 | 数据量 | | ------------ | ------ | ------ | ------ | ------ | ------ | | 两库两表更新 | 10w | 50w | 200w | 500w | 1000w | > 压测接口: > 汇总报告 > > 聚合报告 ## 测试结果对比 ### JDBC单库单表和Sharding-JDBC单库单表性能对比 ### JDBC单库单表和Sharding-JDBC单库两表性能对比 ### JDBC单库单表和Sharding-JDBC两库两表性能对比 ## 测试结果概述