atune:add tuning example for nginx

This commit is contained in:
BruceGW
2020-11-27 15:31:23 +08:00
parent 4636b0ec23
commit 8fa92da739
6 changed files with 87 additions and 3 deletions

View File

@@ -0,0 +1,8 @@
1. Prepare the environment
sh prepare.sh
2. Start to tuning
atune-adm tuning --project nginx --detail nginx_client.yaml
atune-adm tuning --project nginx_http_long --detail nginx_http_long_client.yaml
3. Restore the environment
atune-adm tuning --restore --project nginx
atune-adm tuning --restore --project nginx_http_long

View File

@@ -0,0 +1,17 @@
#!/bin/sh
# Copyright (c) 2020 Huawei Technologies Co., Ltd.
# A-Tune is licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
# http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# Create: 2020-11-26
if [ -f /run/nginx.pid ]; then
/usr/sbin/nginx -s stop
fi
/usr/sbin/nginx -c /etc/nginx/nginx.conf
httpress -n 1000000 -c 512 -t 7 -k http://localhost:80

View File

@@ -0,0 +1,13 @@
project: "nginx"
engine : "gbrt"
iterations : 30
random_starts : 10
benchmark : "sh nginx/nginx_benchmark.sh"
evaluations :
-
name: "rps"
info:
get: "echo '$out' | grep 'TIMING:' | awk '{print $4}'"
type: "negative"
weight: 100

View File

@@ -0,0 +1,13 @@
project: "nginx_http_long"
engine : "gbrt"
iterations : 30
random_starts : 10
benchmark : "sh nginx/nginx_benchmark.sh"
evaluations :
-
name: "rps"
info:
get: "echo '$out' | grep 'TIMING:' | awk '{print $4}'"
type: "negative"
weight: 100

View File

@@ -0,0 +1,33 @@
#!/bin/sh
# Copyright (c) 2020 Huawei Technologies Co., Ltd.
# A-Tune is licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
# http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# Create: 2020-11-26
path=$(
cd "$(dirname "$0")"
pwd
)
systemctl stop firewalld
echo "install nginx"
yum install nginx gnutls gnutls-devel libev libev-devel -y
echo "install nginx benchmark"
if [ ! -f /usr/bin/httpress ]; then
rm -rf httpress
git clone https://github.com/yarosla/httpress.git
cd httpress && make
cp bin/Release/httpress /usr/bin
fi
echo "update the nginx client"
sed -i "s#sh .*/nginx_benchmark.sh#sh $path/nginx_benchmark.sh#g" $path/nginx_client.yaml
sed -i "s#sh .*/nginx_benchmark.sh#sh $path/nginx_benchmark.sh#g" $path/nginx_http_long_client.yaml

View File

@@ -3638,7 +3638,7 @@ The default value is 2048. You are advised to change the value to 8192."
info :
desc : "Enabling or Disabling nginx access_log"
get : cat /etc/nginx/nginx.conf | grep "access_log" | awk -F ';' '{print $1}' | awk '{$1="";print}'| awk '$1=$1'
set : sed -i "s#access_log.*#access_log $value;#g" /etc/nginx/nginx.conf
set : sed -i 's#access_log.*#access_log $value;#g' /etc/nginx/nginx.conf
needrestart : "false"
type : "discrete"
options :
@@ -3650,11 +3650,11 @@ The default value is 2048. You are advised to change the value to 8192."
info :
desc : "Enabling or Disabling nginx error_log"
get : cat /etc/nginx/nginx.conf | grep "error_log" | awk -F ';' '{print $1}' | awk '{$1="";print}' | awk '$1=$1'
set : sed -i "s#error_log.*#error_log $value;#g" /etc/nginx/nginx.conf
set : sed -i 's#error_log.*#error_log $value;#g' /etc/nginx/nginx.conf
needrestart : "false"
type : "discrete"
options :
- "/var/log/nginx/access.log main"
- "/var/log/nginx/error.log"
- "/dev/null"
dtype : "string"
-