Fabric和Spring以及Pool

文章目录

  • 前言
  • 测试代码逻辑
  • 测试结果
    • 直连
    • 带Pool
    • 带Pool带Cache
  • 总结
  • 后记

前言

之前写了个FabricJavaPool

	implementation group: 'com.github.samyuan1990', name:'FabricJavaPool', version: '0.0.3'

最近把这个项目放到了mvn上测了一下,测试代码:
https://github.com/SamYuan1990/fabric-java-spring

测试代码逻辑

首先通过byfn 启动Fabric区块链网络
测试代码业务逻辑很简单,在8080上实现http服务器,回复"Greetings from Spring Boot! "+query a

webUI/Jemeter Java Server Blockchain Network give me "Greetings from Spring Boot! "+`query a` 3rd Round return from cache if hit. give me query a 1st Round direct link. 2nd,3rd Round Pool. 90 "Greetings from Spring Boot! "+90 webUI/Jemeter Java Server Blockchain Network

那么区别在于第一次我们不加任何cache和Pool直接连接,每次启动一个连接。
第二次我们使用Pool(FabricJavaPool)
第三次我们在最上边加个cache
笔记本电脑用jmeter,10个thread测1分钟。

测试结果

直连

惨不忍睹的直接连接。
直接连接错误了。
Fabric和Spring以及Pool_第1张图片
**46%**的错误率

Label # Samples Average Median 90% Line 95% Line 99% Line Min Max Error % Throughput Received KB/sec Sent KB/sec
Home Page 2510 568 116 162 206 412 64 111377 46.414% 17.27770 4.17 2.00
TOTAL 2510 568 116 162 206 412 64 111377 46.414% 17.27770 4.17 2.00

Fabric和Spring以及Pool_第2张图片

带Pool

webUI/Jemeter Java Server FabricJavaPool Blockchain Network give me "Greetings from Spring Boot! "+`query a` give me query a Reused Pool connection query a 90 "Greetings from Spring Boot! "+90 webUI/Jemeter Java Server FabricJavaPool Blockchain Network

318的TPS,0 error

Label # Samples Average Median 90% Line 95% Line 99% Line Min Max Error % Throughput Received KB/sec Sent KB/sec
Home Page 19122 29 28 42 46 51 12 63 0.000% 318.58849 59.73 38.27
TOTAL 19122 29 28 42 46 51 12 63 0.000% 318.58849 59.73 38.27

Fabric和Spring以及Pool_第3张图片
Fabric和Spring以及Pool_第4张图片

带Pool带Cache

webUI/Jemeter Java Server Cache FabricJavaPool Blockchain Network give me "Greetings from Spring Boot! "+`query a` give me query a hit 90 give me query a Reused Pool connection query a 90 "Greetings from Spring Boot! "+90 webUI/Jemeter Java Server Cache FabricJavaPool Blockchain Network

很粗暴的写了个cache

		Random r = new Random(10);
		double d2 = r.nextDouble()* 5;
		if(d2>4) {
			data = utils.QueryWithPool();
		}
		else {
			data = "90";
		}

28510.98407 TPS…

Label # Samples Average Median 90% Line 95% Line 99% Line Min Max Error % Throughput Received KB/sec Sent KB/sec
Home Page 1710545 0 0 1 1 1 0 520 0.000% 28510.98407 5337.74 3563.87
TOTAL 1710545 0 0 1 1 1 0 520 0.000% 28510.98407 5337.74 3563.87

Fabric和Spring以及Pool_第5张图片
Fabric和Spring以及Pool_第6张图片

总结

还是要写pool和cache。
我们从46%的错误率,到了300+的tps最后到了28510TPS…
先提高了正确率,然后提升了95倍的tps.

后记

下一步我要开始给我的pool工程加cache了

Hyperledger Fabric性能测试相关文章总结(个人向)

https://blog.csdn.net/oe1019/article/details/106445904

你可能感兴趣的:(Fabric,Hyperledger)