How to know how much CPU I need for my app?

Hi, I am trying k6 for the first time. And I tested a very basic http endpoint which response result is:

{"Result":true,"Message":"You are awesome"}

Now, with the k6, and with the help of htop, I got the following test result for 1 minute with 100 users:

http_reqs: 32k/s
cpu%: 331.5
mem%: 1.6
vertual memory: 390GB
memory: 517M
Load average: 17.54 15.90 14.29

From this figure, for 100 users we needed 517M memory - it’s increases over time; so if I extend test from 1 minute to 1 hour it could go higher (maybe more than a GB) and even further when it continues serving for several days or months. Where we can see 32k/s requests are being made.

So, my question is that how do I calculate how much CPU, memory, etc. do I need it to host if my application needs 32k/s requests? I got confusion because memory is being increased over time.

I have tested it in 9 core CPU 32GB RAM.


Furthermore, I can test it successfully for 100 users but when try to test it for more than this, I start getting error:

connection reset by peer

WARN[0000] Request Failed        error="Get \"http://localhost:8086/welcome\": read tcp 127.0.0.1:55835

So, my next question is how can we test it for more 100 users, 1000 users, million users and even billion users? It fails for 2000 users as stated above:

k6 run --vus 2000 --duration 10m script.js

Hi @bhojendra

Without more context (the script that you are running, more details on your systems, etc.) I would recommend you to have a look at Running large tests.

Indeed with one load generator instance (and not clear if the system under test is the same workstation), you will eventually hit bottlenecks when increasing load to million or billion users if you are setting the same duration.

If the bottleneck was on the load generator instance, you could distribute the tests:

However, based on your message, it could well be that your system under test is the one failing with this load. Or it could be the network. I do recommend reading Running large tests with your knowledge of the systems involved in the test, and what you are trying to achieve.

I hope this helps.

Cheers!