Quickly measure the distribution of HTTP requests

Source: Internet
Author: User
Quickly measure the distribution of HTTP requests
  • Nemozhang
  • 2012-09-22 09: 56bhmvdgye3kcaw + bus4nvw
Requirements:
There are a bunch of CGI that all need to pass in the appid parameter. How can we view the current most visited appid?
How can I view the distribution of these CGI requests?

Solution:
Assume that all our webserver requests are connected through LVS, and all Internet requests are connected through the tunl0 Nic. Assume that the IP address of the local LVS is 113.108.20.23, and the listening port is 80, the statistical script is:

// Count the distribution of appid in all requests sent to the Local Machine
Sudo tcpdump-C 30000-itunl0-s 512 DST port 80 and DST host 113.108.20.23-A 2> & 1 | awk-F 'appid = ''{print $2} '| tee /tmp/Tee. log | awk-F' & ''{print $1} '| awk-f''' {print $1}' | sort | uniq-c | sort-Rn | HEAD
120298 // This row is empty and can be ignored
1349 47 // The number of accesses with appid 47 is 1349
447 61
421 2141
370 2736
253 2227
192 33
145 282
139 121282
125 343

// Count the distribution of CGI in all requests sent to the Local Machine
Sudo tcpdump-C 30000-itunl0-s 512 DST port 80 and DST host 113.108.20.23-A 2> & 1 | grep 'get \ | Post' | awk-f''' {print $(NF-1 )} '| awk-F '? ''{Print $1} '| grep-V' \.' | sort | uniq-c | sort-Rn | HEAD
1150/V3/user/get_info
1011/V3/user/is_login
991/V3/spread/is_reminder_set
635/V3/spread/set_reminder
240/V3/page/is_fans
210/V3/relation/get_app_friends
140/V3/user/is_setup
126/V3/user/is_vip
97/V3/user/get_multi_info
76/V3/user/total_vip_info

Analysis:
-C 30000 indicates that the system will exit after 30000 packets are captured.
-S 512 shows the first 512 bytes of each package.-S 0 shows all, too many, not necessary.
-A displays the package in ASCII format.
Tee this command is a two-way redirection command that allows you to conveniently view the intermediate output results of the pipeline.

Extension:
You can calculate the distribution of any parameter in an HTTP request, simply change the appid to PF, and then you can calculate the distribution of requests from various platforms.Requirements:
There are a bunch of CGI that all need to pass in the appid parameter. How can we view the current most visited appid?
How can I view the distribution of these CGI requests?

Solution:
Assume that all our webserver requests are connected through LVS, and all Internet requests are connected through the tunl0 Nic. Assume that the IP address of the local LVS is 113.108.20.23, and the listening port is 80, the statistical script is:

// Count the distribution of appid in all requests sent to the Local Machine
Sudo tcpdump-C 30000-itunl0-s 512 DST port 80 and DST host 113.108.20.23-A 2> & 1 | awk-F 'appid = ''{print $2} '| tee /tmp/Tee. log | awk-F' & ''{print $1} '| awk-f''' {print $1}' | sort | uniq-c | sort-Rn | HEAD
120298 // This row is empty and can be ignored
1349 47 // The number of accesses with appid 47 is 1349
447 61
421 2141
370 2736
253 2227
192 33
145 282
139 121282
125 343

// Count the distribution of CGI in all requests sent to the Local Machine
Sudo tcpdump-C 30000-itunl0-s 512 DST port 80 and DST host 113.108.20.23-A 2> & 1 | grep 'get \ | Post' | awk-f''' {print $(NF-1 )} '| awk-F '? ''{Print $1} '| grep-V' \.' | sort | uniq-c | sort-Rn | HEAD
1150/V3/user/get_info
1011/V3/user/is_login
991/V3/spread/is_reminder_set
635/V3/spread/set_reminder
240/V3/page/is_fans
210/V3/relation/get_app_friends
140/V3/user/is_setup
126/V3/user/is_vip
97/V3/user/get_multi_info
76/V3/user/total_vip_info

Analysis:
-C 30000 indicates that the system will exit after 30000 packets are captured.
-S 512 shows the first 512 bytes of each package.-S 0 shows all, too many, not necessary.
-A displays the package in ASCII format.
Tee this command is a two-way redirection command that allows you to conveniently view the intermediate output results of the pipeline.

Extension:
You can calculate the distribution of any parameter in an HTTP request, simply change the appid to PF, and then you can calculate the distribution of requests from various platforms.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.