-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: introduce flagd-proxy profiling tool (#599)
Signed-off-by: James Milligan <james@omnant.co.uk>
- Loading branch information
1 parent
58eed62
commit dc4fc5c
Showing
15 changed files
with
2,071 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
profiling-results.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# flagd Proxy Profiling | ||
|
||
This go module contains a profiling tool for the `flagd-proxy`. Starting `n` watchers against a single flag configuration resource to monitor the effects of server load and flag configuration definition size on the response time between a configuration change and all watchers receiving the configuration change. | ||
|
||
## Pseudo Code | ||
|
||
1. Parse configuration file referenced as the only startup argument | ||
1. Loop for each defined repeat | ||
1. Write to the target file using the start configuration | ||
1. Start `n` watchers for the resource using a grpc sync definining the selector as `file:TARGET-FILE` | ||
1. Wait for all watchers to receive their first configuration change event (which will contain the full configuration object) | ||
1. Flush the change event channel to ensure there are no previous events | ||
1. Trigger a configuration change event by writing the end configuration to the target file | ||
1. Time how long it takes for all watchers to receive the new configuration | ||
|
||
## Example | ||
|
||
run the flagd-proxy locally (from the project root): | ||
|
||
```sh | ||
go run flagd-proxy/main.go start --port 8080 | ||
``` | ||
|
||
run the flagd-proxy-profiler (from the project root): | ||
|
||
```sh | ||
go run flagd-proxy/tests/loadtest/main.go ./flagd-proxy/tests/loadtest/config/config.json | ||
``` | ||
|
||
Once the tests have been run the results can be found in ./flagd-proxy/tests/loadtest/profiling-results.json | ||
|
||
## Sample Configuration | ||
|
||
```json | ||
{ | ||
"triggerType": "filepath", | ||
"fileTriggerConfig": { | ||
"startFile":"./start-spec.json", | ||
"endFile":"./config/end-spec.json", | ||
"targetFile":"./target.json" | ||
}, | ||
"handlerConfig": { | ||
"filePath": "./target.json", | ||
"outFile":"./profiling-results.json", | ||
"host": "localhost", | ||
"port": 8080, | ||
}, | ||
"tests": [ | ||
{ | ||
"watchers": 10000, | ||
"repeats": 5, | ||
"delay": 2000000000 | ||
} | ||
] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"fileTriggerConfig": { | ||
"startFile":"./flagd-proxy/tests/loadtest/config/start-spec.json", | ||
"endFile":"./flagd-proxy/tests/loadtest/config/end-spec.json", | ||
"targetFile":"./flagd-proxy/tests/loadtest/target.json" | ||
}, | ||
"handlerConfig": { | ||
"filePath": "./flagd-proxy/tests/loadtest/target.json", | ||
"outFile":"./flagd-proxy/tests/loadtest/profiling-results.json" | ||
}, | ||
"tests": [ | ||
{ | ||
"watchers": 10, | ||
"repeats": 5, | ||
"delay": 2000000000 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
{ | ||
"flags": { | ||
"myBoolFlag": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"on": true, | ||
"off": false | ||
}, | ||
"defaultVariant": "off" | ||
}, | ||
"myStringFlag": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"key1": "val1", | ||
"key2": "val2" | ||
}, | ||
"defaultVariant": "key1" | ||
}, | ||
"myFloatFlag": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"one": 1.23, | ||
"two": 2.34 | ||
}, | ||
"defaultVariant": "one" | ||
}, | ||
"myIntFlag": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"one": 1, | ||
"two": 2 | ||
}, | ||
"defaultVariant": "one" | ||
}, | ||
"myObjectFlag": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"object1": { | ||
"key": "val" | ||
}, | ||
"object2": { | ||
"key": true | ||
} | ||
}, | ||
"defaultVariant": "object1" | ||
}, | ||
"isColorYellow": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"on": true, | ||
"off": false | ||
}, | ||
"defaultVariant": "off", | ||
"targeting": { | ||
"if": [ | ||
{ | ||
"==": [ | ||
{ | ||
"var": [ | ||
"color" | ||
] | ||
}, | ||
"yellow" | ||
] | ||
}, | ||
"on", | ||
"off" | ||
] | ||
} | ||
}, | ||
"fibAlgo": { | ||
"variants": { | ||
"recursive": "recursive", | ||
"memo": "memo", | ||
"loop": "loop", | ||
"binet": "binet" | ||
}, | ||
"defaultVariant": "recursive", | ||
"state": "ENABLED", | ||
"targeting": { | ||
"if": [ | ||
{ | ||
"$ref": "emailWithFaas" | ||
}, "binet", null | ||
] | ||
} | ||
}, | ||
"headerColor": { | ||
"variants": { | ||
"red": "#FF0000", | ||
"blue": "#0000FF", | ||
"green": "#00FF00", | ||
"yellow": "#FFFF00" | ||
}, | ||
"defaultVariant": "red", | ||
"state": "ENABLED", | ||
"targeting": { | ||
"if": [ | ||
{ | ||
"$ref": "emailWithFaas" | ||
}, | ||
{ | ||
"fractionalEvaluation": [ | ||
"email", | ||
[ | ||
"red", | ||
25 | ||
], | ||
[ | ||
"blue", | ||
25 | ||
], | ||
[ | ||
"green", | ||
25 | ||
], | ||
[ | ||
"yellow", | ||
25 | ||
] | ||
] | ||
}, null | ||
] | ||
} | ||
} | ||
}, | ||
"$evaluators": { | ||
"emailWithFaas": { | ||
"in": ["@faas.com", { | ||
"var": ["email"] | ||
}] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
{ | ||
"flags": { | ||
"myBoolFlag": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"on": true, | ||
"off": false | ||
}, | ||
"defaultVariant": "on" | ||
}, | ||
"myStringFlag": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"key1": "val1", | ||
"key2": "val2" | ||
}, | ||
"defaultVariant": "key1" | ||
}, | ||
"myFloatFlag": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"one": 1.23, | ||
"two": 2.34 | ||
}, | ||
"defaultVariant": "one" | ||
}, | ||
"myIntFlag": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"one": 1, | ||
"two": 2 | ||
}, | ||
"defaultVariant": "one" | ||
}, | ||
"myObjectFlag": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"object1": { | ||
"key": "val" | ||
}, | ||
"object2": { | ||
"key": true | ||
} | ||
}, | ||
"defaultVariant": "object1" | ||
}, | ||
"isColorYellow": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"on": true, | ||
"off": false | ||
}, | ||
"defaultVariant": "off", | ||
"targeting": { | ||
"if": [ | ||
{ | ||
"==": [ | ||
{ | ||
"var": [ | ||
"color" | ||
] | ||
}, | ||
"yellow" | ||
] | ||
}, | ||
"on", | ||
"off" | ||
] | ||
} | ||
}, | ||
"fibAlgo": { | ||
"variants": { | ||
"recursive": "recursive", | ||
"memo": "memo", | ||
"loop": "loop", | ||
"binet": "binet" | ||
}, | ||
"defaultVariant": "recursive", | ||
"state": "ENABLED", | ||
"targeting": { | ||
"if": [ | ||
{ | ||
"$ref": "emailWithFaas" | ||
}, "binet", null | ||
] | ||
} | ||
}, | ||
"headerColor": { | ||
"variants": { | ||
"red": "#FF0000", | ||
"blue": "#0000FF", | ||
"green": "#00FF00", | ||
"yellow": "#FFFF00" | ||
}, | ||
"defaultVariant": "red", | ||
"state": "ENABLED", | ||
"targeting": { | ||
"if": [ | ||
{ | ||
"$ref": "emailWithFaas" | ||
}, | ||
{ | ||
"fractionalEvaluation": [ | ||
"email", | ||
[ | ||
"red", | ||
25 | ||
], | ||
[ | ||
"blue", | ||
25 | ||
], | ||
[ | ||
"green", | ||
25 | ||
], | ||
[ | ||
"yellow", | ||
25 | ||
] | ||
] | ||
}, null | ||
] | ||
} | ||
} | ||
}, | ||
"$evaluators": { | ||
"emailWithFaas": { | ||
"in": ["@faas.com", { | ||
"var": ["email"] | ||
}] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module github.com/open-feature/flagd/flagd-proxy/tests/loadtest | ||
|
||
go 1.19 | ||
|
||
require ( | ||
buf.build/gen/go/open-feature/flagd/grpc/go v1.3.0-20230317150644-afd1cc2ef580.1 | ||
buf.build/gen/go/open-feature/flagd/protocolbuffers/go v1.30.0-20230317150644-afd1cc2ef580.1 | ||
google.golang.org/grpc v1.53.0 | ||
) | ||
|
||
require ( | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
golang.org/x/net v0.5.0 // indirect | ||
golang.org/x/sys v0.4.0 // indirect | ||
golang.org/x/text v0.6.0 // indirect | ||
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect | ||
google.golang.org/protobuf v1.30.0 // indirect | ||
) |
Oops, something went wrong.