mod_dup for performance testing - Orange-OpenSource/mod_dup GitHub Wiki
mod_dup may be used for performance testing of your API subsystem, in particular thanks to the duplication percentage setting.
- works even with https and OAuth2, since requests are fully duplicated realtime after decryption
- the duplication in itself adds a small CPU overhead of ~10% per duplication
- works only on Apache
- You can test the capacity of your production environment with realtime true production requests multiplied by a factor. You have to be willing to bring your production to saturation for a brief moment.
A DupPreventFilter will need to be set to avoid x4 local loop of requests, since we are duplicating to the same set of servers that receive the original request. cf below.
Here is a configuration to add to your VirtualHost that will do the above:
<IfModule dup_module>
<Location /my_api_path>
DupTimeout 10000
DupApplicationScope URL_AND_HEADERS
DupDuplicationType COMPLETE_REQUEST
# Duplicate 200% to loadbalancer
DupDestination loadbalancer 200
# Avoid multiple loop: don't duplicate twice
DupPreventFilter X-DUPLICATED-REQUEST 1
# Duplicate anything
DupRawFilter ".*"
</Location>
</IfModule>
curl localhost/my_api_path
tail -f /var/log/apache2/access.log
localhost|127.0.0.1 - - [14/Feb/2018:21:44:22 +0100] 400 0 1599 0 "PNSWS31-213238611" "curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3" "GET /my_api_path? HTTP/1.1" localhost|127.0.0.1 - - [14/Feb/2018:21:44:22 +0100] 400 0 15730 0 "PNSWS31-2116462940" "curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3" "GET /my_api_path HTTP/1.1"
- You want to test the capacity of your production environment
- For that you will multiply or raise the number of requests handled by your servers with mod_dup
- You need to be quick at disabling it in case of saturation
For fastest setup, you would setup mod_dup only on one or several servers and use a high duplication percentage.
In case of saturation, just lower the duplication percentage and reload apache, a restart is not required.