How much memory for k6 VU (Virtual User)? [closed]

偶尔善良 提交于 2019-12-13 09:42:20

问题


How much memory is used by a VU (Virtual User) in k6?

Does memory usage for VUs scale linearly, i.e. if 1 VU uses X kilobytes, do 100 VUs use 100 * X kilobytes?


回答1:


How much memory a VU takes is highly dependent on what your script does and (usually more importantly) how many other files it imports/parses. Due to the fact that all VUs have their own JS VM they are separate copies of all JS files that need to be parsed. As such if you have some big JS library it will be copied between VUs and probably account for the majority of your memory usage. If your script also has some big files with a lot of test data in them - they will be copied as well and so on. In my experience simple scripts can use as little as 1-2mb or less and I have seen script go as high as 40mb in some really bad cases where they import some pretty big JS libs.

Obviously your script will use more memory during the execution, but the major source of that memory will be response bodies so we highly recommend using discardResponseBodies (At the very bottom of the page) to lower that memory usage and only set responseType where/if you need the body response.

About linearity - kind of, more or less the majority of memory in every script that I have profiled goes towards VUs once the JS scripts have been parsed in the beginning and all the VUs have been initialized. And they use around the same amount of memory but there is some memory that k6 needs for other uses depending on what you use that should be around 200-300mb.

Ultimately you will have to test your script and see. If you know that you are going to use some libraries import them without using them in order for them to parsed and to get a fast estimate. You can run k6 with --paused --no-teardown --no-setup to only initialize VUs without actually executing any of the code again for faster estimate. I recommend providing how many VUs should be ran/initialized with -u <count> for the testing. And you should wait until it says paused before a progress bar so that everything has been initialized. Be advised that k6 will use some memory to parse your JS and initialize other stuff in the beginning so you should probably start testing with at least 50 VUs and go up in order to see how much memory is being added for the additional VUs. Obliviously execution of the final script will use more memory but this should be useful for gauging purposes.



来源:https://stackoverflow.com/questions/54204227/how-much-memory-for-k6-vu-virtual-user

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!