Tutorial

This section is a tutorial for RapidHouse.

Installation

This section explains how to install RapidHouse via GitHub.

$ pip install git+https://github.com/KNCT-KPC/RapidHouse

It’s so easy.

Usage

This section explains how to tune Apache HTTP Server.

Prepare a configuration file for the server application.

You must prepare the configuration file for the server application.

$ scp user@server:/etc/httpd/conf/httpd.conf test/httpd.conf
$ vim test/httpd.conf

Then, you change some parameter value as follows:

--- httpd.conf.default	2015-03-20 01:23:09.310841200 +0900
+++ httpd.conf.template	2015-03-20 01:23:29.535293300 +0900
@@ -67,7 +67,7 @@
 #
 # Timeout: The number of seconds before receives and sends time out.
 #
-Timeout 60
+Timeout	#{ de_deeeen[0:1200] }
 
 #
 # KeepAlive: Whether or not to allow persistent connections (more than
@@ -80,13 +80,13 @@
 # during a persistent connection. Set to 0 to allow an unlimited amount.
 # We recommend you leave this number high, for maximum performance.
 #
-MaxKeepAliveRequests 100
+MaxKeepAliveRequests	#{ keep_a_live[0:1000] }
 
 #
 # KeepAliveTimeout: Number of seconds to wait for the next request from the
 # same client on the same connection.
 #
-KeepAliveTimeout 15
+KeepAliveTimeout	#{ keep_de_deeen[0:50] }
 
 ##
 ## Server-Pool Size Regulation (MPM specific)
@@ -100,12 +100,12 @@
 # MaxClients: maximum number of server processes allowed to start
 # MaxRequestsPerChild: maximum number of requests a server process serves
 <IfModule prefork.c>
-StartServers       8
-MinSpareServers    5
-MaxSpareServers   20
-ServerLimit      256
-MaxClients       256
-MaxRequestsPerChild  4000
+StartServers        #{ s_servers[0:50] }
+MinSpareServers     #{ min_spare_sv[0:10] }
+MaxSpareServers     #{ max_sp_sv[0:15] }
+ServerLimit         #{ sv_lmt[0:512] }
+MaxClients          #{ max_cli[0:512] }
+MaxRequestsPerChild	#{ uhehe[0:10000] }
 </IfModule>
 
 # worker MPM

Prepare a configuration file for RapidHouse.

You must prepare the configuration file for RapidHouse as follows:

#
#                               Welcome come on!
#             _____             _     _ _    _
#            |  __ \           (_)   | | |  | |
#            | |__) |__ _ _ __  _  __| | |__| | ___  _   _ ___  ___
#            |  _  // _` | '_ \| |/ _` |  __  |/ _ \| | | / __|/ _ \
#            | | \ \ (_| | |_) | | (_| | |  | | (_) | |_| \__ \  __/
#            |_|  \_\__,_| .__/|_|\__,_|_|  |_|\___/ \__,_|___/\___|
#                        | |
#                        |_| - Configulation file -
#
#
# = Memo
#   * When you set a relative PATH, a base of the PATH is the PATH of this file.
#

[config]
# A settings for a configuration file for a server application.
#
# The `input` is a local PATH.
# The `output` is either a local PATH or a remote PATH.
# The `backup` is a local PATH.
# RapidHouse execute a command of `$ cp output backup`. 
input = "./test/httpd.conf"
output = "/etc/httpd/conf/httpd.conf"
backup = "./test/httpd.conf.bak"


[eval]
# A settings for evaluating a server application.
#
# The `apply` is a command for that apply the configuration for the server application.
# The `wait` is a number of seconds for a interval of both applying and the evaluation.
# The `bench` is a command for the evaluation.
# The `remote` is the item for setting of that which run the `bench` on the local or the remote.
# The `score` is a regular expression for extracting a evaluated result by the `bench`.
#	RapidHouse use `$1` of a matched result.
# The `soft_name` is a name of the server application.
#	A default-value of the `soft_name` is become a extracted string from the `apply`.
apply = "service httpd reload"
wait = 5
bench = "ab -c 10 -n 100 http://localhost/"
remote = yes
score = "Requests per second:\s*([\d.]+?) \[#/sec\] \(mean\)"
soft_name = "httpd"


[ssh]
# A settings for a SSH connection with a server of tuning target.
#
# The `server` is a string such as the URI scheme that indicate the server.
#	If the `server` is the `None`, then RapidHouse will run the tuning on the local.
#	The format of the `server` is as follows: <user>@<host>[:<port>].
# The `pkey` is a RSA public key for the server.
#	If the `pkey` is the `None`, then RapidHouse will use a password to authenticate.
server = "root@192.168.1.150:22"
pkey = "test/id_rsa"


[algorithm]
# A settings for a algorithm for tuning.
#
# The `type` is a name of the algorithm.
#	Noda-chan cabinet.
type = "GA"


[log]
# A settings for logging of tuning.
#
# The `level` is a level of the log.
# The `file` is a PATH of the log file.
level = "debug"
file = "USAGI.log"

Then, save the file as “rapid_house.ini”. See also Configuration for RapidHouse .

Run

Be caught up in the darkness!

$ rapidhouse rapid_house.ini
$ vim test/httpd.conf

When you satisfied with a result of tuning, you should stop RapidHouse. In Addition, RapidHouse stops when the approximate solution is unchanged.