flagd/test/loadtest
Florian Bacher e9728aae83
feat: support new flagd.evaluation and flagd.sync schemas (#1083)
Closes #1029 

This PR introduces support for the newly introduced evaluation and sync
schemas.

Supporting both the old and new schemas involves some duplication, but I
tried to keep it as minimal as possible. I'm of course open for
suggestions for any ideas on how to make this simpler :)

See reasoning for new naming
[here](https://github.com/open-feature/flagd/issues/948).

---------

Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
2023-12-21 10:20:01 -05:00
..
.gitignore chore: move e2e tests to test (#1005) 2023-11-15 09:27:40 -05:00
README.MD chore: move e2e tests to test (#1005) 2023-11-15 09:27:40 -05:00
ff_gen.go chore: move e2e tests to test (#1005) 2023-11-15 09:27:40 -05:00
go.mod chore: move e2e tests to test (#1005) 2023-11-15 09:27:40 -05:00
go.sum chore: move e2e tests to test (#1005) 2023-11-15 09:27:40 -05:00
sample_k6.js feat: support new flagd.evaluation and flagd.sync schemas (#1083) 2023-12-21 10:20:01 -05:00

README.MD

Load Testing

This folder contains resources for flagd load testing.

  • ff_gen.go : simple, random feature flag generation utility.
  • sample_k6.js : sample K6 load test script

Profiling

It's possible to utilize profiler.go included with flagd source to profile flagd during load test. Profiling is enabled through go pprof package.

To enable pprof profiling, build a docker image with the profile.Dockerfile

ex:- docker build . -f ./flagd/profile.Dockerfile -t flagdprofile

This image now exposes port 6060 for pprof data.

Example test run

First, let's create random feature flags using ff_gen.go utility. To generate 100 boolean feature flags, run the command

go run ff_gen.go -c 100 -t boolean

This command generates random.jsonin the same directory.

Then, let's start pprof profiler enabled flagd docker container with newly generated feature flags.

docker run -p 8013:8013 -p 6060:6060 --rm -it -v $(pwd):/etc/flagd flagdprofile start --uri file:./etc/flagd/random.json

Finally, you can run the K6 test script to load test the flagd container.

k6 run sample_k6.js

To observe the pprof date, you can either visit http://localhost:6060/debug/pprof/ or use go pprof tool. Example tool usages are given below,

  • Analyze heap in command line: go tool pprof http://localhost:6060/debug/pprof/heap
  • Analyze heap in UI mode: go tool pprof --http=:9090 http://localhost:6060/debug/pprof/heap

Performance observations

flagd performs well under heavy loads. Consider the following results observed against the HTTP API of flagd,

flagd is able to serve ~20K HTTP requests/second with just 64MB memory and 1 CPU. And the impact of flag type is minimal. There was no memory pressure observed throughout the test runs.

Note on observations

Above observations were made on a single system. Hence, throughput does not account for network delays. Also, there were no background syncs or context evaluations performed.