????12??????????????
??????????????е???????????ò????
??????????????????У?????????????ò???У???????????????????????????????????????????г?????????????????ó???????????????У????????????????????????ж???????????????????????£????н?????????е?????????????????ж????????????????????????????? “????”?????????????????????????????????????select??epoll ???????????????????????????????????????????????????????????????????????????????ò???е????????????????????????????????o??????????????????????????????????????????????????????????????????????“????”?????????????????????????????
????????“????”????????????????У?????????е????????????н??????????????????6?????


????
?6

????????????е??????????????“????”??????????????????????????????????????????????????????
????????????????????????????μ???ò????
?????????????????????????????????CPU???????????????????????????ж??У?????????????????С?????????????????????????????????CPU????佨???μ???ò???У?????????????????????????????У????7????????????????????????????μ???г????
???????????з??????????????
????L*( X*S3/H3+S1/H1+S2/H2)
?????????μ???к????????
????X*S3/H3+L’*(S1/H2+S2/H2)
????????г????????????£??????μ???ò???к?????????????????????????????????


????
?7

??????????????????????????????
??????????????????????????????????????????????????????????I/O????????????????????????????????????????????????????????????????????I/O?????????????????????????????£?????????????????????????????????????????????
???????????????“???”??????“???”???????????????????????????????????CPU???????????CPU?????й?????????????????????????????
????Z*N1
????N1??CPU??????Z??????????????????1??2???
???????????????????????????????????????????y????????“???”????????Щ????????????????к????????????????????????????????????????????????Z????????1?????
????????????????????????????????С?????????????????????????CPU???????????????????????????岻????????????????????????????
????13??CPU??????I/O????????????????
??????????????????????????????????????????????Щ??CPU?????I/O?????????????????μ?????Σ???????????????CPU?????????????????I/O?????????????????????η???????????????????
????CPU?????
??????????紦???CPU??????????Ρ?
????????????????????????????????????Ρ?
??????????CPU???????????????и??????????????????????????CPU????????????????????????????????????????????????????
????????CPU????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????
????I/O?????
??????????紦???I/O??д??????Σ?CPU?????С??????????
??????????????????????????????????????????Ρ?
????????????????????????????????????????????????1?????
????min(H3/S3??H2/S2)* (X*S3/H3+S2/H2)
????????????CPU???????
????????I/O???????????????????????????????????????????????????????????????????С?????????????з???????????????????????????CPU??????????????????紦???????????????μò??????
??????????????????????????I/O???????????????????????????????
????14???????????????
????????????????????????????????????????????????????????????????????????http?????????nginx???????php????mysql?????8???


??
???8

??????????????????????????????????????????μ???????
??????????
???????????С???????
???????
???????????????
??????????
??????????*??????
??????????????????????????????????????????????????????????????????????????????????????????????????к???????????????????php??mysql??????????????????????????????????????????????????????????????????2????????????????????????????????
????php????????????????紦????CPU?????м????ò???У???PHP?????????????nginx??顣
??????????
???????????????????????????????????????????????????????A??????B?????A????????????????????B?????????????????B????????????????B
????????B?????????????????A???????????????????????????????????÷???????????????????????????????????????????
????A???????? = A????????*???A
????A???????? = B????????
???????A =???B
????????
????A???????? = B????????*???B
????15????ν??????????
????????????????????????????????????????????????????????????????????????????????????????????伸????????????????????????????????????????????????????????????????????????????Щ???????????????????в???????????????????????????????????????????????????siege?????
?????ù?????в?????·
???????????????????????????????????????????
????A???????? = B????????*???B
??????
????B???????? = A????????/???B
???????????????????????ò????????????????????????????????????????
????????????????????????????????????H-S-F??????????????????????????????????????????????????ó??????С???
?????????????????????????????????????????????????????????????????
?????????????С??????????????????????ó??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????????siege
????Ben: $ siege -u shemp.whoohoo.com/Admin.jsp-d1 -r10 -c25
????..Siege 2.65 2006/05/11 23:42:16
????..Preparing 25 concurrent users for battle.
????The server is now under siege...done
????Transactions: 250 hits
????Elapsed time: 14.67 secs
????Data transferred: 448000 bytes
????Response time: 0.43 secs
????Transaction rate: 17.04 trans/sec
????Throughput: 30538.51 bytes/sec
????Concurrency: 7.38
????Status code 200: 250
????Successful transactions: 250
????Failed transactions: 0
????Transaction rate ???????
????Response time  ????
????Concurrency ???????
?????????????
?????????????????????????????????????????????????????????????????????????????????????????nginx??php????mysql??????о????????????????????CPU???????I/O????????????????????????????????????????????????????????????????????????????????
?????ο?????
????1. UNIX ??????
????2. High Performance MySQL