java 如何计算 TPS

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6896862/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 17:48:40  来源:igfitidea点击:

how to calculate TPS

javaalgorithmmathlogic

提问by Abhisek

I have to built an application in java which will handle load testing on a particular application. Here we can give certain parameters like TPS (Transaction Per Second) Time (in secs) and Number of Request. I am giving you some scenario like TPS = 5 Time=100 No of Request=500. Or TPS=10 Time=100 No of request=1000

我必须在 java 中构建一个应用程序,它将处理特定应用程序的负载测试。在这里,我们可以提供某些参数,例如 TPS(每秒事务处理)时间(以秒为单位)和请求数。我给你一些场景,比如 TPS = 5 Time=100 No of Request=500。或 TPS=10 时间=100 请求数=1000

But this request I have sent using multiple Thread so the process can give the fill of concurrent transaction. My question is how to create the logic to create this. I am developing my program in java.

但是我使用多个线程发送了这个请求,因此该过程可以填充并发事务。我的问题是如何创建逻辑来创建它。我正在用java开发我的程序。

采纳答案by Alex Gitelman

Suppose you want to run 50 TPS for 100 seconds. You can have 5 threads that would send 1 transaction every 100 ms for 100 seconds. 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

假设您想以 50 TPS 的速度运行 100 秒。您可以有 5 个线程,每 100 毫秒发送 1 个事务,持续 100 秒。但是,您希望稍微随机化进程以防止线程同时发送事务。所以每个胎面的过程将是

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

That will give you average 50 TPS reasonably distributed in time. You can play around with thread count and other numbers to achieve your specific goal.

这将为您提供合理分配的平均 50 TPS。您可以使用线程数和其他数字来实现您的特定目标。