解读Curl-loader的配置文件之基本配置

2011-05-26  籽藤 

    继《curl-loader问题记录》之后,我仍然抽时间在RHEL5上折腾curl-loader。由于curl-loader的资料并不多,只能通过官网和boobooke上四个视频教程来学习。当然,你可以通过SVN(https://curl-loader.svn.sourceforge.net/svnroot/curl-loader) 下载源码。
    OK,言归正传,这篇博文的主题是介绍配置文件。
    所谓Curl-loader的配置文件,用于定义性能测试过程中所需要的参数。如虚拟用户、请求类型、待测url、执行次数等等(具体情况的配置可参考curl-loader\conf-examples)
    对于一个最简单的conf(如conf-examples中10K.conf)而言,需要定义如下参数:
########### GENERAL SECTION ##################
BATCH_NAME=smalltest
CLIENTS_NUM_MAX=10
CLIENTS_NUM_START=1
CLIENTS_RAMPUP_INC=2
INTERFACE =eth0
NETMASK=255.255.255.0 
IP_ADDR_MIN= 192.168.0.1
IP_ADDR_MAX= 192.168.0.255
CYCLES_NUM= -1
URLS_NUM= 1

########### URLs SECTION #######################
URL=http://targethost/somefile.html
URL_SHORT_NAME="somefile"
REQUEST_TYPE=GET
TIMER_URL_COMPLETION = 0
TIMER_AFTER_URL_SLEEP = 0
 
结合curl-loader在终端的输出log文件,以及Tomcat产生的log 三个方面,我进一步了解以下参数:
BATCH_NAME
    This name is used for the display while the curl\-loader is running, and also for the three generated files.  This is a tag for the general section.
    我们可以把BATCH_NAME理解为测试的名称,也就是测试的标识。在测试执行之后,产生的log文件是以BATCH_NAME为名的,而不是跟conf文件同名。例如,我执行“../curl-loader -f appletest2.conf”;这里,我使用的是appletest2的conf文件,而在该文件中,我定义BATCH_NAME为appletest,那么,只会产生appletest.conf,而不是appletest2.log
CLIENTS_NUM_MAX
    The maximum number of clients to be used for this batch.
    这个clients其实就是虚拟用户,Curl-loader中的Visual Clients,跟Loadrunner中的Visual User是一个概念
CLIENTS_NUM_START
    the number of clients to use when the curl\-loader program is first started. If this number is less than the number specified by CLIENTS_NUM_MAX then the cur\-loader tool will add more clients every second. The number of new clients to add is specified by the CLIENTS_RAMPUP_INC
    通过官方说明我们可以了解,CLIENTS_NUM_START与CLIENTS_NUM_MAX可以相等
CLIENTS_RAMPUP_INC
    the number of clients to add each second when the value of the CLIENTS_NUM_START tag is less than the value of the CLIENTS_NUM_MAX.This is a tag for the general section.
    这个不必多说了,是每秒新增的虚拟用户数
INTERFACE
    This requires a valid interface name and specifies the interface that will be used for connecting to the server(s) specified in the URLs of the URL section. You can do:
    ls /sys/class/net or run /sbin/ifconfig or /sbin/ip addr
    to get the names of your network interfaces. Normally you would use something like eth0. This is a tag for the general section.
    网卡编号
NETMASK
    This requires a valid netmask as the value. For IPv4 you can use either a traditional dotted-quad specification like 255.255.255.0,or you you can use a CIDR number like 24. For IPv6 only CIDR values from 0 to 128 are supported. This is a tag for the general section.
    子网掩码
IP_ADDR_MIN
    This requires a valid IP address as the value. This is the first address to use and the first client you create will use this as its source address. The tool supports two operating modes. In the first mode, a secondary IP is used for each client and added to the network interface. The first client gets IP_ADDR_MIN, then each new client will increment this by one and use that address, until the IP_ADDR_MAX is reached and the address will wrap back to IP_ADDR_MIN. In the second mode, you specify the only IP, optionally to be the real address for the interface specified in the INTERFACE tag, and you use it for IP_ADDR_MIN and IP_ADDR_MAX and all clients use the only IP-address. This is a tag for the general section.
   作为第一个visual client的IP地址。有两种模式:
  1. 每新增一个client,都会将IP地址自增1,直至IP_ADDR_MAX;
  2. 使用当前的真实IP,IP_ADDR_MIN和IP_ADDR_MAX都是这个IP地址,所有的client都使用同一个IP
IP_ADDR_MAX
    This requires a valid IP address as the value. This is the last address from your address pool. 
    它将是IP地址池中最后一个地址
CYCLES_NUM
    This requires a valid signed integer value. This is the number of cycles to be performed. If the value is
-1, the curl\-loader tool cycles forever until you hit ctl-C. This is a tag for the general section.
    我们可以从字面上理解,它是指循环次数。curl-loader进行性能测试,是不断用client向url发请求的过程;一次Cycle有多个client,多次请求。如果CYCLES_NUM等于-1,那么curl-loader将一直运行下去,直到按下Ctrl+C结束。你可以在终端看到如下执行记录(appletest即是BATCH_NAME):
 ============  loading batch is: appletest  ======================================
--------------------------------------------------------------------------------
Interval stats (latest:3 sec, clients:2, CAPS-curr:1):
H/F   Req:3,1xx:0,2xx:3,3xx:0,4xx:0,5xx:0,Err:0,T-Err:0,D:857ms,D-2xx:857ms,Ti:12050B/s,To:152B/s
H/F/S Req:0,1xx:0,2xx:0,3xx:0,4xx:0,5xx:0,Err:0,T-Err:0,D:0ms,D-2xx:0ms,Ti:0B/s,To:0B/s
--------------------------------------------------------------------------------
Summary stats (runs:3 secs, CAPS-average:2):
H/F   Req:3,1xx:0,2xx:3,3xx:0,4xx:0,5xx:0,Err:0,T-Err:0,D:857ms,D-2xx:857ms,Ti:12050B/s,To:152B/s
H/F/S Req:0,1xx:0,2xx:0,3xx:0,4xx:0,5xx:0,Err:0,T-Err:0,D:0ms,D-2xx:0ms,Ti:0B/s,To:0B/s
=================================================================================
 Automatic: adding 1 clients/sec. Stop inc and manual [M].
=================================================================================
    不要认为一条loading batch记录就是一次Cycle;这种记录与CYCLES_NUM并没有直接关系。关于Cycle的信息,你可以查看appletest.log记录。通过client_no了解Cycle的次数。

URLS_NUM
    This requires a valid unsigned integer value. This is the number of URLs in the URL section. This is a tag for the general section.

    很显然,URLS_NUM的值与URL的个数一致。否则,输入执行命令之后,会报“空URL”、“URLS_NUM小于URL个数
”之类的错误。
URL
    This is the first tag of a URL subsection. It must be a valid URL supported by the curl\-loader tool. Valid URLs for downloading with curl\-loader must start with "http://", "https://", or "ftp://". The one exception
to this rule is when the URL is blank because the URL_USE_CURRENT is included and set to 1 in this URL section. Upload URLs will need to have a file name, but download URLs can end with a "/".This is a tag for the URL section.
    如果我们在conf文件中定义2个URL,通过curl-loader的log看出,client是随机访问url的。(url_no只有0和1,而client_no则是1-10不等)
提示:在log中,cycle_no和url_no均是从零开始编号,而client_no是从1开始

URL_SHORT_NAME    
    This optional tag requires an ASCII string with at most 12 characters.It is used for the operational statistics display while the curl-loader tool is running.This is a tag for the URL section.

    显示在appletest.ops的Operation Name栏中。如:URL0:local-index
REQUEST_TYPE
    This tag is required for all http and https URLs. It requires a string value of "GET", "POST", or "PUT". URLs for ftp should not use this tag.This is a tag for the URL section.

    请求类型:GET POST PUT――额,GET、POST 请求都好说,但PUT请求我之前没有实现过,只是看REST文章时有点印象。OK,贴个链接来扫盲(http://www.hackbase.com/tech/2011-04-28/63500.html Get、POST、PUT三者的区别)


TIMER_URL_COMPLETION
    This optional tag requires an unsigned integer value. This specifies the time in milliseconds to wait for a url fetching operation to complete.If the value is 0, this means there is no time limit enforced.
    If the value is greater than 0, then if the fetch is not completed in that amount of time, the fetch is cancelled and is considered a time out.Values between 1 and 19 should not be used because the operating system and curl-loader cannot enforce such short timers.This is a tag for the URL section.

    官方描述得很清楚了,它是定义完成时间的。若为零,则没有时间限制;且不能在1到19之间取值。


TIMER_AFTER_URL_SLEEP
    This optional tag requires an unsigned integer value. This specifies the time in milliseconds for a client to sleep after finishing a fetch. The value 0 means do not sleep at all, but instead immediately continue.
    Random timer values could be an option specified as e.g. 0-2000,which means, that a client will sleep for some random time from 0 to 2000 milliseconds.This is a tag for the URL section.

    这个也不用多说――休眠时间。若为零,则完全没有休眠时间;取值范围在0到2000毫秒

515°/5151 人阅读/0 条评论 发表评论

登录 后发表评论