linux curl
curl www.laifeng.com > /dev/null
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 64578 0 64578 0 0 1685k 0 --:--:-- --:--:-- --:--:-- 1704k
root@m1hadoop:~# curl www.baidu.com -I
HTTP/1.1 200 OK
Date: Wed, 08 Apr 2015 05:35:53 GMT
Content-Type: text/html; charset=utf-8
Connection: Keep-Alive
Vary: Accept-Encoding
Set-Cookie: BAIDUID=02B552B2DED84F73E61341A542C21292:FG=1; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com
Set-Cookie: BIDUPSID=02B552B2DED84F73E61341A542C21292; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com
Set-Cookie: BDSVRTM=0; path=/
Set-Cookie: BD_HOME=0; path=/
Set-Cookie: H_PS_PSSID=11192_1456_12772_13075_12826_12868_13320_12691_13411_8502_13348_12723_12797_12735_13085_13310_13324_13210_12836_13162_13256_8498; path=/; domain=.baidu.com
P3P: CP=" OTI DSP COR IVA OUR IND COM "
Cache-Control: private
Cxy_all: baidu+0503c15ef19aed449289e5beec7d831a
Expires: Wed, 08 Apr 2015 05:35:49 GMT
X-Powered-By: HPHP
Server: BWS/1.1
BDPAGETYPE: 1
BDQID: 0xb38166cc00001f1b
BDUSERID: 0
root@m1hadoop:~# cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 10.155.100.20
nameserver 10.10.0.21
search 1verge.com
TTL是 Time To Live的缩写,该字段指定IP包被路由器丢弃之前允许通过的最大网段数量。TTL是IPv4包头的一个8 bit字段。
跟踪域名解析过程
nslookup
dig www.taobao.com
; <<>> DiG 9.8.1-P1 <<>> www.taobao.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62258
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.taobao.com. IN A
;; ANSWER SECTION:
www.taobao.com. 1513 IN CNAME www.gslb.taobao.com.danuoyi.tbcache.com.
www.gslb.taobao.com.danuoyi.tbcache.com. 14 IN A 202.108.249.241
www.gslb.taobao.com.danuoyi.tbcache.com. 14 IN A 202.108.249.251
www.gslb.taobao.com.danuoyi.tbcache.com. 14 IN A 202.108.250.241
www.gslb.taobao.com.danuoyi.tbcache.com. 14 IN A 202.108.250.251
;; Query time: 5 msec
;; SERVER: 10.155.100.20#53(10.155.100.20)
;; WHEN: Tue Apr 7 23:07:22 2015
;; MSG SIZE rcvd: 146
dig www.taobao.com +trace
跟踪这个域名的解析过程
dig www.taobao.com +trace
; <<>> DiG 9.8.1-P1 <<>> www.taobao.com +trace
;; global options: +cmd
. 3600 IN NS i.root-servers.net.
. 3600 IN NS j.root-servers.net.
. 3600 IN NS k.root-servers.net.
. 3600 IN NS l.root-servers.net.
. 3600 IN NS m.root-servers.net.
. 3600 IN NS a.root-servers.net.
. 3600 IN NS b.root-servers.net.
. 3600 IN NS c.root-servers.net.
. 3600 IN NS d.root-servers.net.
. 3600 IN NS e.root-servers.net.
. 3600 IN NS f.root-servers.net.
. 3600 IN NS g.root-servers.net.
. 3600 IN NS h.root-servers.net.
;; Received 289 bytes from 10.155.100.20#53(10.155.100.20) in 72 ms
com. 172800 IN NS i.gtld-servers.net.
com. 172800 IN NS d.gtld-servers.net.
com. 172800 IN NS m.gtld-servers.net.
com. 172800 IN NS a.gtld-servers.net.
com. 172800 IN NS l.gtld-servers.net.
com. 172800 IN NS e.gtld-servers.net.
com. 172800 IN NS c.gtld-servers.net.
com. 172800 IN NS k.gtld-servers.net.
com. 172800 IN NS h.gtld-servers.net.
com. 172800 IN NS f.gtld-servers.net.
com. 172800 IN NS b.gtld-servers.net.
com. 172800 IN NS j.gtld-servers.net.
com. 172800 IN NS g.gtld-servers.net.
;; Received 504 bytes from 192.58.128.30#53(192.58.128.30) in 4973 ms
taobao.com. 172800 IN NS ns4.taobao.com.
taobao.com. 172800 IN NS ns5.taobao.com.
taobao.com. 172800 IN NS ns6.taobao.com.
taobao.com. 172800 IN NS ns7.taobao.com.
;; Received 184 bytes from 192.52.178.30#53(192.52.178.30) in 354 ms
www.taobao.com. 1800 IN CNAME www.gslb.taobao.com.danuoyi.tbcache.com.
danuoyi.tbcache.com. 10800 IN NS danuoyins4.tbcache.com.
danuoyi.tbcache.com. 10800 IN NS danuoyins6.tbcache.com.
danuoyi.tbcache.com. 10800 IN NS danuoyins8.tbcache.com.
danuoyi.tbcache.com. 10800 IN NS danuoyins7.tbcache.com.
danuoyi.tbcache.com. 10800 IN NS danuoyins9.tbcache.com.
danuoyi.tbcache.com. 10800 IN NS danuoyins5.tbcache.com.
;; Received 328 bytes from 110.75.20.29#53(110.75.20.29) in 42 ms
GTM负责外网的负载均衡,比如北京的用户访问被分配到北京的数据中心,南京的用户访问被分配到深圳的数据中心。
LTM负责内网的负载均衡,比如一个用户访问进来,由LTM负责具体分配到哪个服务器来处理。
常规的CDN都是回源的。即:当有用户访问某一个URL的时候,如果被解析到的那个CDN节点没有缓存响应的内容,或者是缓存已经到期,就会回源站去获取。如果没有人访问,那么CDN节点不会主动去源站拿的。
17:54 [[email protected]]$ iostat
Linux 2.6.32-220.el6.x86_64 (a01.offline.stat.laifeng.m6.youku) 2015年04月10日 _x86_64_ (8 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
1.51 0.00 0.26 0.10 0.00 98.13
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda 2.33 6.93 300.55 56906732 2468047708
17:54 [[email protected]]$ cat /proc/sys/net/ipv4/ip_local_port_range
1024 65000
65000-1024=63976
出现大量TIME_WAIT,将/proc/sys/net/ipv4/tcp_fin_timeout设置为更小的值来快速释放请求。
17:56 [[email protected]]$ cat /proc/sys/net/ipv4/tcp_fin_timeout
5
netstat -tunple | grep .[1-4]
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 0 25247484 -
tcp 0 0 0.0.0.0:21296 0.0.0.0:* LISTEN 0 25279969 -
tcp 0 0 0.0.0.0:2999 0.0.0.0:* LISTEN 29 25279941 -
tcp 0 0 0.0.0.0:41978 0.0.0.0:* LISTEN 0 168874942 -
tcp 0 0 10.100.20.51:5308 0.0.0.0:* LISTEN 0 10299 -
tcp 0 0 0.0.0.0:3360 0.0.0.0:* LISTEN 27 126465794 -
tcp 0 0 0.0.0.0:22022 0.0.0.0:* LISTEN 0 10060 -
tcp 0 0 127.0.0.1:199 0.0.0.0:* LISTEN 0 10026 -
tcp 0 0 :::8011 :::* LISTEN 500 185203471 23084/java
tcp 0 0 :::3533 :::* LISTEN 29 25279949 -
tcp 0 0 :::111 :::* LISTEN 0 25247489 -
tcp 0 0 :::19925 :::* LISTEN 500 184462256 12313/java
tcp 0 0 :::3647 :::* LISTEN 0 168874943 -
tcp 0 0 :::11012 :::* LISTEN 500 75328206 41678/java
tcp 0 0 :::22022 :::* LISTEN 0 10062 -
udp 0 0 0.0.0.0:161 0.0.0.0:* 0 10024 -
udp 0 0 0.0.0.0:946 0.0.0.0:* 0 25279929 -
udp 0 0 0.0.0.0:11592 0.0.0.0:* 0 183624060 -
udp 0 0 0.0.0.0:40154 0.0.0.0:* 29 25279937 -
udp 0 0 0.0.0.0:736 0.0.0.0:* 0 25247483 -
udp 0 0 0.0.0.0:111 0.0.0.0:* 0 25247479 -
udp 0 0 0.0.0.0:6791 0.0.0.0:* 0 25279968 -
udp 0 0 :::736 :::* 0 25247488 -
udp 0 0 :::111 :::* 0 25247486 -
udp 0 0 :::30065 :::* 29 25279945 -
18:18 [[email protected]]$ netstat -n | awk '/^tcp/ {++state[$NF]} END {for(key in state) print key,"\t", state[key]}'
TIME_WAIT 8651
CLOSE_WAIT 1
FIN_WAIT1 20
ESTABLISHED 247
SYN_RECV 147
CLOSING 1
18:19 [[email protected]]$ netstat -n | awk '/^tcp/ {++state[$NF]} END {for(key in state) print key,"\t", state[key]}'
TIME_WAIT 44821
CLOSE_WAIT 8
FIN_WAIT1 33
ESTABLISHED 99
SYN_RECV 17
CLOSING 2
tty:[2] jobs:[0] cwd:[/opt/nfs/10.100.20.33/logs/data/stat/web]
18:19 [[email protected]]$ cat /proc/net/netstat
TcpExt: SyncookiesSent SyncookiesRecv SyncookiesFailed EmbryonicRsts PruneCalled RcvPruned OfoPruned OutOfWindowIcmps LockDroppedIcmps ArpFilter TW TWRecycled TWKilled PAWSPassive PAWSActive PAWSEstab DelayedACKs DelayedACKLocked DelayedACKLost ListenOverflows ListenDrops TCPPrequeued TCPDirectCopyFromBacklog TCPDirectCopyFromPrequeue TCPPrequeueDropped TCPHPHits TCPHPHitsToUser TCPPureAcks TCPHPAcks TCPRenoRecovery TCPSackRecovery TCPSACKReneging TCPFACKReorder TCPSACKReorder TCPRenoReorder TCPTSReorder TCPFullUndo TCPPartialUndo TCPDSACKUndo TCPLossUndo TCPLoss TCPLostRetransmit TCPRenoFailures TCPSackFailures TCPLossFailures TCPFastRetrans TCPForwardRetrans TCPSlowStartRetrans TCPTimeouts TCPRenoRecoveryFail TCPSackRecoveryFail TCPSchedulerFailed TCPRcvCollapsed TCPDSACKOldSent TCPDSACKOfoSent TCPDSACKRecv TCPDSACKOfoRecv TCPAbortOnSyn TCPAbortOnData TCPAbortOnClose TCPAbortOnMemory TCPAbortOnTimeout TCPAbortOnLinger TCPAbortFailed TCPMemoryPressures TCPSACKDiscard TCPDSACKIgnoredOld TCPDSACKIgnoredNoUndo TCPSpuriousRTOs TCPMD5NotFound TCPMD5Unexpected TCPSackShifted TCPSackMerged TCPSackShiftFallback
TcpExt: 0 0 3 0 186718 13422 7 17 0 0 322237 78250 0 0 0 0 4369693 5424 8900 0 0 2022428405 323175290 22206230704 0 3489547955 114375378 299341056 1944267878 6 28927 0 5 1 3 0 3 14 535 100 53673 1194 0 5595 672 53486 2520 18430 50444 5 2344 78 48742817 9428 74 5332 91 0 210339 19 0 44 0 0 0 0 4113 783 2 0 0 38683 76959 63628
IpExt: InNoRoutes InTruncatedPkts InMcastPkts OutMcastPkts InBcastPkts OutBcastPkts InOctets OutOctets InMcastOctets OutMcastOctets InBcastOctets OutBcastOctets
IpExt: 0 0 4 0 0 0 3007677322734 395066245888 128 0 0 0
tty:[2] jobs:[0] cwd:[/opt/nfs/10.100.20.33/logs/data/stat/web]
18:25 [[email protected]]$ cat /proc/net/snmp
Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates
Ip: 1 64 4328108569 0 0 0 0 0 4328108569 3570618131 0 35 0 0 0 0 0 0 0
Icmp: InMsgs InErrors InDestUnreachs InTimeExcds InParmProbs InSrcQuenchs InRedirects InEchos InEchoReps InTimestamps InTimestampReps InAddrMasks InAddrMaskReps OutMsgs OutErrors OutDestUnreachs OutTimeExcds OutParmProbs OutSrcQuenchs OutRedirects OutEchos OutEchoReps OutTimestamps OutTimestampReps OutAddrMasks OutAddrMaskReps
Icmp: 88177 0 19948 31 0 0 0 68195 3 0 0 0 0 68207 0 9 0 0 0 0 3 68195 0 0 0 0
IcmpMsg: InType0 InType3 InType8 InType11 OutType0 OutType3 OutType8
IcmpMsg: 3 19948 68195 31 68195 9 3
Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts
Tcp: 1 200 120000 -1 148459742 105531 20004 234844 24 4327835540 3570164939 136763 67 189167
Udp: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors
Udp: 211136 10 0 274520 0 0
UdpLite: InDatagrams NoPorts InErrors OutDatagrams RcvbufErrors SndbufErrors
UdpLite: 0 0 0 0 0 0
tty:[2] jobs:[0] cwd:[/opt/nfs/10.100.20.33/logs/data/stat/web]
18:25 [[email protected]]$ netstat -s
Ip:
4328110857 total packets received
0 forwarded
0 incoming packets discarded
4328110857 incoming packets delivered
3570620298 requests sent out
35 dropped because of missing route
Icmp:
88177 ICMP messages received
0 input ICMP message failed.
ICMP input histogram:
destination unreachable: 19948
timeout in transit: 31
echo requests: 68195
echo replies: 3
68207 ICMP messages sent
0 ICMP messages failed
ICMP output histogram:
destination unreachable: 9
echo request: 3
echo replies: 68195
IcmpMsg:
InType0: 3
InType3: 19948
InType8: 68195
InType11: 31
OutType0: 68195
OutType3: 9
OutType8: 3
Tcp:
148459742 active connections openings
105531 passive connection openings
20004 failed connection attempts
234844 connection resets received
24 connections established
4327837826 segments received
3570167104 segments send out
136763 segments retransmited
67 bad segments received.
189168 resets sent
Udp:
211136 packets received
10 packets to unknown port received.
0 packet receive errors
274520 packets sent
UdpLite:
TcpExt:
3 invalid SYN cookies received
186718 packets pruned from receive queue because of socket buffer overrun
13422 packets pruned from receive queue
7 packets dropped from out-of-order queue because of socket buffer overrun
17 ICMP packets dropped because they were out-of-window
322240 TCP sockets finished time wait in fast timer
78250 time wait sockets recycled by time stamp
4369729 delayed acks sent
5424 delayed acks further delayed because of locked socket
Quick ack mode was activated 8900 times
2022433357 packets directly queued to recvmsg prequeue.
323176655 packets directly received from backlog
22206594458 packets directly received from prequeue
3489551024 packets header predicted
114377336 packets header predicted and directly queued to user
299341071 acknowledgments not containing data received
1944271044 predicted acknowledgments
6 times recovered from packet loss due to fast retransmit
28927 times recovered from packet loss due to SACK data
Detected reordering 5 times using FACK
Detected reordering 1 times using SACK
Detected reordering 3 times using reno fast retransmit
3 congestion windows fully recovered
14 congestion windows partially recovered using Hoe heuristic
TCPDSACKUndo: 535
100 congestion windows recovered after partial ack
53673 TCP data loss events
TCPLostRetransmit: 1194
5595 timeouts after SACK recovery
672 timeouts in loss state
53486 fast retransmits
2520 forward retransmits
18430 retransmits in slow start
50444 other TCP timeouts
TCPRenoRecoveryFail: 5
2344 sack retransmits failed
78 times receiver scheduled too late for direct processing
48742817 packets collapsed in receive queue due to low socket buffer
9428 DSACKs sent for old packets
74 DSACKs sent for out of order packets
5332 DSACKs received
91 DSACKs for out of order packets received
210339 connections reset due to unexpected data
19 connections reset due to early user close
44 connections aborted due to timeout
TCPDSACKIgnoredOld: 4113
TCPDSACKIgnoredNoUndo: 783
TCPSpuriousRTOs: 2
TCPSackShifted: 38683
TCPSackMerged: 76959
TCPSackShiftFallback: 63628
IpExt:
InMcastPkts: 4
InOctets: 3007679753483
OutOctets: 395066653417
InMcastOctets: 128