0

将到达率从 10 更改为 100 后,laodtest 无法运行。

Artillery: 1.6.0-27 Artillery Pro: not installed Node.js: v10.15.0 OS: darwin/x64
:test $ artillery run -o report.json artillery.yml
Started phase 0, duration: 10s @ 10:01:42(+0000) 2019-03-10
.
<--- Last few GCs --->

[62621:0x102803200] 9478 ms: Mark-sweep 1392.4 (1401.5) -> 1392.3 (1401.5) MB, 20.1 / 0.0 ms (average mu = 0.439, current mu = 0.002)

请求旧空间中的最后手段 GC [62621:0x102803200] 9498 毫秒:标记扫描 1392.3 (1401.5) -> 1392.3 (1401.5) MB,20.6 / 0.0 毫秒(平均 mu = 0.277,当前 mu = 0.001)旧空间中的最后手段 GC要求的空间

<--- JS stacktrace --->

==== JS stack trace =========================================

0: ExitFrame [pc: 0x38a6205dbe3d]

Security context: 0x1da57481e6e1
1: byteLength [0x1da5274066f1] [buffer.js:526] [bytecode=0x1da597d26509 offset=126](this=0x1da5d7c5fbc1 <JSFunction

缓冲区 (sfi = 0x1da573a14251)>,string=0x1da597e082b9 ,encoding=0x1da5d92026f1 ) 2: 参数适配器帧: 1->2 3: setContentLength(aka setContentLength) [0x1da5201841e9] [/Users//.nv...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: 0x10003b125 node::Abort() [/Users//.nvm/versions/node/v10.15.0/bin/node]
2: 0x10003b32f node::OnFatalError(char const*, char const*) [/Users//.nvm/versions/node/v10.15.0/bin/node]
3: 0x1001a8e85 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char

const*, bool) [/Users//.nvm/versions/node/v10.15.0/bin/node] 4: 0x1005742a2 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users//.nvm /versions/node/v10.15.0/bin/node] 5: 0x10057d7a4 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/Users// .nvm/versions/node/v10.15.0/bin/node] 6: 0x10054f055 v8::internal::Factory::NewRawOneByteString(int, v8::internal::PretenureFlag) [/Users//.nvm/versions/node /v10.15.0/bin/node] 7: 0x1006811a8 v8::internal::String::SlowFlatten(v8::internal::Handlev8::internal::ConsString, v8::internal::PretenureFlag) [/Users// .nvm/versions/node/v10.15.0/bin/node] 8: 0x1001c6c1d v8::String::Utf8Length() const [/Users//.nvm/versions/node/v10.15.0/bin/node] 9: 0x10004eaac 节点::缓冲区::(匿名命名空间)::ByteLengthUtf8(v8::FunctionCallbackInfov8::Value const&) [/Users//.nvm/versions/node/v10.15.0/bin/node] 10: 0x10023170f v8::internal::FunctionCallbackArguments::Call(v8::internal: :CallHandlerInfo*) [/Users//.nvm/versions/node/v10.15.0/bin/node] 11: 0x100230c51 v8::internal::MaybeHandlev8::internal::Object v8::internal::(匿名命名空间) ::HandleApiCallHelper(v8::internal::Isolate*, v8::internal::Handlev8::internal::HeapObject, v8::internal::Handlev8::internal::HeapObject, v8::internal::Handlev8:: internal::FunctionTemplateInfo, v8::internal::Handlev8::internal::Object, v8::internal::BuiltinArguments) [/Users//.nvm/versions/node/v10.15.0/bin/node] 12: 0x1002302f0 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/Users//.nvm/versions/node/v10.15.0/bin/node] 13:0x38a6205dbe3d 中止陷阱:6

我的测试看起来像这样。

.yml

config:
  target: "<URL_REMOVED"
  processor: "./getData.js"
  phases:
    - duration: 10
      arrivalRate: 100
scenarios:
  - flow:
      - function: "getData"
      - post:
          url: "/api/v2/auth"
          json:
            productId: "56729b6b77c82288f746c0cf"
          capture:
            json: "$.data.token"
            as: "token"
      - post:
          url: "/api/v2/sessions"
          headers:
            Authorization: 'Bearer {{token}}'
          json:
            productId: "56729b6b77c82288f746c0cf"
            jobId: "{{jobId}}"
          capture:
            json: "$.data.session._id"
            as: "sessionId"
      - post:
          url: "/api/v2/sessions/{{sessionId}}/document"
          headers:
            Authorization: "Bearer {{token}}"
          json:
            side: "front"
            payload: "{{frontDocument}}"
      - get:
          url: "/api/v2/sessions/{{sessionId}}/metrics/front"
          headers:
            Authorization: "Bearer {{token}}"
      - get:
          url: "/api/v2/sessions/{{sessionId}}/classification"
          headers:
            Authorization: "Bearer {{token}}"
      - get:
          url: "/api/v2/sessions/{{sessionId}}/end"
          headers:
            Authorization: "Bearer {{token}}"

获取数据.js

'use strict';
var faker = require('faker');
var FRONT_ID = require("./resources/id/front.json");

module.exports = {
    getData
};

function getData(userContext, events, done) {

    let jobId = faker.random.uuid()
    userContext.vars.jobId = jobId;
    userContext.vars.frontDocument = FRONT_ID.base64;
    return done();
}
4

1 回答 1

0

您的 nodejs,即运行大炮的实例,内存不足。它的默认限制约为 1.4G。

*nix 上的 Artillery 可能从/usr/bin/artillery您使用npm install -g.

该文件的第一行很可能是

#!/usr/bin/env node

尝试将其更改为

#!/usr/bin/env node  --max-old-space-size=8192

获得8G的堆空间。但是不要占用比运行大炮的机器拥有物理 RAM 更多的堆空间,否则你会崩溃。阅读本文:如何增加 nodejs 默认内存?

编辑:问题仍然存在:为什么你的artillery进程会炸毁它的堆。看起来它在崩溃之前运行了大约 9 秒。可能是您的被测系统无法以 100 的到达率跟上您对其施加的负载。可能是炮兵不断创建和排队内存中的 post 和 get 请求,并且它们没有完成,所以他们不要被释放。您的性能日志是否给您任何提示?

负载测试的重点是找到被测系统的断点。您不会通过将十个沙袋装入船中,然后说“很酷,它可以工作”然后将 100 个沙袋倒入其中来测试船。船只会沉没。为什么要这样测试服务器?你所学到的只是它的容量在 10 到 100 之间。相反,一个沙包一个沙包地增加负载,直到系统开始出现故障。

这就是为什么火炮(实际上是大多数负载测试系统)有办法增加负载的原因。

为什么不尝试这样的事情:

- duration: 120
  arrivalRate: 10
  name: "Two minutes, ten arrivals/sec"
- duration: 600
  arrivalRate: 10
  rampTo: 100
  name: "Ten minutes, gradual ramp to 100 arrivals/sec"

一旦您知道系统发生故障的到达率,您就可以根据需要进行更详细的测试。并且,如有必要,您可以尝试重新编写代码以使其更快。

此外,10 秒的测试通常不足以收集有价值的数据。您想知道系统在稳定的高负载下的容量。

于 2019-03-10T13:07:41.623 回答