apisix icon indicating copy to clipboard operation
apisix copied to clipboard

[proposal]: add performance testing in CI

Open idbeta opened this issue 5 years ago • 18 comments

Why

The current CI of APISIX does not have performance testing. In order to avoid the problem of performance degradation of APISIX caused by some modifications, it is necessary to add performance testing in CI.

How

Determine testing scenarios First, determine which scenarios need to be added for stress testing in CI. Because there are so many plug-ins in APISIX, it is impossible to perform stress testing on every plugin. I read the performance test reports of several api gateway vendors and found that the most common scenarios is

  1. only one simple route scenario
  2. enabled limit-count plugin scenario
  3. enabled jwt-auth plugin scenario
  4. Enable a large number of different routes scenario

Determine benchmark data In the environment of GitHub action, use wrk to perform performance test on APISIX in the specified scene. After 100 times tests, We find the average result and use it as the benchmark data.

Test Perform performance test on APISIX in CI to determine whether the QPS result is above the benchmark data. If the test result is lower than the benchmark data, it is considered that this modification has caused the performance of APISIX to decrease.

References

https://konghq.com/api-microservices-management-benchmark-apigee https://www.nginx.com/resources/library/gigaom-api-report/ https://gist.github.com/membphis/137db97a4bf64d3653aa42f3e016bd01

idbeta avatar Jan 21 '21 09:01 idbeta

The lowest result out of 5 test seems very easy to be surpassed. Maybe we could test for like 100 times, get its distribution and try to set the benchmark value

Yiyiyimu avatar Jan 21 '21 09:01 Yiyiyimu

The lowest result out of 5 test seems very easy to be surpassed. Maybe we could test for like 100 times, get its distribution and try to set the benchmark value

ok, good idea, the performance of Github action will change a lot, I tested it several times, QPS from 13300 to 21433, so different.

idbeta avatar Jan 21 '21 10:01 idbeta

ok, good idea, the performance of Github action will change a lot, I tested it several times, QPS from 13300 to 21433, so different.

Wow that indeed differs a lot. Would the average QPS like out of 5 be any kind of stable?

Yiyiyimu avatar Jan 21 '21 10:01 Yiyiyimu

ok, good idea, the performance of Github action will change a lot, I tested it several times, QPS from 13300 to 21433, so different.

Wow that indeed differs a lot. Would the average QPS like out of 5 be any kind of stable?

no, it's irregular. I think as long as the test results and the expected results do not differ too much, as long as they are within an order of magnitude, the test can be considered passed, otherwise there may be many false positives.

idbeta avatar Jan 21 '21 10:01 idbeta

@idbeta How could we know that "not differ too much" would happen, or "they are within an order of magnitude". Maybe we need some methods to get over those false positives, but not just "as long as"

Yiyiyimu avatar Jan 21 '21 12:01 Yiyiyimu

@idbeta How could we know that "not differ too much" would happen, or "they are within an order of magnitude". Maybe we need some methods to get over those false positives, but not just "as long as"

I plan to change the APISIX's worker_processes from auto to 1, then execute 10 times for each test, remove the highest and lowest values, find the average value, and compare it with the expected result (for example, I test 100 times in one route scenario, get the average value is 18942.1789. I think it can be used as the expected value of this scenario. ), which should reduce false positives.

idbeta avatar Jan 22 '21 03:01 idbeta

Cool! I think we need some data to prove the point

Yiyiyimu avatar Jan 22 '21 03:01 Yiyiyimu

Cool! I think we need some data to prove the point

Yes, I am doing tests in this area and collecting data. At present, this standard is accurate, I have run CI 5 times without false positives, but I am not sure whether there will be false positives under certain special situation, such as when the overall resources of GitHub actions are tight.

idbeta avatar Jan 22 '21 06:01 idbeta

Waiting for the test result!

Yiyiyimu avatar Jan 22 '21 07:01 Yiyiyimu

@idbeta How could we know that "not differ too much" would happen, or "they are within an order of magnitude". Maybe we need some methods to get over those false positives, but not just "as long as"

I plan to change the APISIX's worker_processes from auto to 1, then execute 10 times for each test, remove the highest and lowest values, find the average value, and compare it with the expected result (for example, I test 100 times in one route scenario, get the average value is 18942.1789. I think it can be used as the expected value of this scenario. ), which should reduce false positives.

@membphis Can you give some advice?

idbeta avatar Jan 22 '21 08:01 idbeta

I don’t think it’s a good idea to perform benchmark on github actions. We cannot know the performance of the machine behind GH and how busy CI is.

moonming avatar Jan 22 '21 08:01 moonming

I don’t think it’s a good idea to perform benchmark on github actions. We cannot know the performance of the machine behind GH and how busy CI is.

I quite agree with your point. What if testing is done via self-hosted? Is it possible to perform this test in the CI of the Apache project?

idbeta avatar Jan 22 '21 08:01 idbeta

After more than 10 tests, I determined that the test environment provided by github action is random, sometimes the performance is better, sometimes the performance is worse, the following is the result of my tests, all results are for testing only single core:

APISIX QPS		CPU performance		Division result
21331			3620				5.892541436464088
21150			3424				6.176985981308411
23533			4122				5.709121785541
23739			3965				5.987137452711223
23093			3463				6.668495524112042
23149			3408				6.792546948356808
16586			3791				4.375098918491163
28767			4482				6.418340026773762
22673			3735				6.07041499330656
25898			4126				6.276781386330587
13530			3393				3.98762157382847
20307			3416				5.944672131147541
23424			4214				5.558614143331751

The machine environment corresponding to these results is as follows (obtained by cat /proc/cpuinfo | grep'model name'):

model name	: Intel(R) Xeon(R) CPU E5-2673 v4 @ 2.30GHz
model name	: Intel(R) Xeon(R) CPU E5-2673 v3 @ 2.40GHz
model name	: Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz
model name	: Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz

It can be seen that the environment of each test is different, so the test results are not comparable.

idbeta avatar Jan 25 '21 10:01 idbeta

I quite agree with your point. What if testing is done via self-hosted? Is it possible to perform this test in the CI of the Apache project?

I think this should be fine. You can make a try

membphis avatar Jan 25 '21 15:01 membphis

I have used self-hosted in other projects for performance testing and found that it is feasible, but after checking Apache's official documentation, I found that although Apache allows using self-hosted for testing, it is not recommended. I checked a lot of well-known Apache projects (apache/echarts, apache/incubator-doris, apache/skywalking, apache/shardingsphere, etc.), but I haven't found any project using self-hosted for testing. https://infra.apache.org/self-hosted-runners.html I think this test is not suitable for APISIX, I hope to hear the opinions of the community.

idbeta avatar Jan 26 '21 03:01 idbeta

It is not quite often when we need to know the benchmark result for every commits, until something big changes, and I think it's enough to provide benchmark scripts for now :-)

sysulq avatar Jan 29 '21 08:01 sysulq

benchmark scripts

The purpose of automated performance testing is to add a quality assurance method. benchmark scripts are of course very good, but they need to be run manually. If can automatically run and get a result, telling the PR does not affect performance, it would be better, isn't it? And it will not increase the CI execution time. Of course, because of the Apache policy...

idbeta avatar Jan 29 '21 08:01 idbeta

It is not quite often when we need to know the benchmark result for every commits, until something big changes, and I think it's enough to provide benchmark scripts for now :-)

yes, agree. so I think we can close this issue. @idbeta if you want to do this job, feel free to reopen this issue ^_^

membphis avatar Jan 29 '21 14:01 membphis