环境:
8核 12GB内存
服务端代码:
MessageBrokerService.Iface iface = SpringContext.getBean(MessageBrokerService.Iface.class); TServerTransport serverTransport = new TServerSocket(port); MessageBrokerService.Processor processor = new Processor(iface); Factory portFactory = new TBinaryProtocol.Factory(true, true); Args args = new Args(serverTransport); args.maxWorkerThreads(2000); args.minWorkerThreads(8); args.processor(processor); args.protocolFactory(portFactory); TServer server = new TThreadPoolServer(args); // 有多种server可选择 server.setServerEventHandler(new TServerEventHandlerImpl()); logger.info("start MessageBrokerService thrift server on port:"+port); server.serve();
测试方法:
String ping() ,返回 "PONG"字符串
性能数据描述:
concurrency:线程数
cost:耗时(毫秒)
count:执行次数
all_tps: 每秒总的TPS
per_thread_tps= all_tps / concurrency
性能测试结果:
runPingPerf,concurrency:8 cost:6821 count:200000 all_tps:29321 per_thread_tps:3665 runPingPerf,concurrency:16 cost:3586 count:200000 all_tps:55772 per_thread_tps:3485 runPingPerf,concurrency:50 cost:9318 count:200000 all_tps:21463 per_thread_tps:429 runPingPerf,concurrency:200 cost:9021 count:200000 all_tps:22170 per_thread_tps:110 runPingPerf,concurrency:8 cost:66163 count:2000000 all_tps:30228 per_thread_tps:3778 runPingPerf,concurrency:16 cost:34379 count:2000000 all_tps:58175 per_thread_tps:3635 runPingPerf,concurrency:50 cost:63974 count:2000000 all_tps:31262 per_thread_tps:625 runPingPerf,concurrency:200 cost:107447 count:2000000 all_tps:18613 per_thread_tps:93
系统负载
----total-cpu-usage---- -dsk/total- ---load-avg--- ------memory-usage----- -net/total- ---procs--- ----swap--- ---system-- usr sys idl wai hiq siq| read writ| 1m 5m 15m | used buff cach free| recv send|run blk new| used free| int csw 10 6 75 0 0 9| 0 0 | 2.7 1.9 1.7|5726M 772M 8706M 859M| 10M 11M| 4 0 0|1124M 11G| 11k 101k 9 7 76 0 0 7| 0 108k| 2.5 1.8 1.7|5720M 772M 8706M 865M| 10M 11M| 5 0 0|1124M 11G| 11k 101k