Skip to content

jmdoherty/refactored-enigma

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

refactored-enigma

A fastapi app for throwing load at, using a redis back end Runs under uvicorn, listening on port 8000 by default Borrowing heavily from: https://github.com/shevron/python-redis-demo-counter

Uses environment variables of REDIS_HOST and REDIS_PORT for Redis backend Assumes localhost:6379 if not set

Routes:

GET /name - Return value of key name POST /name - Increment value of key name by 1 and return that value

Optional Query Parameters or Path to increase resource usage to service a request

Methods:

  • error - 1 in number chancee it generates a 418 error
  • loop - Loops 1M x number times before completing request
  • memory - Create a number MB string in memory before it does so, in increments of 1MB before completing request
  • slow - Randomally sleeps for up to number ms before completing the request

Sample load generation

Using Curl

Get the value of somevalue

curl -X GET 'http://localhost:8000/somevalue'

Increase the value of somevalue by 1, use the sleep method to sleep up 1000ms

curl -X POST 'http://localhost:8000/somevalue?method=sleep&number=1000'

Using wget

Get the value of somevalue, looping 5M times before returning

wget 'http://localhost:8000/somevalue?method=loop&number=5'

Get the value of somevalue, sleeping up to 5000ms before returning

  • -q : Quiet
  • -O- : Write response to STDOUT instead of file

wget -qO- --post-data '' 'http://localhost:8000/_somevalue_?method=sleep&number=5000'

Make a 100 requests to get the value of somevalue at a concurrency of 20 Using the error method to get an error 1:5 times

ab -n 100 -c 20 http://127.0.0.1:8000/_somevalue_\?method\=error\&number\=5

Make a 100 requests to increment the value of somevalue at a concurrency of 20 Using the sleep method to have each request sleep for up to 100ms

  • -n : Number of requests
  • -c : Concurrency
  • -l : Don't count the fact that the response length changes as an error
  • -p : File containing data to POST, can set to /dev/null and just use the url path but still need it to POST
  • -T : Content-type for post

ab -n 100 -c 20 -l -p /dev/null -T application/x-www-form-urlencoded http://127.0.0.1:8000/somevalue/sleep/100

Using Siege

Siege the server, sending as many requests as possible, incrementing the value of somevalue but getting an error 1 in 10 times

siege 'http://localhost:8000/what?method=error&number=10 POST'

About

Another app for throwing load at

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published