apache log rotatelogs

APACHE TUNE 2020. 1. 30. 16:17

apache log 관리는 rotatelogs 또는 logrotate를 이용해서 설정할 수 있다.

 

 

rotatelogs 를 이용한 방법

아파치 설정 파일(httpd.conf)을 확인한다.

# vi /usr/local/apache2/conf/httpd.conf

 

LogFormat 부분의 마지막에 있는 별명(common, combined, combinedio) 중에서 사용한다.

- combinedio는 추가 작업이 필요한다.

 

아파치의 가상 호스트 파일을 설정한다.

]# vi /usr/local/apache2/conf/extra/httpd-vhost.conf 

 

ErrorLog "|/usr/local/apache2/bin/rotatelogs /usr/local/apache2/logs/okkks-error-%y%m%d_log 86400 +540"
CustomLog "|/usr/local/apache2/bin/rotatelogs /usr/local/apache2/logs/okkks-access-%y%m%d_log 86400 +540" combined

%y%m%d : 년월일(예>140101)

- $Y : 년(예> 2014)

86400 : 초 단위이며 24시간 주기로 새 파일을 생성한다.(GMT 기준시)

+540 : 한국 시간을 사용하기 위해 GMT 기준시에 더해준다.

combined : httpd.conf에 설정된 LogFormat

 

아파치를 다시 실행한다.

]# service httpd restart

 

 

웹 사이트에 접속한 후 log 파일을 확인해 보면 파일이 생성된 것을 확인할 수 있다.

]# ll /usr/local/apache2/logs/ 

 

블로그 이미지

remoted

Remoted's IT LAB & POST DATABASE

댓글을 달아 주세요

VirtualHost Examples

APACHE TUNE 2020. 1. 30. 16:08

This document attempts to answer the commonly-asked questions about setting up virtual hosts. These scenarios are those involving multiple web sites running on a single server, via name-based or IP-based virtual hosts.

See also

Running several name-based web sites on a single IP address.

Your server has multiple hostnames that resolve to a single address, and you want to respond differently for www.example.com and www.example.org.

Note

Creating virtual host configurations on your Apache server does not magically cause DNS entries to be created for those host names. You must have the names in DNS, resolving to your IP address, or nobody else will be able to see your web site. You can put entries in your hosts file for local testing, but that will work only from the machine with those hosts entries.

# Ensure that Apache listens on port 80 Listen 80 
<VirtualHost *:80>
	DocumentRoot "/www/example1" 
	ServerName www.example.com 
	# Other directives here 
</VirtualHost> 

<VirtualHost *:80> 
	DocumentRoot "/www/example2" ServerName www.example.org 
	# Other directives here 
</VirtualHost>

The asterisks match all addresses, so the main server serves no requests. Due to the fact that the virtual host with  ServerName www.example.com is first in the configuration file, it has the highest priority and can be seen as the default or primary server. That means that if a request is received that does not match one of the specified ServerName directives, it will be served by this first <VirtualHost>.

 

The above configuration is what you will want to use in almost all name-based virtual hosting situations. The only thing that this configuration will not work for, in fact, is when you are serving different content based on differing IP addresses or ports.

Note

You may replace * with a specific IP address on the system. Such virtual hosts will only be used for HTTP requests received on connection to the specified IP address.

However, it is additionally useful to use * on systems where the IP address is not predictable - for example if you have a dynamic IP address with your ISP, and you are using some variety of dynamic DNS solution. Since * matches any IP address, this configuration would work without changes whenever your IP address changes.

Name-based hosts on more than one IP address.

Note

Any of the techniques discussed here can be extended to any number of IP addresses.

The server has two IP addresses. On one (172.20.30.40), we will serve the "main" server, server.example.com and on the other (172.20.30.50), we will serve two or more virtual hosts.

Listen 80 

# This is the "main" server running on 172.20.30.40 
ServerName server.example.com 
DocumentRoot "/www/mainserver"

<VirtualHost 172.20.30.50> 
	DocumentRoot "/www/example1" 
    ServerName www.example.com 
    
	# Other directives here ... 
</VirtualHost> 

<VirtualHost 172.20.30.50> 
	DocumentRoot "/www/example2"
    ServerName www.example.org 
    # Other directives here ... 
</VirtualHost>

 

 

Any request to an address other than 172.20.30.50 will be served from the main server. A request to 172.20.30.50 with an unknown hostname, or no Host: header, will be served from www.example.com.

Serving the same content on different IP addresses (such as an internal and external address).

The server machine has two IP addresses (192.168.1.1 and 172.20.30.40). The machine is sitting between an internal (intranet) network and an external (internet) network. Outside of the network, the name server.example.com resolves to the external address (172.20.30.40), but inside the network, that same name resolves to the internal address (192.168.1.1).

The server can be made to respond to internal and external requests with the same content, with just one <VirtualHost> section.

<VirtualHost 192.168.1.1 172.20.30.40> 
	DocumentRoot "/www/server1" 
    ServerName server.example.com 
    ServerAlias server 
</VirtualHost>

 

 

Now requests from both networks will be served from the same <VirtualHost>.

Note:

On the internal network, one can just use the name server rather than the fully qualified host name server.example.com.

Note also that, in the above example, you can replace the list of IP addresses with *, which will cause the server to respond the same on all addresses.

Running different sites on different ports.

You have multiple domains going to the same IP and also want to serve multiple ports. The example below illustrates that the name-matching takes place after the best matching IP address and port combination is determined.

Listen 80
Listen 8080 

<VirtualHost 172.20.30.40:80> 
	ServerName www.example.com 
    DocumentRoot "/www/domain-80" 
</VirtualHost> 

<VirtualHost 172.20.30.40:8080> 
	ServerName www.example.com 
    DocumentRoot "/www/domain-8080" 
</VirtualHost> 

<VirtualHost 172.20.30.40:80> 
	ServerName www.example.org 
    DocumentRoot "/www/otherdomain-80" 
</VirtualHost> 

<VirtualHost 172.20.30.40:8080> 
	ServerName www.example.org 
    DocumentRoot "/www/otherdomain-8080"
</VirtualHost>

IP-based virtual hosting

The server has two IP addresses (172.20.30.40 and 172.20.30.50) which resolve to the names www.example.com and www.example.org respectively.

Listen 80 

<VirtualHost 172.20.30.40> 
	DocumentRoot "/www/example1" 
    ServerName www.example.com 
</VirtualHost> 

<VirtualHost 172.20.30.50>
	DocumentRoot "/www/example2" 
    ServerName www.example.org 
</VirtualHost>

Requests for any address not specified in one of the <VirtualHost> directives (such as localhost, for example) will go to the main server, if there is one.

Mixed port-based and ip-based virtual hosts

The server machine has two IP addresses (172.20.30.40 and 172.20.30.50) which resolve to the names www.example.com and www.example.org respectively. In each case, we want to run hosts on ports 80 and 8080.

Listen 172.20.30.40:80 
Listen 172.20.30.40:8080 
Listen 172.20.30.50:80 
Listen 172.20.30.50:8080 

<VirtualHost 172.20.30.40:80> 
	DocumentRoot "/www/example1-80" 
    ServerName www.example.com 
</VirtualHost> 

<VirtualHost 172.20.30.40:8080> 
	DocumentRoot "/www/example1-8080" 
    ServerName www.example.com 
</VirtualHost> 

<VirtualHost 172.20.30.50:80> 
	DocumentRoot "/www/example2-80" 
    ServerName www.example.org 
</VirtualHost> 

<VirtualHost 172.20.30.50:8080>
	DocumentRoot "/www/example2-8080" 
    ServerName www.example.org 
</VirtualHost>

 

Mixed name-based and IP-based vhosts

Any address mentioned in the argument to a virtualhost that never appears in another virtual host is a strictly IP-based virtual host.

Listen 80 
<VirtualHost 172.20.30.40> 
	DocumentRoot "/www/example1"
    ServerName www.example.com 
</VirtualHost> 

<VirtualHost 172.20.30.40>
	DocumentRoot "/www/example2" 
    ServerName www.example.org
</VirtualHost> 

<VirtualHost 172.20.30.40> 
	DocumentRoot "/www/example3"
    ServerName www.example.net
</VirtualHost> 

# IP-based 
<VirtualHost 172.20.30.50>
	DocumentRoot "/www/example4"
    ServerName www.example.edu 
</VirtualHost> 

<VirtualHost 172.20.30.60>
	DocumentRoot "/www/example5" 
    ServerName www.example.gov 
</VirtualHost>

Using Virtual_host and mod_proxy together

The following example allows a front-end machine to proxy a virtual host through to a server running on another machine. In the example, a virtual host of the same name is configured on a machine at 192.168.111.2. The ProxyPreserveHost On directive is used so that the desired hostname is passed through, in case we are proxying multiple hostnames to a single machine.

<VirtualHost *:*> 
	ProxyPreserveHost On 
    ProxyPass "/" "http://192.168.111.2/" 
    ProxyPassReverse "/" "http://192.168.111.2/" 
    ServerName hostname.example.com 
</VirtualHost>

Using _default_ vhosts

_default_ vhosts for all ports

Catching every request to any unspecified IP address and port, i.e., an address/port combination that is not used for any other virtual host.

<VirtualHost _default_:*> 
	DocumentRoot "/www/default" 
</VirtualHost>

Using such a default vhost with a wildcard port effectively prevents any request going to the main server.

 

A default vhost never serves a request that was sent to an address/port that is used for name-based vhosts. If the request contained an unknown or no Host: header it is always served from the primary name-based vhost (the vhost for that address/port appearing first in the configuration file).

 

You can use AliasMatch or RewriteRule to rewrite any request to a single information page (or script).

_default_ vhosts for different ports

Same as setup 1, but the server listens on several ports and we want to use a second _default_ vhost for port 80.

<VirtualHost _default_:80> 
	DocumentRoot "/www/default80" 
    # ... 
</VirtualHost> 

<VirtualHost _default_:*> 
	DocumentRoot "/www/default"
    # ... 
</VirtualHost>

The default vhost for port 80 (which must appear before any default vhost with a wildcard port) catches all requests that were sent to an unspecified IP address. The main server is never used to serve a request.

_default_ vhosts for one port

We want to have a default vhost for port 80, but no other default vhosts.

<VirtualHost _default_:80> 
	DocumentRoot "/www/default" 
... 
</VirtualHost>

A request to an unspecified address on port 80 is served from the default vhost. Any other request to an unspecified address and port is served from the main server.

Any use of * in a virtual host declaration will have higher precedence than _default_.

Migrating a name-based vhost to an IP-based vhost

The name-based vhost with the hostname www.example.org (from our name-based example, setup 2) should get its own IP address. To avoid problems with name servers or proxies who cached the old IP address for the name-based vhost we want to provide both variants during a migration phase.

The solution is easy, because we can simply add the new IP address (172.20.30.50) to the VirtualHost directive.

Listen 80 
ServerName www.example.com 
DocumentRoot "/www/example1" 

<VirtualHost 172.20.30.40 172.20.30.50> 
	DocumentRoot "/www/example2"
    ServerName www.example.org 
    # ... 
</VirtualHost> 

<VirtualHost 172.20.30.40>
	DocumentRoot "/www/example3" 
    ServerName www.example.net 
    ServerAlias *.example.net 
    # ... 
</VirtualHost>

The vhost can now be accessed through the new address (as an IP-based vhost) and through the old address (as a name-based vhost).

Using the ServerPath directive

We have a server with two name-based vhosts. In order to match the correct virtual host a client must send the correct Host: header. Old HTTP/1.0 clients do not send such a header and Apache has no clue what vhost the client tried to reach (and serves the request from the primary vhost). To provide as much backward compatibility as possible we create a primary vhost which returns a single page containing links with an URL prefix to the name-based virtual hosts.

<VirtualHost 172.20.30.40> 
	# primary vhost 
    DocumentRoot "/www/subdomain" 
    RewriteEngine On 
    RewriteRule "." "/www/subdomain/index.html" 
    # ... 
</VirtualHost> 

<VirtualHost 172.20.30.40>
	DocumentRoot "/www/subdomain/sub1" 
    ServerName www.sub1.domain.tld 
    ServerPath "/sub1/" 
    RewriteEngine On 
    RewriteRule "^(/sub1/.*)" "/www/subdomain$1" 
    # ... 
</VirtualHost> 

<VirtualHost 172.20.30.40> 
	DocumentRoot "/www/subdomain/sub2" 
    ServerName www.sub2.domain.tld 
    ServerPath "/sub2/" 
    RewriteEngine On
    RewriteRule "^(/sub2/.*)" "/www/subdomain$1"
    # ... 
</VirtualHost>

Due to the ServerPath directive a request to the URL http://www.sub1.domain.tld/sub1/ is always served from the sub1-vhost. A request to the URL http://www.sub1.domain.tld/ is only served from the sub1-vhost if the client sent a correct Host: header. If no Host: header is sent the client gets the information page from the primary host.

 

Please note that there is one oddity: A request to http://www.sub2.domain.tld/sub1/ is also served from the sub1-vhost if the client sent no Host: header.

 

The RewriteRule directives are used to make sure that a client which sent a correct Host: header can use both URL variants, i.e., with or without URL prefix.

 

블로그 이미지

remoted

Remoted's IT LAB & POST DATABASE

댓글을 달아 주세요

About a week ago, when restarting apache using ssh, I got the following notice:
"AH00548: NameVirtualHost has no effect and will be removed in the next release..."
Same issue seen in this post:
NameVirtualHost has no effect error?

I ran the rebuild mentioned in that post, and also rebuilt the EA4 profile, the notice disappeared for couple of days, then came back!

Any easy way to stop these residual NameVirtualHost entries from regenerating?

webhostukWell-Known Member

 

 

Sep 27, 2017

Can you open your httpd.conf file and check if the entry for Virtualhost is :
<VirtualHost xxx.xx.xxx.xx:80> where (xxx is your IP ) try to replace it with : <VirtualHost *:80> and restart apache.
Check if that solved the problem.

WebhostUK LTD : Best UK Web Hosting
Cloud VPS Hosting & Managed Servers

G

gnetwork-cpMember 

 

 

 

Sep 27, 2017

Thanks for suggestion. For some reason only one virtual host had the NameVirtualHost entry stuck.
I resaved that domain's zone, and ran /scripts/rebuildhttpdconf - the NameVirtualHost entry has disappeared again, and hopefully will stay like that.

C

cPanelMichaelAdministrator 

Staff member

 

 

Sep 27, 2017

Hello,

The "NameVirtualHost has no effect and will be removed in the next release" message is informational and will not result in any issues accessing your websites. It's no longer used as of cPanel version 68:

Fixed case CPANEL-15364: Avoid adding NameVirtualHost to httpd.conf when using EA4.

Thank you.

블로그 이미지

remoted

Remoted's IT LAB & POST DATABASE

댓글을 달아 주세요


I have developed an application in VB6, and am using an online MySQL database server for storing my application's data.

The first time I try to connect to my database server is successful, but after closing my application and starting it again I get:

Can't connect to MySQL server(10060)"

After some time (approximately 30 minutes), I can successfully connect to the database again.

  • I have given maximum values to all of MySQL system and global variables like connection_timeoutwait_timeout etc.
  • I have granted all permissions to my MySQL user.
  • The firewall on my computer is turned off.
  • All connections are properly closed when the application closes.

I have asked the technical people who provide the Online MySQL Database service and they gave me these three reasons:

  1. The local machine from where you are trying to connect is not whitelisted on the server.
  2. The maximum number of connections for the user has been exceeded.
  3. The MySQL server was down at the time (though they said that their server was not down).

How can I solve the first two reasons, or determine that they are the cause of the problem? Or could there be another problem not listed there?

you need to make sure there is:

1) user created that has remote access for example user@'x.x.x.x'

2) there is a connection from the two machine ( they can ping each other for example or access each another by another method) the port is opened between the two machine

3) in my.ini/my.cnf there is blocking connection parameter like:bind-address=a.a.a.a or skip-networking

4) the service is up and running when you try to connect from the other machine


블로그 이미지

remoted

Remoted's IT LAB & POST DATABASE

댓글을 달아 주세요


I had to handle high traffic loads in my career and I fought with down-time, not used memory and a lot of trouble in my past. In this article I want to give a step-by-step guide to apache2 performance settings, which is a concentrated result of a lot of reading and trying.

My environment

Precalculation of average memory usage and maxclients/max-children

1. Calculate process size

You need to know how many processes can run on your machine. So calculate the process size of your main CPU/memory drivers is necessary.

There are several calculation methods out there. Personally I prefer this python script as it takes shared memory into account and will give insights into real memory usage.

cd ~
wget https://raw.githubusercontent.com/pixelb/ps_mem/master/ps_mem.py
chmod a+x ps_mem.py
sudo python ps_mem.py

ps_mem.py will produce output like this:

Here you can see that there are 30 apache2 processes, consuming a total of 352 MiB, so each Apache process is using roughly 12MiB of RAM. The php-fpm5.6 process will use about 50MiB.

2. Calculate apache MaxRequestWorkers

To be safe though, I’ll reserve 15% of memory for all other processes (in my case ~1,2GiB) and round up apache process size to 15MiB.

MaxRequestWorkers = (Total RAM - Memory used for Linux, DB, etc.) / process size
MaxRequestWorkers = (8192MB - 1200MB) / 15MB = 466

3. Calculate php-fpm max-children

To be safe though, I’ll reserve 1 GiB for all other processes and round up php process size to 55MiB.

maxclients = (Total RAM - Memory used for Linux, DB, etc.) / process size
maxclients = (8048MB - 1024MB) / 55MB = 128

My colleague Thomas prepared this Excel Sheet for the calculation: https://s3.buckpesch.io/downloads/apache_performance.xlsx

Detailed Setup

In the /etc/apache2/mods-enabled/mpm-event.conf or /etc/apache2/mods-enabled/mpm-worker.conf file:

<IfModule mpm_*_module>
ServerLimit (Total RAM - Memory used for Linux, DB, etc.) / process size
StartServers (Number of Cores)
MinSpareThreads 25
MaxSpareThreads 75
ThreadsLimit 64
ThreadsPerChild 25
MaxRequestWorkers (Total RAM - Memory used for Linux, DB, etc.) / process size
MaxConnectionsPerChild 1000
</IfModule>

Note that the default settings did not contain the “ServerLimit”, so I added it here.

In the /etc/php/7.1/fpm/pool.d/www.conf change the following settings:

pm = dynamic            
pm.max_children (total RAM - (DB etc) / process size)
pm.start_servers (cpu cores * 4)
pm.min_spare_servers (cpu cores * 2)
pm.max_spare_servers (cpu cores * 4)
pm.max_requests 1000

To learn about all php-fpm settings I recommend watching the video on that page: https://serversforhackers.com/c/php-fpm-process-management

My final settings

My server has 16GB RAM and 4 CPUs à 2,4GHz. My avarage apache process has 15MB, an average PHP process takes 55MB.

/etc/apache2/mods-available/mpm_event.conf

# Optimized settings for avg. apache process 15MB and AWS EC2 m4.xlarge Server
<IfModule mpm_event_module>
ServerLimit 925
StartServers 4
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxRequestWorkers 925
MaxConnectionsPerChild 1000
</IfModule>

/etc/php/7.1/fpm/pool.d/www.conf

; Optimized for php-fpm request size of 55MB on AWS EC2 m4.xlarge (4CPU cores, 16GB RAM)
pm = dynamic
pm.max_children = 200
pm.start_servers = 20
pm.min_spare_servers = 10
pm.max_spare_servers = 20
pm.max_requests = 1000

Save your settings and restart your apache and php-fpm processes

sudo service apache2 restart
sudo service php7.1-fpm restart

Test you settings

To test your server settings you can run Apache Bench tests and see how your server behaves in htop .

Open 2 terminals and the following command to test 5000 requests with a concurrency of 100 parallel requests:

ab -n 5000 -c 100
Load test using apache bench

I hope this helps. Drop me a line, when you have other experience or think I might can improve my formular/calculation. As well I might create a simple web-interface to calculate the settings… But now I have to go back to work ;-)

References


블로그 이미지

remoted

Remoted's IT LAB & POST DATABASE

댓글을 달아 주세요

htop is a Linux process monitoring tool, It is an alternative tool for top command, Which is the standard and the default process Monitoring tool in Linux and Unix Operating System. But htop on CentOS 7 is more user friendly and output is easy to read compared to the Linux top command.

In this Tutorial We are going to learn how to Install htop on CentOS 7 using yum install command with epel repository.

To Install htop on CentOS 7 We Want to add CentOS epel repository, Because the htop software package does not come with Default CentOS yum repository.

Start Amazon Prime 30-day Trial - Instantly watch over 40,000 movies and TV episodes

Step One

Install Epel Release

First, enable the epel release on CentOS 7.

yum -y install epel-release

Step Two

install htop With Yum Command

Now we can install CentOS htop using yum install command.

yum -y install htop

 

Now to start htop program, Open Linux Terminal and type htop

centos install htop

You can see the output of the htop process monitoring tools is more readable and easy understand.

Summary : htop CentOS 7

  • In this tutorial we installed htop on Linux CentOS 7 using epel repository.
  • First, we enable the epel-release and then install htop using yum command (Without epel-release you will receive the following error "No package htop available").

We can also use this same method to install htop on CentOS 6.5 and older versions.

블로그 이미지

remoted

Remoted's IT LAB & POST DATABASE

댓글을 달아 주세요


I try to install Apache Benchmark using Is there a way to install Apache Bench (ab) without installing apache solutions on my centos but when i run yumdownloader httpd, i get error:

root@local [~/httpd]# yumdownloader httpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: yum.phx.singlehop.com
 * elrepo: repos.lax-noc.com
 * extras: centos.tcpdiag.net
 * updates: mirror.stanford.edu
No Match for argument httpd
Nothing to download

What is it? and how can i fixed it?

Edit 1: i try to use Michael Hampton way but i get this errors:

root@local [~]# yum provides /usr/bin/ab
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: yum.phx.singlehop.com
 * elrepo: repos.lax-noc.com
 * extras: centos.tcpdiag.net
 * updates: mirror.stanford.edu
No Matches found

root@local [~]# yum install httpd-tools
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: yum.phx.singlehop.com
 * elrepo: repos.lax-noc.com
 * extras: centos.tcpdiag.net
 * updates: mirror.stanford.edu
Setting up Install Process
No package httpd-tools available.
Error: Nothing to do

You can discover which package contains the program you want using yum provides:

yum provides /usr/bin/ab

Then you will see that ab is in the httpd-tools package.

And now you can install it:

yum install httpd-tools


    블로그 이미지

    remoted

    Remoted's IT LAB & POST DATABASE

    댓글을 달아 주세요

    ab 프로그램은 웹 서버를 벤치마크하기 위해 Apache 웹 서버와 함께 제공됩니다. Watson™ Explorer Engine은 일반적으로 웹 서버 내에서 CGI 실행 파일로 실행되므로 웹 서버의 작동 성능을 파악하는 것이 유용합니다. ab 애플리케이션은 현재 Apache 설치의 작동 성능에 대한 정보를 제공하도록 설계되었으며, Apache 설치가 서비스할 수 있는 초당 요청 수를 요약해서 보여줍니다.

    이 정보는 Watson Explorer Engine이 실행 중인 상태에서 Watson Explorer Engine과 독립적으로 웹 서버에서 처리할 수 있는 최대 로드를 판별하는 데 유용합니다. ab 애플리케이션은 Watson Explorer Engine이 실행 중인 동안 웹 서버를 테스트할 수 있으므로 일반 사용자 관점에서 전체 애플리케이션의 성능에 대한 정확한 벤치마크를 가져올 수 있습니다.

    ab 애플리케이션은 Apache 설치 패키지의 일부로 설치됩니다. 대부분의 Linux 배포에서 이 애플리케이션은 httpd-tools 패키지에 포함되어 있습니다. ab유틸리티를 확보하는 방법에 대한 정보는 사용 중인 운영 체제에 대한 Apache 문서를 참조하십시오.

    다음은 ab 애플리케이션에서 제공하는 도움말 정보입니다.

        # ab -h
          Usage: ab [options] [http[s]://]hostname[:port]/path
          Options are:
          -n requests     Number of requests to perform
          -c concurrency  Number of multiple requests to make
          -t timelimit    Seconds to max. wait for responses
          -b windowsize   Size of TCP send/receive buffer, in bytes
          -p postfile     File containing data to POST. Remember also to set -T
          -u putfile      File containing data to PUT. Remember also to set -T
          -T content-type Content-type header for POSTing, eg.
          'application/x-www-form-urlencoded'
          Default is 'text/plain'
          -v verbosity    How much troubleshooting info to print
          -w              Print out results in HTML tables
          -i              Use HEAD instead of GET
          -x attributes   String to insert as table attributes
          -y attributes   String to insert as tr attributes
          -z attributes   String to insert as td or th attributes
          -C attribute    Add cookie, eg. 'Apache=1234. (repeatable)
          -H attribute    Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
          Inserted after all normal header lines. (repeatable)
          -A attribute    Add Basic WWW Authentication, the attributes
          are a colon separated username and password.
          -P attribute    Add Basic Proxy Authentication, the attributes
          are a colon separated username and password.
          -X proxy:port   Proxyserver and port number to use
          -V              Print version number and exit
          -k              Use HTTP KeepAlive feature
          -d              Do not show percentiles served table.
          -S              Do not show confidence estimators and warnings.
          -g filename     Output collected data to gnuplot format file.
          -e filename     Output CSV file with percentages served
          -r              Don't exit on socket receive errors.
          -h              Display usage information (this message)
          -Z ciphersuite  Specify SSL/TLS cipher suite (See openssl ciphers)
          -f protocol     Specify SSL/TLS protocol (SSL2, SSL3, TLS1, or ALL)

    Watson Explorer Engine 설치에 대한 로드 테스트 방법의 예제는 다음과 같습니다.

        # ab -n 1000 -c 10 http://localhost/velocity/cgi-bin/query-meta
          This is ApacheBench, Version 2.3 <$Revision: 655654 $>
          Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
          Licensed to The Apache Software Foundation, http://www.apache.org/
    
          Benchmarking localhost (be patient)
          Completed 100 requests
          Completed 200 requests
          Completed 300 requests
          Completed 400 requests
          Completed 500 requests
          Completed 600 requests
          Completed 700 requests
          Completed 800 requests
          Completed 900 requests
          Completed 1000 requests
          Finished 1000 requests
    
          Server Software:        Apache/2.2.15
          Server Hostname:        localhost
          Server Port:            80
          Document Path:          /velocity/cgi-bin/query-meta
          Document Length:        140256 bytes
    
          Concurrency Level:      10
          Time taken for tests:   55.911 seconds
          Complete requests:      1000
          Failed requests:        65
          (Connect: 0, Receive: 0, Length: 65, Exceptions: 0)
          Write errors:           0
          Total transferred:      140402934 bytes
          HTML transferred:       140255934 bytes
          Requests per second:    17.89 [#/sec] (mean)
          Time per request:       559.107 [ms] (mean)
          Time per request:       55.911 [ms] (mean, across all concurrent requests)
          Transfer rate:          2452.35 [Kbytes/sec] received
    
          Connection Times (ms)
          min  mean[+/-sd] median   max
          Connect:        0    0   0.0      0       1
          Processing:   366  558 104.9    541    1350
          Waiting:      353  528 104.5    511    1320
          Total:        366  558 104.9    541    1350
          Percentage of the requests served within a certain time (ms)
          50%    541
          66%    570
          75%    593
          80%    605
          90%    650
          95%    701
          98%    941
          99%   1059
          100%   1350 (longest request)

    위의 테스트는 이 Watson Explorer Engine 인스턴스를 실행하는 서버가 초당 17.89개의 요청을 처리할 수 있음을 나타냅니다. 이 결과는 query-meta를 실행하고 example-metadata 콜렉션을 검색하는 기본 구성으로 얻은 결과입니다.

    meta-searching 및 검색 콜렉션을 사용한 검색에 대한 로드 테스트 출력은 다음과 같습니다.

        # ab -n 100 -c 10 "http://localhost/velocity/cgi-bin/query-meta?v:project=query-meta&query=news"
          This is ApacheBench, Version 2.3 <$Revision: 655654 $>
          Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
          Licensed to The Apache Software Foundation, http://www.apache.org/
          Benchmarking localhost (be patient).....done
    
          Server Software:        Apache/2.2.15
          Server Hostname:        localhost
          Server Port:            80
          Document Path:          /velocity/cgi-bin/query-meta?v:project=query-meta&query=news
          Document Length:        124894 bytes
          Concurrency Level:      10
          Time taken for tests:   70.536 seconds
          Complete requests:      100
          Failed requests:        99
          (Connect: 0, Receive: 0, Length: 99, Exceptions: 0)
          Write errors:           0
          Total transferred:      12478129 bytes
          HTML transferred:       12463429 bytes
          Requests per second:    1.42 [#/sec] (mean)
          Time per request:       7053.553 [ms] (mean)
          Time per request:       705.355 [ms] (mean, across all concurrent requests)
          Transfer rate:          172.76 [Kbytes/sec] received
    
          Connection Times (ms)
          min  mean[+/-sd] median   max
          Connect:        0    0   0.1      0       0
          Processing:  2666 6838 1842.3   6547   13812
          Waiting:     2650 6822 1842.5   6533   13798
          Total:       2666 6838 1842.3   6547   13812
    
          Percentage of the requests served within a certain time (ms)
          50%   6547
          66%   7243
          75%   7676
          80%   8149
          90%   8995
          95%  10025
          98%  13689
          99%  13812
          100%  13812 (longest request)

    meta-searching이 조회에 포함되는 경우 성능에 현저한 차이가 있음을 확인할 수 있습니다. 첫 번째 실행은 평균적으로 0.5초에 완료된 총 1000개의 요청(10개 동시)이 있는 검색 콜렉션에 대한 것입니다. 두 번째 실행은 평균적으로 6.5초에 완료된 총 100개의 요청(10개 동시)이 있는 콜렉션 및 연합 소스에 대한 것입니다. 연합을 사용하도록 설정한 후에 10번째 요청의 완료 시간은 13배 더 늘어났습니다.


    블로그 이미지

    remoted

    Remoted's IT LAB & POST DATABASE

    댓글을 달아 주세요