简体   繁体   English

如何计算TPS

[英]how to calculate TPS

I have to built an application in java which will handle load testing on a particular application. 我必须在java中构建一个应用程序,它将处理特定应用程序的负载测试。 Here we can give certain parameters like TPS (Transaction Per Second) Time (in secs) and Number of Request. 在这里,我们可以给出某些参数,如TPS(每秒事务处理)时间(以秒为单位)和请求数。 I am giving you some scenario like TPS = 5 Time=100 No of Request=500. 我给你一些场景,如TPS = 5时间= 100 No of Request = 500。 Or TPS=10 Time=100 No of request=1000 或TPS = 10时间= 100请求数= 1000

But this request I have sent using multiple Thread so the process can give the fill of concurrent transaction. 但是我已经使用多个Thread发送了这个请求,因此该进程可以给出并发事务的填充。 My question is how to create the logic to create this. 我的问题是如何创建逻辑来创建它。 I am developing my program in java. 我正在用java开发我的程序。

Suppose you want to run 50 TPS for 100 seconds. 假设您要运行50 TPS 100秒。 You can have 5 threads that would send 1 transaction every 100 ms for 100 seconds. 您可以拥有5个线程,每100毫秒发送1个事务,持续100秒。 You,however, want to randomize the process little bit to prevent threads sending transactions at the same time. 但是,您希望稍微随机化该进程以防止线程同时发送事务。 So the process for each tread would be 所以每个胎面的过程都是如此

  • Send a transaction 发送交易
  • Wait random time between 1 and 199 ms inclusive (to average 100ms) 等待1到199毫秒之间的随机时间(平均100毫秒)
  • Repeat as long as required 根据需要重复

That will give you average 50 TPS reasonably distributed in time. 这将为您提供合理分配的平均50 TPS。 You can play around with thread count and other numbers to achieve your specific goal. 您可以使用线程计数和其他数字来实现您的特定目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM