File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ #!/bin/env python3
3+
4+ import datetime
5+ import math
6+ import random
7+ import sys
8+ import time
9+
10+
11+
12+ requests_per_second = 2
13+ failure_rate = 0.05
14+ get_post_ratio = 0.9
15+ get_average_duration_ms = 500
16+ post_average_duration_ms = 2000
17+
18+
19+ while True :
20+
21+ # Exponential distribution random value of average 1/lines_per_second.
22+ d = random .expovariate (requests_per_second )
23+ time .sleep (d )
24+ if random .random () < failure_rate :
25+ status = "500"
26+ else :
27+ status = "200"
28+ if random .random () < get_post_ratio :
29+ method = "GET"
30+ duration_ms = math .floor (random .expovariate (1 / get_average_duration_ms ))
31+ else :
32+ method = "POST"
33+ duration_ms = math .floor (random .expovariate (1 / post_average_duration_ms ))
34+ timestamp = datetime .datetime .now (tz = datetime .timezone .utc ).isoformat ()
35+ print (f"{ timestamp } level=info method={ method } url=/ status={ status } duration={ duration_ms } ms" )
36+ sys .stdout .flush ()
You can’t perform that action at this time.
0 commit comments