K6: Support network emulation options

Created on 1 Aug 2019  路  4Comments  路  Source: loadimpact/k6

It would be useful if different network conditions could be emulated during a test by introducing some latency and limiting bandwidth available to the virtual users. This helps to cover more real world cases for testing. Predefined options are nice but will need maintenance over time, probably easiest to just allow direct setting of latency and bandwidth in a test.

evaluation needed feature

Most helpful comment

@imiric, while there are certainly workarounds and other tools, I'm pretty sure we'll have to build this functionality in k6, for a few reasons:

  • as you said, it will be simpler (though, for that to be true, I'm 99% certain it will have to be done in the new HTTP API)
  • it will allow users to have exactly the same functionality in both local k6 run load tests, as well as in k6 cloud ones, which a proxy won't do
  • given the new k6 v0.27.0 scenarios, it will allow users to simulate a mix of traffic speeds - with a proxy, it will be difficult to emulate, say, 80% of VUs having broadband connections, 10% having a good mobile connection and 10% having a spotty 2G connection or something like that

So, yes, @dipeshlshah, we plan to add this feature in k6, and in our cloud service, but I can't give any promises on when it will be available yet. In order to implement it in a way that allows our users to make the most of it, we need to implement some prerequisites first.

All 4 comments

This shouldn't be too hard to do, though I'd prefer if we do it after we have custom user-definable transports. There isn't a separate issue describing that feature, I'll create one in the next few days and link to this as well as other things that depend on it, but the gist of it is described in https://github.com/loadimpact/k6/issues/1045#issuecomment-501150436.

Regarding the implementation details, I remember that I've seen a library for this in Go, but I couldn't find it. I only found these seemingly unmaintained ones:

Worst case, we'd have to roll our own, but even that shouldn't be too difficult.

My company is building app which will receive only 3g / 4g user traffic.
I do see some article from 2014 stating that Loadimpact was supporting this feature https://k6.io/blog/mobile-network-emulation-the-key-to-realistic-mobile-performance-testing-feature-release

We need this feature in order to simulate mobile user network traffic. We use Annual Pro k6 subscription to load testing and planning to upgrade in future once we grow. Can you prioritise the fix/feature ?

Wouldn't users be better off by using an external proxy to introduce latency and network issues, instead of it being part of k6 itself? This could be done by something like mitmproxy or muxy.

Sure, we could custom fit the solution to work for k6, and the UX would be better eventually, but just like for the case of CPU/RAM monitoring inside k6, I feel this would be better left out. Existing tools cover these and any other complex scenarios, and users would be better off learning these tools instead of using a k6-only solution, even if it ends up being easier to use.

@imiric, while there are certainly workarounds and other tools, I'm pretty sure we'll have to build this functionality in k6, for a few reasons:

  • as you said, it will be simpler (though, for that to be true, I'm 99% certain it will have to be done in the new HTTP API)
  • it will allow users to have exactly the same functionality in both local k6 run load tests, as well as in k6 cloud ones, which a proxy won't do
  • given the new k6 v0.27.0 scenarios, it will allow users to simulate a mix of traffic speeds - with a proxy, it will be difficult to emulate, say, 80% of VUs having broadband connections, 10% having a good mobile connection and 10% having a spotty 2G connection or something like that

So, yes, @dipeshlshah, we plan to add this feature in k6, and in our cloud service, but I can't give any promises on when it will be available yet. In order to implement it in a way that allows our users to make the most of it, we need to implement some prerequisites first.

Was this page helpful?
0 / 5 - 0 ratings