You can get good settings during sleeping ;)
First it is necessary to prepare to the point where an ordinary stress test is possible. Please prepare the server to be used for attacking in a location that is close (in terms of network) to the target. Suitable specifications are required for the Attacker as well.
Anything is acceptable as a stress tool providing that it can be used from a command line. Although
ab(Apache Bench) etc. have been included from the beginning and therefore would be simple, this time, a software called green-hakai was used. (The installation instructions for
green-hakai are available from the product’s website)
When performing automatic tuning, the target (= sever group of the tuning target) is controlled by Chef and it is necessary that the parameters become attributes of Chef. For example, when the template
httpd.conf becomes as shown:
MaxClients are to be made attribute of Chef, do it as follows:
MaxClients <%= node["httpd"]["max_clients"] %>
When in this state, by writing as shown below in
nodes/www-1.example.json, it is possible to control
MaxClients of the
As a result of rewriting this JSON, deploying it to the target by using Chef, and then applying the stress test, it will be
gargor (the new software) that searches the new test parameter using GA.
gargor by doing the following: (Ruby 1.9.3 or higher is required)
$ [sudo] gem install gargor
gargor.rb under the Chef repository. Rewrite the contents as necessary.
# generations: set > 1
# individuals number of some generation.
# elite number of some generation.(carried over)
# Probability of mutation set "0.01" to "1%" (when crossover)
# target cook command : '%s' will replace by node name.
target_cooking_cmd "knife solo cook %s"
# target nodes
# performing target_cooking_command before the attack.
# attack command
attack_cmd "ssh attacker.example ./bin/ghakai www-1.example.yml 2>/dev/null"
# evalute of the attack
# code: exit code of attack_cmd command (0 => succees)
# out: standard output of attack_cmd command
# time: execute time of attack_cmd
evaluate do |code,out,time|
fitness = 0
# get "FAILED" count from stadard output of stress-tool,
# and set fitess to 0 when FAILED > 0.
if time > 0 && code == 0 && /^FAILED (\d+)/ =~ out && $1 == "0"
# get fitness from stadard output of stress-tool.
# e.g.: request count:200, concurrenry:20, 45.060816 req/s
if /, ([\.\d]+) req\/s/ =~ out
fitness = $1.to_f
# To get fitness simply,to use execution time
# fitness = 1/time
# This block must return the fitness.(integer or float)
# definition of parameters(GA)
# param _name_ do
# json_file: Chef parameter(JSON) file (such as nodes/*.json or roles/*.json)
# (Warning!) gargor will overwrite their json files.
# json_path: to locate the value by JSONPath
# mutaion: to set value when mutaion
param "max_clients" do
param "innodb_log_file_size" do
param "sort_buffer_size" do
param "read_buffer_size" do
param "query_cache_size" do
When using something other than
green-hakai, it will be necessary to customize
# fitness = 1/time
However, by removing the comment out of this part, it is possible to decide a rough score by the (inverse number of) the measurement time.
gargor performs the stress test for the number of (number of generations * number of individuals) at the maximum and searches for parameters that appear good. As it takes a long time, it is probably best to run when finishing work for the day in order to confirm the results the next morning.
Of course, it is possible to perform multiple settings for parameters.
As GA is used, there are erratic elements, and unless the software is tried, it is unknown whether good results will be output. If the number of individuals and the number of generations are increased, it will take longer but the precision will be improved. Also, because the precision also changes depending on how
mutation is written, the user is encouraged to try many things.
gargor is only just-created software, please report bugs and fixes to
github. Developer is waiting for pull-request.