Skip to content

Instantly share code, notes, and snippets.

@csrichard1
Last active August 17, 2016 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csrichard1/4b7b8527ee5a6565a84956cff33cf29b to your computer and use it in GitHub Desktop.
Save csrichard1/4b7b8527ee5a6565a84956cff33cf29b to your computer and use it in GitHub Desktop.
Keystone Revoke/Validation Benchmark

Fernet token validation

##Using 2 Revokes Time per request: 6.810 [ms] (mean)

##Using 10 Revokes Time per request: 7.908 [ms] (mean)

##Using 100 Revokes Time per request: 18.224 [ms] (mean)

##Using 1,000 Revokes Time per request: 110.155 [ms] (mean)

##Using 10,000 Revokes Time per request: 1998.220 [ms] (mean)

{"auth": {"scope": {"project": {"name": "admin", "domain": {"id": "default"}}}, "identity": {"methods": ["password"], "password": {"user": {"domain": {"id": "default"}, "name": "admin", "password": "secrete"}}}}}
#!/bin/bash
set -e
ENDPOINT="http://localhost:35357"
function authenticate() {
source ../devstack/openrc admin admin
ISSUE=`openstack token issue | grep "id"`
IFS='| |' read -a fields <<< "$ISSUE"
TOKEN=${fields[2]}
TOKEN=${TOKEN//[[:space:]]/}
}
function revokeGen(){
#To uncomment the for loop to create more revoked tokens than 1
for num in {1..8}
do
XTOKEN=`http -v POST $ENDPOINT/v3/auth/tokens @auth_request_admin.json | grep "X-Subject-Token: "`
NTOKEN=${XTOKEN##*:}
NTOKEN=${NTOKEN//[[:space:]]/}
http --print= DELETE $ENDPOINT/v3/auth/tokens X-Subject-Token:$NTOKEN X-Auth-Token:$NTOKEN
done
}
#get admin token
authenticate
ADMIN_TOKEN=$TOKEN
SUBJECT_TOKEN=$TOKEN
echo "Admin token: $ADMIN_TOKEN"
echo "Subject token: $SUBJECT_TOKEN"
revokeGen
echo "Warming up Apache..."
ab -c 100 -n 1000 -T 'application/json' $ENDPOINT/ > /dev/null 2>&1
echo "Benchmarking token validation..."
ab -r -c 1 -n 1000 -T 'application/json' -H "X-Auth-Token: $ADMIN_TOKEN" -H "X-Subject-Token: $SUBJECT_TOKEN" $ENDPOINT/v3/auth/tokens > latest_validate_token
if grep -q 'Non-2xx' latest_validate_token; then
echo 'Non-2xx return codes! Use -v 2 for more info.'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment