Skip to content

Commit

Permalink
Updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rabuchaim committed Jul 23, 2024
1 parent de26ae7 commit 7816f53
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# StressAnAPI v1.0.2
# StressAnAPI v1.0.3

StressAnAPI is a Pure Python application for stress testing on APIs. Easily configurable via command line. Use the arrow keys to increase speed and bursts, see results, requests per seconds and much more.

Expand Down Expand Up @@ -46,7 +46,7 @@ There are more options that can be configured, to see them just use the `--templ
"token": "mysupertoken"
},
"headers": {
"User-Agent": "StressAnAPI v1.0.2",
"User-Agent": "StressAnAPI v1.0.3",
"Host": "set_your_api_hostname_here",
"Content-Type": "application/json",
"X-Forwarded-For": "1.2.3.4",
Expand All @@ -60,26 +60,35 @@ There are more options that can be configured, to see them just use the `--templ
202,
204
],
"user_agent": "StressAnAPI v1.0.2",
"user_agent": "StressAnAPI v1.0.3",
"start_interval": 0.5,
"start_burst": 1,
"start_threads": 1,
"cpu_affinity": [-1],
"syslog_server_url":"udp://127.0.0.1:514/local7"
}
```
- **`url`**: I think this field is self-explanatory, right?
- **`url`**: This value can accept template variables:
- %%randomipv4%% to be replaced by a random IPv4
- %%randomipv6%% to be replaced by a random IPv6
- %%randomprivateipv4%% to be replaced by a random Private IPv4
- %%randomint:val_min:val_max%% to be replaced by a random integer between 'val_min' and 'val_max'

Example:
- "url": "http://127.0.0.1:8000/api/v1/customer/%%randomint:1:10000%%",
- "url": "http://127.0.0.1:8000/api/v1/testip/%%randomipv4%%",

- **`method`**: Enter the method you want to test within the available GET, POST, PUT, PATCH and DELETE
- **`post_data`**: These are the values ​​you want to post to the API. In this version, only key and value will be accepted. If you inform the GET method, these post_data values ​​will be ignored and will not be sent in API requests.
- **`headers`**: Enter the headers you want to send to your API. The `content-type` is an important header. Headers are sent in any method.
- **`timeout`**: Enter the timeout you want to work. The application does not make retries. You can increase/decrease the timeout using the + and - keys on your keyboard to test an ideal and safe timeout value to configure on your API proxy server.
- **`success_status_codes`**: Enter the status_codes that you consider "success" to return from your API for the call you configured. This information is important in generating statistics, where only the methods reported here are considered successful. If you omit this field, by default, status codes 200, 201, 202 and 204 will be considered successful.
- **`user_agent`**: If this field is omitted, the default user-agent "StressAnAPI v1.0.2" will be used.
- **`user_agent`**: If this field is omitted, the default user-agent "StressAnAPI v1.0.3" will be used.
- **`start_interval`**: Enter the interval between one request and another. This is necessary to allow you to increase/decrease the speed of requests and evaluate how your API behaves with an increase in requests and their impacts. By default, there is a 1 second interval between each request. You can decrease/increase this interval anytime using the UP and DOWN keys on your keyboard.
- **`start_burst`**: Burst is the number of requests before an interval. You can increase and decrease the burst using the RIGHT and LEFT keys on your keyboard. By default, the application makes 1 request + interval. You can increase it to 2 requests + interval, 10 requests + interval, and so on...
- **`start_threads`**: This value simulates user concurrency in your API. Use with caution. You can increase/decrease the number of threads using the < and > keys on your keyboard.
- **`cpu_affinity`**: This is a very important option. If you omit this value, Python will use any processor and you will have concurrency in the stress test. To test the best performance of your API together with StressAnAPI, I suggest defining a CPU core to be used here. If you set the value '-1', the application will inform the Linux operating system to isolate the stressanapi.py process on the last available processor. Do a test without using this option, and then using this option, you will see that it is possible to obtain more requests if you isolate stressanapi on a single CPU core. The same thing with the API server, always leave it isolated in a core all to itself and performance will be much higher. Isolate the affinity of this process and let the operating system take care of the other processes. You can use the *psutil* library in your application to do this. Here, we are using the ```taskset -cp [core_index] [pid]``` command to stay pure Python. You can also enter more than 1 CPU Core, just enter this value as a list of integers. Ex: ```[0,1]``` and it will use the 1st and 2nd cpu core available on your machine.
- **`syslog_server_url`**: <font color=red>NEW!</font> Configure the address of your syslog server here to send request results, including the content of the responses. Supports "udp://ipaddr:port/facility", "tcp://ipaddr:port/facility" or "/dev/log". When sending to syslog you have a loss in StressAnAPI performance, but in some cases it is necessary for debugging, so this option is available. Use only if necessary.
- **`syslog_server_url`**: <font color=red>NEW!</font> Configure the address of your syslog server here to send request results, including the content of the responses. Supports "udp://ipaddr:port/facility", "tcp://ipaddr:port/facility" or "/dev/log". When sending to syslog you have a loss in StressAnAPI performance, but in some cases it is necessary for debugging, so this option is available. Use only if necessary. Give preference to the UDP protocol to minimize performance loss.

## Running the application

Expand Down Expand Up @@ -127,7 +136,7 @@ Successfully installed tornado-6.4.1
# simple_stressanapi_server.py -h
usage: simple_stressanapi_server.py [-h] [--host <ip_address>] [--port <port_number>] [--cpu <cpu_index>] [--log]

>>> Simple StressAnAPI Server v1.0.2
>>> Simple StressAnAPI Server v1.0.3

options:
-h, --help show this help message and exit
Expand Down

0 comments on commit 7816f53

Please sign in to comment.