如何计算负载测试中要使用的并发用户数? [英] How do I calculate the number of concurrent users to use in a load test?

查看:663
本文介绍了如何计算负载测试中要使用的并发用户数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Load Impact上经常遇到此问题,所以我想将其添加到Stack Overflow社区中,以便于查找.

如何计算负载测试期间需要模拟的并发用户(VU)的数量,以使系统承受与通常在一个月,一周内会看到的相同流量的压力还是一天?

How do I calculate the number of concurrent users (VUs) that I need to simulate during a load test, in order to stress my system with the same kind of traffic that it will normally see in the course of a month, week or day?

推荐答案

运行负载测试要求您指定在测试过程中应模拟多少个并发用户.换句话说,有多少个模拟用户将处于活动状态,同时加载内容或与您的网站/应用进行交互.不幸的是,例如,在查看Google Analytics(分析)时,我们只会看到一个网站每天或每月有多少次访问.一个站点每月可以访问一百万次,但最多只能同时访问100个访问者.

Running a load test requires that you specify how many concurrent users should be simulated during testing. In other words, how many simulated users will be active, loading things or interacting with your site/app at the same time. Unfortunately, when looking at Google Analytics for example, we only see how many visits a website has per day or per month. A site can have a million visits per month, but still only ever experience max 100 concurrent visitors.

要将Google Analytics(分析)或某些其他分析系统的每X访问次数"指标转换为可用于负载测试的并发用户"指标,可以使用以下方法.

To convert the "visits per X" metric from Google Analytics, or some other analytics system, into a "concurrent users" metric that you can use for load testing, you can use the following method.

首先,找出两件事:

  1. 当您的网站/应用处于流量高峰时,您需要在短时间内进行访问的总次数.这可以通过例如通过查看例如一个小时内一个小时内访问量最高的Google Analytics(分析)一个月.查看访问量最多的一天,然后向下钻取以查看一天中的哪个小时最忙,以及您在该小时内有多少次访问.记下该值.在本文中,我将此值称为"peak_hourly_visits".

  1. You need the total number of visits for a short time period when your site/app is at peak traffic levels. This can easily be found via e.g. Google Analytics by seeing what the highest number of visits was for a single hour in the course of e.g. a month. Look at the day that has seen the highest number of visits, and drill down to see what hour of that day was the busiest and how many visits you had during that hour. Note this value down. I will call this value "peak_hourly_visits" in this text.

您需要知道用户与您的网站/应用进行交互所花费的平均时间.在Google Analytics(分析)中,这称为平均会话时长",在本文中也将其称为平均会话时长",但有时也称为网站平均时间".如果此值对您的网站/应用程序变化很大,这取决于您所看的时间段,那么为了安全起见,您可能希望使用较大的值之一.我们希望所有时间都以秒为单位,因此,例如Google Analytics(分析)会告诉您"00:03:19"(3分19秒),您应该记下199作为平均会话时长.

You need to know the average time a user spends interacting with your site/app. In Google Analytics this is called "Average session duration" and I will call it that in this text also, but sometimes it is called "Average time on site". If this value changes a lot for your site/app depending on which time period you look at you might want to use one of the larger values you find, to be on the safe side. We want all times in seconds, so if e.g. Google Analytics tells you "00:03:19" (3 minutes, 19 seconds) you should note down 199 as the average session duration.

当拥有这两个值时,您可以使用以下公式来计算要在负载测试中使用的并发用户数:

When you have those two values you use this formula to calculate the number of concurrent users to use in your load test:

假设负载测试中的每个模拟用户(VU)都表现得很真实(即很好地模拟了真实用户),那么您现在就可以使用通常只在高峰期看到的相同流量来向您的网站/应用施加压力交通时间.

Provided that each simulated user (VU) in your load test behaves realistically (i.e. simulates a real user well), you will now be able to stress your site/app with the same kind of traffic that it normally only sees during peak traffic hours.

这篇关于如何计算负载测试中要使用的并发用户数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆