Load balancer service is a REST service which expose one endpoint
- /route?id=${userid} - takes userid and return one of the weighted group defined in externally delivered properties file
For generate jar file run
- mvn package
Application is spring boot repacked jar, which can be run using command:
- java -jar TP-LOAD-BALANCER-1.0-SNAPSHOT.jar --spring.config.location=file:{externally.delivered.properties}
Weighted groups should be defined as a touple in format
- groupsWeights={GroupName:'number', .... } - where number is percentage distribution of requests among groups divided by ten
Properties should also specify consistent hashing buckets number, which currently have to has value 10. - numberOfBuckets=10
Example of properties file content:
groupsWeights={GroupA:'2',GroupB:'2',GroupC:'4',GroupD:'2'}
numberOfBuckets=10
Project has Dockerfile delivered. following command creates docker image:
- docker build -t docker_image_tag .
Then run docker image with command:
- docker run -d -p 8080:8080 docker_image_tag
When running on Windows service should be reached using address retrieved by command:
- docker-machine ip default
While service is running it can be reached with wget
- wget http://${ip}:8080/route?id={alphanumeric_id}
Project contains functional main.test which verifies requests distribution among predefined, weighted groups
FunctionalTestRunner - periodicaly reports requests distribution among groups.
When running main.test it should also have --spring.config.location=file:{externally.delivered.properties} passed as a program parameter.
Example of report:
functional.config.FakeClient : 20.346608898516912 percentage of traffic goes to group GroupA
functional.config.FakeClient : 20.113314447592067 percentage of traffic goes to group GroupB
functional.config.FakeClient : 39.27678720213298 percentage of traffic goes to group GroupC
functional.config.FakeClient : 20.32994500916514 percentage of traffic goes to group GroupD
For performance tests wrk application was used. It can be retrieved from https://github.com/wg/wrk.
In order to achieve different user id for each requests loadtest.lua script is delivered.
Example of usage:
- wrk -t 2 -c 2 -d test_duration -s /path/to/loadtest.lua http://${ip}:8080
Five main.test runs was performed on:
CPU: Intel Core i5 72000
2 Cores 2,5GHz
RAM: 8GB
results: https://docs.google.com/spreadsheets/d/1XC8VOSM4L2ZlT0494aP55feKyJ5BPECpg0vcNsmh1d4/edit?usp=sharing
- Average throughput was: 11909 Req/sec
- Average latency was 521.244 micro seconds