Fabric和Spring以及Pool

文章目录

前言

之前写了个FabricJavaPool

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

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

测试代码逻辑

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

webUI/JemeterJava ServerBlockchain Networkgive me "Greetings from Spring Boot! "+`query a`3rd Round returnfrom cache if hit.give me query a1st Round directlink. 2nd,3rdRound Pool.90"Greetings from Spring Boot! "+90webUI/JemeterJava ServerBlockchain Network

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

测试结果

直连

惨不忍睹的直接连接。
直接连接错误了。
Fabric和Spring以及Pool
**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

带Pool

webUI/JemeterJava ServerFabricJavaPoolBlockchain Networkgive me "Greetings from Spring Boot! "+`query a`give me query aReused Poolconnectionquery a90"Greetings from Spring Boot! "+90webUI/JemeterJava ServerFabricJavaPoolBlockchain 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
Fabric和Spring以及Pool

带Pool带Cache

webUI/JemeterJava ServerCacheFabricJavaPoolBlockchain Networkgive me "Greetings from Spring Boot! "+`query a`give me query ahit90give me query aReused Poolconnectionquery a90"Greetings from Spring Boot! "+90webUI/JemeterJava ServerCacheFabricJavaPoolBlockchain 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
Fabric和Spring以及Pool

总结

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

后记

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

上一篇:Could not find profile: TwoOrgsOrdererGenesis.


下一篇:什么是Virtual Fabric?