Äîêóìåíò âçÿò èç êýøà ïîèñêîâîé ìàøèíû. Àäðåñ
îðèãèíàëüíîãî äîêóìåíòà
: http://www.arcetri.astro.it/manual/ko/misc/perf-tuning.html
Äàòà èçìåíåíèÿ: Mon Jan 21 19:44:30 2013 Äàòà èíäåêñèðîâàíèÿ: Fri Feb 28 07:17:55 2014 Êîäèðîâêà: ISO8859-5 Ïîèñêîâûå ñëîâà: ï ï ï ï ï ï ï ï ï ï ï ï ï ð ï ð ï ð ï ð ï ð ï ð ï ð ï ð ï ð ï ð ï ð ï ð ï ð ï ð ï ð ï ð ï ð ï ð ï ð ï ð ï ð ï ð ï ð ï ð ï ð ï |
Apache HTTP Server Version 2.2
ÎÖÖÔÔÅ 2.0ÐÊ ÁòÄÙÀ? Ö?ÖÓÀÅÄÙÌÊÀ? ÌÊÄÙÐ× Áå×?ÐÜ ÈÒÅÅÇß ÌÃÀø×á É?Ïû Ð?Ì-É?ÐÜÄé. Ê?ÔÅÈÆÕ? ÁòÇßÐË ÌÌÏüÁòÐ?×è ÌÃÀø×ßÑ? ÎÚÎâÑ?ÈÈ ÎÖÖÔÔÅ 2.0ÐÊ Í×Ñ? ÈÉÐÊ ÀöÏü Ã?ÐÊ ÌÊÄÙÐË ÃÍÄé.
ÎÖÖÔÔÅ 1.3À? ÊåÁÃ×èÌ- 2.0 É?Ð?ÐÊ ÓÃÈ?Ç?À? Ø?ÐõÌÊ(scalability)ÐË Ã?ÐÜÁòÐ?×è ÈÉÐÊ ÓæÐ?Ø-È? ×ïÄé. ÁòÊËÀ?ÐÈÇÞ ÄûÊÞÊà ÓæÐ?Ø-×á À?ÐË Ë÷Ïû×áÄé. ÁçÇ?Ã? ÔÔÖÔÐßÍÓ Ø?ÐÊ Í××ðÍÓ ÌÃÑ?ÐÜ ÌÊÄÙÏÅ Õ? ÏÅ×òÐË Ñé Ì? ÐæÄé. ÐÜ É?Ì-ÄÒ ÎÖÖÔÔÅ 2.0Ð× ÌÊÄÙÐË ×òË?×ßÁòÐ?×è Ì-É? À?È?ÐêÀÅ ÌÃÑ?×â Ì? ÐæÄÒ ÏÙÌ×ÐË ÌÃÈý×áÄé. ÎþÆ ÌÃÑ? ÏÙÌ×ÐÊ Ð?Ì-É?ÀÅ ×ßÅõÏ?ÎþÏÝ ÏþÏÅÓÌÑ?Ð× ÁòÄÙÐË Ä? Ðï ØÀÏû×ßÅÅÇß ×ßÄÒ ÉíÈù, ÎþÆ ÏÙÌ×ÐÊ ÌãÅÅÈ? Ð?×è ÁòÄÙÐË ØåË×áÄé.
Ð?Ì-É? ÌÊÄÙÏÅ ÀÅÐõ Õ? ÏÅ×òÐË ÑæÄÒ ÀÝÐÊ ÈîÈ?È?Äé. ÍÊÏâÐÊ
ÏôÓËÄ÷ Ñ?Ï?ÍÓÀ?ÐË Ë÷ÏûÐêÀÅ "ÓöÊàØ? Ê?È?ÄéÀý" ËÀ?×ßÑ? È?×ßÀä
ÄÓÈ?ÁòÆ?É?ÏÅ Ð?Ì-É?ÄÒ ÍÊÏâÐË ×ßÈù ÎØÅØÄé. ÄÐÇÑÑ?Èù Ë÷ÏûÐêÄÒ
Ñ?Ñ?×ßÀý ÄéÍÓ Ñ?Ìã×ßÏ? ÊÞ×ßÀÅ ÀøÌã Ñ?ÀÅ×áÄé. MaxClients
Ñ?ÍÓÎþÈ? ÑÆÐ×ßÏ?
Ð?Ì-É?ÀÅ ÍÊÏâÐË ×â Ñ?ÅÅÇÞ ÈÉÐÊ ÐêÍÔÐË ÈÈÅùÑ?ÎÚÅÅÇß ×èÎï
×áÄé. ÉöÉÐÊ À?Äì×ßÄé: top
À? ÀÀÐÊ ÅÅÁÈÏÅÌ-
×ÑÇÞÌÌÍÊ ÈåÇßÐË ÊÈÀý ÎÖÖÔÔÅ ×ÑÇÞÌÌÍÊÐ× Ö?Áå ÈîÈ?È? Ë÷ÏûÇ?ÐË
ÎÛÎÖÃÍØÔ, Ð?ÓÌ Ë÷ÏûÀÅÄÙ×á ÈîÈ?È?ÏÅÌ- ÄéÈ? ×ÑÇÞÌÌÍÊÅùÐÜ Ë÷Ïû×â
À?À?ÐË Ë? À?ÏÅÌ- Ã?Ä?Äé.
Ã?ÈãÑ?ÄÒ Ö?É?×ßÄé: ÓöÊàØ? Ê?È? CPU, ÓöÊàØ? Ê?È? ÃçÖ?Ï?Ô?Åõ, ÓöÊàØ? Ê?È? Å?ÍÊÕ?, Ï?ÁòÌ- "ÓöÊàØ? Ê?È?"ÐÊ Í××øÐË ×èÌ- ÀñÑ?×èÎï ×áÄé.
ÏþÏÅÓÌÑ?ÄÒ ÊÈÕû À?Ðê ÎÛÎÖÌ- ÌÁÕÓ×â ÐßÐÜÄé. ÁçÇ?Ã? ÐßÉíÐ?ÐÈÇÞ Ð?Ïû×ßÄéÀý Ö×ÈýÅØ ÈþÀÅÑ? Ñ?Ô?ÐÜ ÐæÄé:
ÌÁÕÓ×á ÏþÏÅÓÌÑ?Ð× ÓæÍÕ ÎØÑ? É?Ð?À? ÖàÔÅÈ? Í××ð×áÄé. ÈÉÐÊ ÏþÏÅÓÌÑ? Ñ?ÐëË÷ÄÒ ÓæÁé TCP ÍÊÕÓÀ? ÎÂÇÉÅõ Æ?ÐÜÊúÇ?È?ÏÅ ÈÉÐÊ ÌãÅÅ×òË?ÐË ×ïÄé.
ÏþÏÅÓÌÑ?ÀÅ sendfile(2)
ÍÓÍÊÕëØ?ÓòÐË
Ñ?Ï?×áÄéÈù, ÐÜÈ? Ë÷Ïû×ßÁòÐ?×á É?Ð?ÐÜÃ? ÖàÔÅÈ? ÌÃÔÅ×ßÏÄÄÒÑ?
Ø?ÐÞ×áÄé. (ÏÉÈ? ÅùÎþ, È?Ä?ÍÊÆ?Èù 2.4 ÐÜË? É?Ð?ÐË Æö×áÄé.
Solaris 8 ÓÚÁò É?Ð?ÐÊ ÖàÔÅÀÅ ×ÚÏô×ßÄé.) Ñ?Ï?×ßÄÒ ÍÓÍÊÕëÐÜÆ?Èù
ÎÖÖÔÔÅ 2ÄÒ sendfile
ÐË Ë÷Ïû×ßÏ? CPUÈ? Ä?
Ë÷Ïû×ßÈ÷ Ñ?Ð? ÖÔÐßÐË Ä? ËÅÈ? Ð?Ìë×â Ì? ÐåÄé.
À?ÇÓÅØ È?Åò | À?ÇÓÅØ Ñ?ÍÓÎþ |
---|---|
ÎÖÖÔÔÅ 1.3 ÐÜÐ?ÏÅ HostnameLookups
Ð× ÁòÊËÀ?ÐÊ
On
ÐÜÏÄÄé. ÏôÓËÐË ÈÆÔÅÁòÐ?ÏÅ DNS ÀÛË?ÐÜ ÃÅÃ?Îï
×ßÉ×ÇÞ ÏôÓËÈÆÄé Ñ?Ï?ÐÜ ËÀõÄé. ÎÖÖÔÔÅ 1.3ÏÅÌ- ÐÜ ÌÃÑ?Ð×
ÁòÊËÀ?ÐÜ Off
ÇÞ Ê?ÀöÅ×Î?Äé. ÇÞÁçÖÔÐßÐ× ÑæÌâÈ?
Ø?ÍÊÖ?ÈýÐÈÇÞ Ê?Ø?×ßÇÑÈù Ï?Ç? ÇÞÁçÓÃÈ? ×ÑÇÞÁçÇ?Ñï ×ßÃ?ÐÞ,
ÎÖÖÔÔÅÏÅ Ö?×äÅØ logresolve
×ÑÇÞÁçÇ?ÐË Ë÷Ïû×ßÆ?.
ÇÞÁçÓÃÈ? ÐëÎ?ÐÜ Ì-É? ÌÊÄÙÏÅ Î×ÏÅ×òÐË ÉÜÔÅÉ×ÇÞ Í×Ñ? Ë÷Ïû×ßÄÒ Ð?Ì-É?ÀÅ ÎÖÄá ÄéÈ? ÔÔ×ËÕÝÏÅÌ- ÇÞÁçÖÔÐßÐË ØÔÓÃÈ?×ßÁö ÉéÆ?Äé.
ÐÜÃ? Allow
from domain
Ñ?ÍÓÎþÈ? Ë÷Ïû×áÄéÈù (Ñÿ, IP ÑæÌâÀÅ ÎÖÄá Ø?ÍÊÖ?ÈýÐÜÃ? ÅÅÈîÐÞÈýÐË
Ë÷Ïû×áÄéÈù) ÊÞÅöÐÜ ÑïÊÉ-Ï? DNS ÀÛË?ÐË (Ï?ÀÛË?ÐË ×áØÔ Î×Ð×ÇÞ
Ê?ÀöÅ×Î?ÄÒÑ? Ø?ÐÞ×ßÁòÐ?×è ÄéÍÓ ÀÛË?) ×èÎï ×áÄé. ÁçÇ?É×ÇÞ
ÌÊÄÙÐË Ã?ÐÜÁòÐ?×è ÐÜÇÁ Ñ?ÍÓÎþÏÅÄÒ ÀÅÄÙ×ßÈù ÐÜÈ?ÄûÍÕ IP
ÑæÌâÈ? Ë÷Ïû×áÄé.Deny
from domain
<Location /server-status>
ÌÍÌ× ÅþÐÈÇÞ
Ñ?ÍÓÎþÐ× Ð?ÏûÉ?Ð?È? Ñ?×á×â Ì? ÐæÐÍÐË ÁòÎÿ×ßÆ?. ÐÜ ÀöÏü
ÑÆÀ×ÏÅ ÈÒÄÒ ÏôÓËÏÅÈÈ DNS ÑÆØÈÈ? ×áÄé. ÄéÐÍÐÊ
.html
À? .cgi
ÖÔÐßÈÈ DNS ÀÛË?ÐË
×ßÄÒ ÏÉÑ?Äé:
HostnameLookups off
<Files ~ "\.(html|cgi)$">
HostnameLookups on
</Files>
ÁçÇ?Ã? CGIÏÅÌ- DNSÈýÐÜ ×ÚÏô×â ËãÐÜÆ?Èù, ×ÚÏô×á Ö?Ñ?
CGIÏÅÌ-ÈÈ gethostbyname
Ø?ÓòÐË ×ßÅÅÇß ÀýÇÑ×èÊÌ
Ì? ÐæÄé.
URL À?À?ÏÅÌ- Options FollowSymLinks
È?
Ë÷Ïû×ßÑ?ÎÚÀý Options SymLinksIfOwnerMatch
È?
Ë÷Ïû×ßÈù ÎÖÖÔÔÅÄÒ ÍÙÊÌÈÅÕ?È? ÀÛË÷×ßÁòÐ?×è ÍÓÍÊÕëØ?ÓòÐË
×áÉ? Ä? ×èÎï ×áÄé. ÖÔÐßÈýÐ× À? ÊÞÊàÈÆÄé ×áÉ?ÎÏ Ä? Ø?ÓòÐË
×áÄé. ÏÉÈ? ÅùÎþ, ÌÃÑ?ÐÜ ÄéÐÍÀ? ÀÀÀý:
DocumentRoot /www/htdocs
<Directory />
Options SymLinksIfOwnerMatch
</Directory>
/index.html
URIÏÅ Äû×á ÏôÓËÐÜ ÐæÄéÀý ÀÅÑ?×ßÐê.
ÁçÇ?Èù ÎÖÖÔÔÅÄÒ /www
, /www/htdocs
,
/www/htdocs/index.html
À?À?ÏÅ Äû×è
lstat(2)
È? Ø?Óò×áÄé. lstats
ÀñÀ?È? ÔÃÍÜ×ßÑ? ÎÚÁòÆ?É?ÏÅ ÏôÓËÐÜ ÅùÎþÏÓ Æ?ÈÆÄé ÈÕÉ? ÀÀÐÊ
ÐëÎ?ÐË ×áÄé. Ñ?Ò? ÍÙÊÌÈÅÕ? ÊÈÎØ ÀÛË÷È? Ï?×áÄéÈù ÄéÐÍÀ?
ÀÀÐÜ ×â Ì? ÐæÄé:
DocumentRoot /www/htdocs
<Directory />
Options FollowSymLinks
</Directory>
<Directory /www/htdocs>
Options -FollowSymLinks +SymLinksIfOwnerMatch
</Directory>
ÐÜ ÀöÏü ÓæÌâ×á DocumentRoot
ÀöÇÞÄÒ ÀÛË÷×ßÑ?
ÎÚÄÒÄé. DocumentRoot ÉëÏÅ ÐæÄÒ ÀöÇÞÇÞ Alias
Ã? RewriteRule
ÐË Ë÷Ïû×á
ÀöÏüÏÅÅÅ Ð?ÏÝ ÊåÍÑ×á ÌÍÌ×ÐÜ ×ÚÏô×ßÄé. ÍÙÊÌÈÅÕ? ÊÈÎØÐË
ÀýÇÑ×ßÑ? ÎÚÀý ÓæÀýÐ× ÌÊÄÙÐË Î?ÐÈÇÑÈù,
FollowSymLinks
È? ÌÃÑ?×ßÀý,
SymLinksIfOwnerMatch
ÄÒ ÐÄûÇÞ ÎØÅØÄé.
URL À?À?ÏÅÌ- overridesÈ? ×óÏû×áÄéÈù (ÊÈÕû
.htaccess
ÖÔÐß) ÎÖÖÔÔÅÄÒ ÖÔÐßÈýÐ× À? ÊÞÊàÈÆÄé
.htaccess
È? Ï-Áö ÍÓÅÅ×áÄé. ÏÉÈ? ÅùÎþ,
DocumentRoot /www/htdocs
<Directory />
AllowOverride all
</Directory>
/index.html
URIÏÅ Äû×á ÏôÓËÐÜ ÐæÄéÀý ÀÅÑ?×ßÐê.
ÎÖÖÔÔÅÄÒ /.htaccess
, /www/.htaccess
,
/www/htdocs/.htaccess
È? Ï-ÇÑÀý ÍÓÅÅ×áÄé.
×èÀñÓ?ÐÊ ÎåÐ× Options FollowSymLinks
ÀöÏüÏÝ
ÊåÍÑ×ßÄé. ÓæÀýÐ× ÌÊÄÙÐË Î?ÐÈÇÑÈù ÖÔÐßÍÓÍÊÕëÏÅ Äû×èÌ- ×çË?
AllowOverride None
ÐË Ë÷Ïû×áÄé.
ÀÅÄÙ×ßÀý Ñ?Ò? ÑÆÁíÐ× ÌÊÄÙ×òË?ÏÅÅÅ À?ÍÙÐÜ ÐæÄéÈù ÃËÏû×?Ë?ÐË ÈÇÄÒÄé. Í×Ñ?ÇÞ ×?Ë?Ð× ÐÜÅöÐÊ ÌÊÄÙÐ?×ßÊÈÄé ÐëÄé. Ì-É?È? Ê?È?Àä ×â Ì? ÐæÄé. ÄéÐÍÀ? ÀÀÐÜ ÏÝÐßÅõÔ?ÅõÈ? Ë÷Ïû×ßÄÒ ÄûÍÕ:
DirectoryIndex index
ÏßÐ?×á ÈåÇßÐË Ë÷Ïû×áÄé:
DirectoryIndex index.cgi index.pl index.shtml index.html
ÀÅÐõ Ø÷×á ÀÝÐË ÎåÏÅ ÅàÄé.
Æ×, Å?ÇÊÕôÈ?ÏÅÌ- ÖÔÐßÅùÐË Ó?ÄÒ MultiViews
ÊÈÄéÄÒ, ×á ÖÔÐßÈÈ ÐàÐÈÈù ×ÚÏô×á Ñ?ÊÈÈ? Î?ÐË Ì? ÐæÄÒ
type-map
ÖÔÐßÐË Ñ?Ñ? ÈÈÅõÄÒ ÀÝÐÜ Ä? Ê?È?ÐË
ÈýÍÙ×ßÆ?.
Ë÷ÐÜÖ?ÏÅ ÃËÏû×?Ë?ÐÜ ×ÚÏô×ßÄéÈù ×?Ë?ÐË Ð?×è Options
MultiViews
Ñ?ÍÓÎþÈ? Ë÷Ïû×ßÁòÊÈÄé type-map
ÖÔÐßÐË ÀýÇÑ×ßÆ?. ×?Ë?ÉöÉÏÅ Äû×á ÐêÌÌ×á ÌÃÈýÀ?
type-map
ÖÔÐßÐË ÈÈÅõÄÒ ÉöÉÐÊ ÃËÏû×?Ë? É?Ì-È? Ò?Àý×ßÆ?.
ÏÉÈ? ÅùÎþ, server-side-includeÈ? ÓÃÈ?×ßÄÒ Åþ ÎÖÖÔÔÅ
2.0ÐÜ Ð?Ìë×â ÖÔÐßÐË ÐàÐËÆ? ÏþÏÅÓÌÑ?ÀÅ mmap(2)
ÅþÐË Ñ?Ï?×áÄéÈù ÖÔÐßÐË ÈîÈ?È?ÄûÐÐ×áÄé.
Ï?Ç? ×ÓÇÅÖ?ÏÅÌ- ÈîÈ?È?ÄûÐÐÐË ÌÊÄÙÐË ×òË?×áÄé. ÁçÇ?Ã? ÈîÈ?È?ÄûÐÐÐÜ Ì-É?Ð× ÌÊÄÙÐË ÆÃÎþÖ?È?Àý ÍÙÑ?Îþ ÎØÑ?ÌÊÐË ×èÔÅÄÒ ÀöÏüÀÅ ÐæÄé:
ÎþÆÂ ÏþÏÅÓÌÑ?ÏÅÌ- mmap
ÐÊ CPU ÀÃÌ?ÀÅ
ÈÉÎÖÑ?Æ? read(2)
ÈÈÕ- Ø?ÐõÌÊÐÜ ÑÑÑ? ÎÚÄé.
ÏÉÈ? ÅùÎþ, ÄéÑï×ÑÇÞÌÌÌ- Solaris Ì-É?ÏÅÌ- ÎÖÖÔÔÅ 2.0ÐÊ
ÑÎÑÎ mmap
ÐË Ë÷Ïû×ßÑ? ÎÚÐËÆ? Ì-É?ÀÅ ÓÃÈ?×á
ÖÔÐßÐË Ä? ËÅÈ? Ð?Ìë×áÄé.
NFS ÈÆÏþÖ?×á ÖÔÐßÍÓÍÊÕëÏÅ ÐæÄÒ ÖÔÐßÐË ÈîÈ?È?ÄûÐÐ×ßÄÒ ÅÅÑïÏÅ ÄéÈ? NFS Õ?Æ?ÐÜÎ?Ö?ÏÅ ÐæÄÒ ×ÑÇÞÌÌÍÊÀÅ ÖÔÐßÐË Ñ?ÏüÀÕÃ? ÖÔÐßÕ?ÁòÈ? ÑéÐÜÈù, Ð?Ì-É? ×ÑÇÞÌÌÍÊÀÅ ÄéÐÍ É?ÏÅ ÈîÈ?È?ÄûÐÐ×á ÖÔÐßÃËÏûÐË ÐàÐËÆ? bus errorÀÅ ÉïË×â Ì? ÐæÄé.
Ð?Ð× ÑÆÀ×ÏÅ ×èÄ÷×ßÈù Ð?Ìë×ßÄÒ ÖÔÐßÐË ÈîÈ?È?ÄûÐÐ×ßÑ?
ÎÚÅÅÇß EnableMMAP off
È? Ë÷Ïû×èÎï ×áÄé. (ÑæÐ×:
ÐÜ Ñ?ÍÓÎþÄÒ Å?ÇÊÕôÈ?ÊÀÇÞ Ê?Àö×â Ì? ÐæÄé.)
ÎÖÖÔÔÅÄÒ ÏþÏÅÓÌÑ?ÀÅ sendfile(2)
ÐË Ñ?Ï?×ßÈù
ÔÏÃÞ sendfileÐË Ë÷Ïû×ßÏ? -- ÏÉÈ? ÅùÎþ, Ñ?Ð? ÖÔÐßÐË Ì-ÊåÍÊ×âÆ?
-- Ð?Ìë×â ÖÔÐßÐË Ñ?Ñ? ÐàÑ?ÎÚÐË Ì? ÐæÄé.
Ï?Ç? ×ÓÇÅÖ?ÏÅÌ- sendfileÐË Ë÷Ïû×ßÈù readÏÝ sendÈ? Å?ÇÞ ×â ×ÚÏôÀÅ Î?ÎþÌ- ËÅÆ?Ñ?Äé. ÁçÇ?Ã? sendfileÐË Ë÷Ïû×ßÈù Ð?Ì-É?Ð× ÎØÑ?ÌÊÐË ×èÔÅÀäÅ×ÄÒ ÀöÏüÀÅ ÐæÄé:
sendfile Ñ?Ï?ÐÜ ÐïÈ?Å×Î?Àý ÔÔÖÔÐß ÍÓÍÊÕëÐÜ ÐÜÑÅÐË ÉïÀï×ßÑ? È?×ßÄÒ ×ÓÇÅÖ?ÐÜ ÐæÄé. Ö?Ø? ÄéÈ? ÔÔ×ËÕÝÏÅÌ- Í××ðÖÔÐßÐË ÔÔÖÔÐß×ßÏ? sendfile Ñ?Ï?ÐÜ ÐïÈ?ÅØ ÔÔ×ËÕÝÇÞ ÀÅÑ?ÏÒ ÀöÏüÏÅ ÀÅÄÙ×ßÄé.
ÔÏÃÞÐÊ ÐêÍÕÐ× ÔÃÍ?È? Ë÷Ïû×ßÏ? NFSÇÞ ÈÆÏþÖ?×á ÖÔÐßÐË ÎØÑ?Ð?ÐÈÇÞ Ì-ÊåÍÊ×â Ì? Î?ÄÒ ÀöÏüÀÅ ÐæÄé.
Ð?Ð× ÑÆÀ×ÏÅ ×èÄ÷×ßÈù ÖÔÐßÐË sendfile Ð?Ìë×ßÑ? ÎÚÅÅÇß
EnableSendfile off
È? Ë÷Ïû×èÎï ×áÄé. (ÑæÐ×:
ÐÜ Ñ?ÍÓÎþÄÒ Å?ÇÊÕôÈ?ÊÀÇÞ Ê?Àö×â Ì? ÐæÄé.)
ÎÖÖÔÔÅ 1.3 ÐÜÐ?ÏÅÄÒ MinSpareServers
, MaxSpareServers
, StartServers
ÌÃÑ?ÐÜ È?ÅÞ
Ê?ÔÅÈÆÕ? ÀñÀ?ÏÅ Õ? ÏÅ×òÐË ÉÜÓÖÄé. Ö?Ø? ÎÖÖÔÔÅÄÒ ÐëÎ?ÐË
Ì-ÊåÍÊ×ßÁòÐ?×è ÓöÊà×á ÐêÍÔÌ?ÏÅ ÄéÄéÈ? Æ?ÁþÑ? "ÅÅÄî" ÁòÀ?ÐÜ
×ÚÏô×ïÄé. ÓÃÐÍ StartServers
Àà ÐêÍÔÐË
ÈÈÅ÷ØÔ, MinSpareServers
ÌÃÑ?À?ÁþÑ? ÓÚÄ÷ ÐêÍÔÐË ×ßÃ?ÎÏ ÈÈÅùÎ?Äé. ÁçÇÅÌ- StartServers
ÁòÊËÀ?ÐÜ
5
ÐÞ Ì-É?ÏÅ Õ?Æ?ÐÜÎ?Ö? 100ÀÃÀÅ ÅÏÍÓÏÅ Ñ?Ìã×ßÈù
ÊÞ×ßÈ? ÓÃÈ?×ßÁòÏÅ ÓöÊà×á ÐêÍÔÐË ÈÈÅùÁòÁþÑ? 95ÓÚÀÅ ÀÙÇØÄé.
ÐêÑæ Ð÷ÍÓÐë×ßÑ? ÎÚÄÒ Í×Ñ? Ì-É?ÏÅÌ-ÄÒ Ðï ÅÏÐë×ßÑ?ÈÈ, 10ÊàÀ?ÈÈ
Í××ð×ßÄÒ Ê?ÔÅÈÆÕ? ÀñÀ?ÄÒ ÈÕÏü Ã?ËêÀä Ã?ÏÒÄé.
ÓÚÄ÷ ×áÀà ÁäÔ?ÐÊ ÐêÍÔÐË Ë?ÇÞ ÍÓÐë×ßÈùÌ- Ì-É?ÏÅ É?È?È?
ÑæÑ? ÎÚÐÈÇÑÀý Ñ?×ïÄé. ÔÔ×ËÕÝÀÅ ÐêÍÔÐË ÍÓÐë×ßÄÐÆ? ÉéËêÈù
ÏôÓËÐË Ì-ÊåÍÊ×â Ì? Î?Äé. ÁçÇ?Ã? ÐÜ ÁäÔ?ÐÜ ÎÖÖÔÔÅÐ× ÓÌÀ?
ÌÊÄÙÏÅ Î×ÏÅ×òÐË ÑæÎþ Ê?Àö×ßÏÄÄé. ÎÖÖÔÔÅ 1.3ÏÅÌ- ÓÚÄ÷ ×áÀÃ
ÁäÔ?ÐÊ ÏßØ-Å×Î?Äé. ÔêÅõÄÒ ÐêÍÔ ×áÀÃÈ? ÈÈÅùÀý, 1ÓÚ Í?Àý,
ÅÞÀÃÈ? ÈÈÅùÀý, 1ÓÚ Í?Àý, ÃçÀÃÈ? ÈÈÅùÀý, ÐÜÇÁ ÍÔÐÈÇÞ ÓÚÄ÷
ÐêÍÔÐË 32Àà ÈÈÅùÆ?ÁþÑ? Ñ?Ì?ÇÞ Ñ?ÀÅ×áÄé. ÐêÍÔÌ?ÀÅ MinSpareServers
ÌÃÑ?ÏÅ ÄéÄéÈ?Èù
Ñ?ÀÅÈ? ÑïÄì×áÄé.
ÐÜ ÀöÏü ÉíÐÐÌãÅÅÀÅ ËÅÆ?Ñ?Ì- MinSpareServers
, MaxSpareServers
, StartServers
È? ÀÕÐ× ÌÃÑ?×â ×ÚÏôÀÅ Î?Äé. ÐßÓÚÏÅ
ÐêÍÔÐË 4Àà ÐÜË? ËÌÊ×ßÈù ErrorLog
ÏÅ ÁòÇß×áÄé. ÐÜÇÁ ÏÐÇ?É?ÐÜ
ÈÉÐÜ ÊÈÐÜÈù ÐÜ ÌÃÑ?ÅùÐË ÑÆÐ×ßÁö ÉéÆ?Äé.
mod_status
ÀñÀ?ÀÅ ÅÅÏ?ÐÜ ÅÙ ÀÝÐÜÄé.
×ÑÇÞÌÌÍÊ ËÌÊÀ? À?ÇÓ×ßÏ? MaxRequestsPerChild
ÌÃÑ?ÐÊ
×ÑÇÞÌÌÍÊÈ? ÑÎÇñ×áÄé. ÁòÊËÀ?ÐÊ ÐêÍÔÄ÷ ÓÃÈ?×â ÏôÓËÌ?ÏÅ Ñ?×áÐÜ
Î?ÄéÄÒ 0
ÐÜÄé. ×?Ð÷ ÌÃÑ?ÐÜ 30
À?
ÀÀÐÜ ÈÕÏü ÐëÐÊ À?ÐÈÇÞ ÌÃÑ?Å×ÐæÄéÈù, À?ÐË Ë?Ä÷Ø? Ã?Ø? ×ÚÏôÀÅ
ÐæÄé. SunOSÃ? ÏÐÇÅÅØ Solaris É?Ð?ÐË Ë÷Ïû×áÄéÈù, ÈîÈ?È?Ð?ÓòÆ?É?ÏÅ
ÐÜ À?ÐË 10000
Ñ?ÅÅÇÞ ÌÃÑ?×ßÆ?.
Ï?ÀñÐ?Ñ?(keep-alive)È? Ë÷Ïû×áÄéÈù ÐêÍÔÅùÐÊ ÐÜÉÜ Ï-ÈÀ
Ï?ÀñÏÅÌ- ÓïÀÅ ÏôÓËÐË ÁòÄéÈ?È÷ ÎÖÉ?ÀÝÅÅ ×ßÑ?ÎÚÁòÆ?É?ÏÅ ÀøÌã
ÉéËêÄé. KeepAliveTimeout
Ð×
ÁòÊËÀ? 15
ÓÚÄÒ ÐÜÇÁ ×?Ë?ÐË ÓæÌâØ-×áÄé. ÃçÖ?Ï?
ÄûÏ?Ö?À? Ì-É? ÐêÏ? À?Ð× Áå×?ÐÜ ÈÒÀä ÌÃÑ?×áÄé.
Ï?ÀñÐ?Ñ?Ð× ÄûÊÞÊàÐ× ÐÜÑÅÐÜ Ë÷Æ?Ñ?ÁòÆ?É?ÏÅ ÎþÆ ÀöÏüÏÅÅÅ
ÐÜ À?ÐË 60
ÓÚ ÐÜË?ÐÈÇÞ ÏÓÈ?Ñ? ÈÆÆ?.
ÎÖÖÔÔÅ 2.xÄÒ ÄéÑïÓÃÈ?È?Åò
(MPMs)ÐÜÆ?ÄÒ ÁÃÓÌ×â Ì? ÐæÄÒ ÅÏÁòØ- È?Å?ÐË Ñ?Ï?×áÄé. ÎÖÖÔÔÅÈ?
ÔÔÖÔÐß×âÆ? MPMÐË ÌÁÕÓ×èÎï ×áÄé. beos
,
mpm_netware
, mpmt_os2
,
mpm_winnt
ÏÝ ÀÀÐÜ Ö?Ñ? ×ÓÇÅÖ?ÏÅÌ-ÈÈ Ë÷Ïû×â
Ì? ÐæÄÒ MPMÅÅ ÐæÄé. ÐßÉíÐ?ÐÞ Ð?ÄàÍÊÇ? ÍÓÍÊÕëÐÊ Ï?Ç? MPM
ÑïÏÅ ×ßÃ?È? ÌÁÕÓ×â Ì? ÐæÄé. Ð?Ì-É?Ð× ÌãÅÅÏÝ
Ø?ÐõÌÊ(scalability)ÐÊ ÎþÆ MPMÐË ÌÁÕÓ×ïÃÔÏÅ ÄîÇØÄé:
worker
MPMÐÊ Ï?Ç? ÐêÍÔ ×ÑÇÞÌÌÍÊÀÅ
À?À? Ï?Ç? ÎÂÇÉÅõÈ? Ë÷Ïû×áÄé. À? ÎÂÇÉÅõÄÒ ×áÉ?ÏÅ ×á Ï?ÀñÐË
ÄóÄ÷×áÄé. ÐßÉíÐ?ÐÈÇÞ workerÄÒ prefork MPM ÊÈÄé Ð?ÐÊ
ÈîÈ?È?È? Ë÷Ïû×ßÉ×ÇÞ ÕûÍÕÇ?ÐÜ ÈÉÐÊ Ì-É?ÏÅ Ð?Ð×ßÄé.prefork
MPMÐÊ ÎÂÇÉÅõÀÅ ×áÀÃÐÞ ÐêÍÔ
×ÑÇÞÌÌÍÊÈ? Ï?Ç?Àà Ë÷Ïû×áÄé. À? ×ÑÇÞÌÌÍÊÄÒ ×áÉ?ÏÅ ×á
Ï?ÀñÐË ÄóÄ÷×áÄé. Ï?Ç? ÍÓÍÊÕëÏÅÌ- preforkÐ× ÌãÅÅÄÒ workerÏÝ
ÊåÍÑ×ßÑ?ÈÈ, Ä? ÈÉÐÊ ÈîÈ?È?È? Ë÷Ïû×áÄé. ÄéÐÍÀ? ÀÀÐÊ Ë?ØÂÏÅÌ-
ÎÂÇÉÅõÈ? Ë÷Ïû×ßÑ? ÎÚÄÒ prefork ÉöÍÔÐÜ workerÏÅ Êå×è
ÐÜÑÅÐË ÀÅÑ?Äé: ÎÂÇÉÅõÏÅ ÎØÐ?×ßÑ? (thread-safe) ÎÚÐÊ
Ñ?ËÿÐêÀÅ ÈÈÅ÷ È?ÅòÐË Ë÷Ïû×â Ì? ÐæÀý, ÎÂÇÉÅõ Å?É?Áû Ñ?Ï?ÐÜ
Ê?Îð×á ×ÓÇÅÖ?ÏÅÌ- ÍÁÀä Å?É?Áû×â Ì? ÐæÄé.ÐÜ MPMÅùÀ? ÄéÈ? MPMÏÅ Äû×è Ä? ÐêÌÌ×á Ñ?ÊÈÄÒ MPM É?Ì-È? Ò?Àý×ßÁö ÉéÆ?Äé.
ÈîÈ?È? Ë÷ÏûÇ?ÐÜ ÌÊÄÙÏÅÌ- ÀÅÐõ ÑïÏô×á ÏôÐÞÐÜÁòÆ?É?ÏÅ
Í×Ñ?ÇÞ Ë÷Ïû×ßÑ? ÎÚÄÒ È?ÅòÐË Ñ?ÀÕ×èÊÈÐê. È?ÅòÐË DSOÇÞ ÔÔÖÔÐß×ïÄéÈù À?ÄìØ? Áç
È?ÅòÏÅ Äû×á LoadModule
Ñ?ÍÓÎþÈ? ÑæÌ?ÓÃÈ?×ßÈù
ÅØÄé. ÁçÇÅÌ- È?ÅòÐË Ñ?ÀÕ×ßÀý Í××ð×ßÏ? Ë÷ÐÜÖ?ÀÅ È?ÅòÎ?ÐÜÅÅ
Ñ?Ë?Ð?ÐÈÇÞ ÅÏÐë×ßÄÒÑ? ËüÖüÊÌ Ì? ÐæÄé.
ÉíÄûÇÞ È?ÅòÐÜ ÎÖÖÔÔÅ Í××ðÖÔÐßÏÅ Ñ?Ð?ÐÈÇÞ ÈÅÕ?Å×ÐæÄéÈù Ï?×ßÑ? ÎÚÄÒ È?ÅòÐË Ñ?ÀÕ×ßÁòÐ?×è ÎÖÖÔÔÅÈ? Ð÷ÔÔÖÔÐß×èÎï ×áÄé.
Ï?ÁòÌ- Ä÷Ï?Ø? ÎþÆ È?ÅòÐË Ë÷Ïû×ßÀý Ë÷Ïû×ßÑ? ÈËÑ?
Ð×É?ÐÜ ËÁôÄé. Ñ?ÄôÐÊ Ð?Ë÷ÐÜÖ?ÈÆÄé ÄéÈ?Äé. ÁçÇ?Ã? ÎÖÈÆÅÅ
ÓæÌâ×á mod_mime
,
mod_dir
, mod_log_config
È?ÅòÐÊ Ë÷Ïû×â ÀÝÐÜÄé. ÉÀÇà Ð?Ë÷ÐÜÖ?ÏÅ ÇÞÁçÖÔÐßÐÜ ×ÚÏôÎ?ÄéÈù
mod_log_config
ÄÒ Î?ÎþÅÅ ÅØÄé. ÁçÇ?Ã? ÓïÓÅ×ßÑ?
ÎÚÄÒÄé.
mod_cache
ÀÀÐÊ È?ÅòÀ? ÓæÁé ÀÃÉïÑïÐÞ
worker MPMÐÊ APRÐ× atomic APIÈ? Ë÷Ïû×áÄé. ÐÜ APIÄÒ ÀöÇ?Áî
ÎÂÇÉÅõ ÅÏÁòØ-È? Ð?×â atomic ÈýÇÙÐË Ñ?À?×áÄé.
ÁòÊËÐ?ÐÈÇÞ APRÐÊ À? ÏþÏÅÓÌÑ?/CPU ×ÓÇÅÖ?ÏÅÌ- ÀÅÐõ ØÏÐÂÐ?ÐÞ
ÉöÉÐË Ë÷Ïû×ßÏ? ÐÜ ÈýÇÙÐË ÁÈ×?×áÄé. ÏÉÈ? ÅùÎþ, Ï?Ç? ÓæÍÕ
CPUÏÅÄÒ ×ßÅõÏ?ÎþÇÞ atomic compare-and-swap (CAS) Ï?ËúÐË
×ßÄÒ ÈýÇÙÎþÀÅ ÐæÄé. ÁçÇ?Ã? ÎþÆ ×ÓÇÅÖ?ÏÅÌ- APRÐÊ ÐÜÇÁ
ÈýÇÙÎþÀÅ Î?ÄÒ ÏÐÇÅÅØ CPUÏÝ Ø?Ø?ÌÊÐË Ð?×è Ä? ÄÐÈÀ mutexÁòÉí
ÁÈ×?ÐË ÁòÊËÐ?ÐÈÇÞ Ë÷Ïû×áÄé. ÐÜÇÁ ×ÓÇÅÖ?ÏÅÌ- ÎÖÖÔÔÅÈ?
ÔÔÖÔÐß×âÆ? ÎÖÖÔÔÅÈ? ÓæÍÕ CPUÏÅÌ-ÈÈ Í××ð×â ÀøØÉÐÜÆ?Èù,
ÎÖÖÔÔÅÈ? ÁÈÌÊ×âÆ? --enable-nonportable-atomics
ÏÙÌ×ÐË Ë÷Ïû×ßÏ? Ä? Ê?È? atomic ÁÈ×?ÐË ÌÁÕÓ×â Ì? ÐæÄé:
./buildconf
./configure --with-mpm=worker --enable-nonportable-atomics=yes
--enable-nonportable-atomics
ÏÙÌ×ÐÊ ÄéÐÍÀ?
ÀÀÐÊ ×ÓÇÅÖ?ÏÅ ÏÅ×òÐÜ ÐæÄé:
--enable-nonportable-atomics
È? Ë÷Ïû×ßÈù
APRÐÊ Ê?È? ×ßÅõÏ?Îþ compare-and-swapÐË Ð?×á SPARC
v8plus ÈýÇÙÎþÈ? Ë÷Ïû×áÄé. ÐÜ ÏÙÌ×ÐË Ë÷Ïû×ßÈù atomic
ÈýÇÙÐÜ Ä? ØÏÐÂÐ?ÐÜÑ?ÈÈ (CPUÈ? Ä? Ë÷Ïû×ßÀý Ä? Ã?ÐÊ
ÅÏÁòØ-ÀÅ ÀÅÄÙ×ßÄé), ÔÔÖÔÐß×á Í××ðÖÔÐßÐÊ UltraSPARC
Ô?ÏÅÌ-ÈÈ Í××ð×â Ì? ÐæÄé.
--enable-nonportable-atomics
È? Ë÷Ïû×ßÈù
APRÐÊ Ê?È? ×ßÅõÏ?Îþ compare-and-swapÐË Ð?×á 486
ÈýÇÙÎþÈ? Ë÷Ïû×áÄé. Ä? ØÏÐÂÐ?ÐÞ atomic ÈýÇÙÐÜ ÀÅÄÙ×ßÑ?ÈÈ,
ÔÔÖÔÐß×á Í××ðÖÔÐßÐÊ 486 ÐÜË? Ô?ÏÅÌ-ÈÈ (386ÐÊ ÎØÅØÄé)
Í××ð×â Ì? ÐæÄé.
ÎÖÖÔÔÅÈ? ÔÔÖÔÐß×âÆ? mod_status
È? Ö?×ä×ßÀý
Í××ð×âÆ? ExtendedStatus On
ÐË ÌÃÑ?×ßÈù ÎÖÖÔÔÅÄÒ
ÏôÓËÐË ÉîÐËÆ?ÈÆÄé gettimeofday(2)
(Ø?ÐÊ ÏþÏÅÓÌÑ?ÏÅ
Å?Æ? times(2)
)È? ÅÞÉ? Ø?Óò×ßÀý (1.3 ÐÜÐ?ÏÅÄÒ)
time(2)
ÅÅ ÓïÀÅÇÞ Ï?Ç?É? Ø?Óò×áÄé. Ë?ÕÒ ÊÈÀýÌ-ÏÅ
ÅÏÐëÍÓÀ?ÐÜ ×ÚÏô×ßÁò Æ?É?ÐÜÄé. ÓæË?Ð× ÌÊÄÙÐË Î?ÐÈÇÑÈù
(ÁòÊËÀ?ÐÞ) ExtendedStatus off
È? ÌÃÑ?×áÄé.
ÎÖÇÅ É?Ì-ÄÒ ÎÖÖÔÔÅ Ð?Ì-É? 2.0 É?Ð?ÏÅÌ- Ê?ÀöÅØ ÃËÏûÐË ÄóÀý ÐæÑ? ÎÚÄé. ÎÖÑ?ÅÅ Ð?ØÏ×á Ñ?ÊÈÀÅ ÐæÑ?ÈÈ, ÑæÐ××èÌ- Ë÷Ïû×ßÁö ÉéÆ?Äé.
Ð?ÄàÍÊ ÌâÔß APIÐ× ÄìÑÅÐË ÌÃÈý×áÄé. Ð?Ì-É?ÀÅ Ï?Ç? Ö?Ö?
Ø?ÐÊ Ï?Ç? ÑæÌâÈ? ÁòÄéÈ?ÁòÐ?×è Ï?Ç? Listen
ÐË Ë÷Ïû×áÄéÀý ÀÅÑ?×ßÐê.
Ï?ÀñÐÜ ÀÅÄÙ×áÑ? À? ÌâÔßÐË ÀÛË÷×ßÁòÐ?×è ÎÖÖÔÔÅÄÒ
select(2)
È? Ë÷Ïû×áÄé. select(2)
ÄÒ
ÌâÔßÏÅ ÁòÄéÈ?Àý ÐæÄÒ Ï?ÀñÐÜ Î?ÄÒÑ? Ø?ÐÊ ÓæÌâ×á
×áÀà ÐæÄÒÑ? ÎÛÇÑÑèÄé. ÎÖÖÔÔÅÏÅÄÒ Ï?Ç? ÐêÍÔÐÜ ÐæÀý,
Í?Àý ÐæÄÒ È?Å÷ ÐêÍÔÐÊ ÅÏÍÓÏÅ Ë?ÇÞÏþ Ï?ÀñÐË ÀÛË÷×áÄé. Ï?ÇÅ
ÁÈ×?ÐÊ ÄéÐÍÀ? ÊåÍÑ×ßÄé (ÐÜ ÏÉÄÒ ÔêÅõÏÅÌ- ÀÅÑ?ÏÐÑ? ÎÚÎâÄé.
ÄìÑ? ÌÃÈý×ßÁòÐ?×á ÏûÅÅÇÞ ÈÈÅùÎ?Äé.):
for (;;) {
for (;;) {
fd_set accept_fds;
FD_ZERO (&accept_fds);
for (i = first_socket; i <= last_socket; ++i) {
FD_SET (i, &accept_fds);
}
rc = select (last_socket+1, &accept_fds, NULL, NULL, NULL);
if (rc < 1) continue;
new_connection = -1;
for (i = first_socket; i <= last_socket; ++i) {
if (FD_ISSET (i, &accept_fds)) {
new_connection = accept (i, NULL, NULL);
if (new_connection != -1) break;
}
}
if (new_connection != -1) break;
}
process the new_connection;
}
ÁçÇ?Ã? Ð?Ð× ÄìÌ?×á ÁÈ×?ÏÅÄÒ ÍÙÀ?×á ÀýÀ?(starvation)
É?Ñ?ÀÅ ÐæÄé. Ï?Ç? ÐêÍÔÐÜ ÅÏÍÓÏÅ ÐÜ ÉíÊÉÉ?ÐË Í××ð×ßÈù,
ÏôÓËÐË ÁòÄéÈ?È÷ È?ÅÞ select
ÏÅÌ- ÈèÓñÄé. ÐÜÆ?
ÎþÆ ÌâÔßÏÅ ÏôÓËÐÜ ×ßÃ?Æ?ÅÅ ÅùÎþÏÐÈù È?Å÷ ÐêÍÔÐÜ Á?ÎþÃ-Äé
(Á?ÎþÃ?ÄÒ ÐêÍÔÐ× ÀÃÌ?ÄÒ ÏþÏÅÓÌÑ?ÏÝ ÕÈÐÜÉæÏÅ Å?Æ? ÄéÈ?Äé).
ÐÜÅùÐÊ È?ÅÞ Ï?ÀñÐË accept
×ßÁö ÍÓÅÅ×áÄé. ÁçÇ?Ã?
(ÎÖÑ?ÅÅ ×á Ï?ÀñÈÈ ÄûÁòÑïÐÜÆ?Èù) ×á ÐêÍÔÈÈ ÌÊÀ?×ßÀý, Ã?ÈãÑ?ÄÒ
accept
ÏÅÌ- ÈèÓñÄé. ÁçÇ?Èù ÐÜ ÐêÍÔÅùÐÊ
×á ÌâÔßÐ× ÏôÓËÈÈÐË Ì-ÊåÍÊ×ßÅÅÇß É-Ï?Ì-, Áç ÌâÔßÐÈÇÞ Ë?ÇÞÏþ
ÏôÓËÐÜ ÓöÊàØ? ÅùÎþÏÝÌ- È?Å÷ ÐêÍÔÐË Á?ÏÿÆ?ÁþÑ? Ñ?Ñ?×èÐæÄé.
ÐÜÇÁ ÀýÀ? É?Ñ?ÄÒ PR#467ÏÅ
ÓÃÐÍ ÊÈÀýÅ×Î?Äé. ÓæÌâ×á ÅÞÀÅÑ? ×èÀñÓ?ÐÜ ÐæÄé.
×áÀÅÑ?ÄÒ ÌâÔßÐË ÄûÁò×ßÑ? ÎÚÅÅÇß (non-blocking) ÈÈÅõÄÒ
ÉöÉÐÜÄé. ÐÜ ÀöÏü ÐêÍÔÐÜ accept
È? ×èÅÅ ÈèÓïÑ?
ÎÚÀý, ÑÿÍÓ Ñ?×ð×â Ì? ÐæÄé. ÁçÇ?Ã? CPU ÍÓÀ?ÐË ÃÆÊå×áÄé.
select
ÏÅÌ- Í?ÄÒ ÐêÍÔÐÜ 10Àà ÐæÀý, Ë?ÇÞ Ï?ÀñÐÜ
×áÀà ÅùÎþÏäÄéÀý ÀÅÑ?×ßÐê. ÁçÇ?Èù ÐÜ ÐêÍÔÑï 9ÀÃÄÒ Á?ÎþÃ?Ì-
Ï?ÀñÐË accept
×ßÁö ÍÓÅÅ×ßÀý Í×Öà×ßÈù ÎÖÉ?
ÐßÅÅ ×ßÑ? ÎÚÀý ÄéÍÓ select
È? ÉíÊÉ×áÄé. ÄéÍÓ
select
ÇÞ ÅÉÎÖÏÓ Æ?ÁþÑ? ÎþÆ ÐêÍÔÅÅ ÄéÈ? ÌâÔßÏÅ
ÅùÎþÏÒ ÏôÓËÐË Ì-ÊåÍÊ×ßÑ? ÎÚÄÒÄé. (ÄéÑï×ÑÇÞÌÌÌ- ÔÔ×ËÕÝÏÅÌ-)
Í?ÄÒ ÐêÍÔ ÀÃÌ?ÈÈÕ- CPU ÀÃÌ?ÀÅ ÐæÄÒ ÅõÉ? ÀöÏüÀÅ ÎÖÄßÆ?Èù
ÐÜ ×èÀñÓ?ÐÊ ÊÀÇÞ ÑÑÎÖÊÈÐÜÑ? ÎÚÄÒÄé.
ÄéÈ? ÉöÉÐÊ ÎÖÖÔÔÅÀÅ Ë÷Ïû×ßÄÒ ÉöÉÐÈÇÞ ÃËÊÞ ÉíÊÉÉ?ÏÅ ×á ÐêÍÔÈÈÐË ÅùÏ?ÊÈÃÍÄé. ÉíÊÉÉ?ÐÊ ÄéÐÍÀ? ÀÀÄé (Ò?ÐÜÈ? À-ÑÆ×ïÐÍ):
for (;;) {
accept_mutex_on ();
for (;;) {
fd_set accept_fds;
FD_ZERO (&accept_fds);
for (i = first_socket; i <= last_socket; ++i) {
FD_SET (i, &accept_fds);
}
rc = select (last_socket+1, &accept_fds, NULL, NULL, NULL);
if (rc < 1) continue;
new_connection = -1;
for (i = first_socket; i <= last_socket; ++i) {
if (FD_ISSET (i, &accept_fds)) {
new_connection = accept (i, NULL, NULL);
if (new_connection != -1) break;
}
}
if (new_connection != -1) break;
}
accept_mutex_off ();
process the new_connection;
}
accept_mutex_on
À? accept_mutex_off
×äÌ?ÄÒ mutex ÌÌÈÆÖ?ÎþÈ?
ÁÈ×?×áÄé. ×áÉ?ÏÅ ÏÐÑ? ×á ÐêÍÔÈÈÐÜ mutexÈ? ÀÅÑ? Ì? ÐæÄé.
mutexÈ? ÁÈ×?×ßÄÒ ÉöÉÐÊ Ï?Ç?ÀÅÑ?ÐÜÄé. ÁÈ×? ÉöÉÐÊ (1.3
ÐÜÐ?) src/conf.h
Ã? (1.3À? Áç ÐÜØÔ)
src/include/ap_config.h
ÏÅ Ñ?Ð×Å×ÐæÄé. ÎþÆÂ
ÎÖÕÀÕèÓÔÄÒ ÐñÁí(locking) ÉöÉÐË ÌÁÕÓ×ßÑ? ÎÚÁòÆ?É?ÏÅ, ÐÜÇÁ
ÎÖÕÀÕèÓÔÏÅÌ- Ï?Ç? Listen
Ñ?ÍÓÎþÈ? Ë÷Ïû×ßÈù
Ð?×ø×ßÄé.
Í××ðÍÓ AcceptMutex
Ñ?ÍÓÎþÈ? Ë÷Ïû×ßÏ?
mutex ÁÈ×?ÐË Ê?Àö×â Ì? ÐæÄé.
AcceptMutex flock
ÐÜ ÉöÉÐÊ ÐñÁíÖÔÐßÐË ÐñÁçÁòÐ?×è flock(2)
ÍÓÍÊÕëØ?ÓòÐË Ë÷Ïû×áÄé (ÐñÁíÖÔÐß Ð?ÔÅÄÒ LockFile
Ñ?ÍÓÎþÇÞ Ñ?Ñ?).
AcceptMutex fcntl
ÐÜ ÉöÉÐÊ ÐñÁíÖÔÐßÐË ÐñÁçÁòÐ?×è fcntl(2)
ÍÓÍÊÕëØ?ÓòÐË Ë÷Ïû×áÄé (ÐñÁíÖÔÐß Ð?ÔÅÄÒ LockFile
Ñ?ÍÓÎþÇÞ Ñ?Ñ?).
AcceptMutex sysvsem
(1.3À? Áç ÐÜØÔ) ÐÜ ÉöÉÐË SysVÍÔ ÌÌÈÆÖ?ÎþÈ? Ë÷Ïû×ßÏ?
mutexÈ? ÁÈ×?×áÄé. Êâ×ðØ?ÅÅ SysVÍÔ ÌÌÈÆÖ?ÎþÄÒ Ã?Ëë
ÊÞÐëÏûÐÜ ÐæÄé. ×ßÃ?ÄÒ ÎÖÖÔÔÅÀÅ ÌÌÈÆÖ?ÎþÈ? Ñ?È?×ßÑ?
ÎÚÀý ÑçÐË Ì? ÐæÄÒ ÑÅÐÜÄé (ipcs(8)
manpage
Ò?Àý). ÄéÈ? ×ßÃ?ÄÒ Ð?Ì-É?ÏÝ ÅÏÐß×á uidÇÞ Í××ð×ßÄÒ
CGIÀÅ (Ñÿ, suexec
Ã?
cgiwrapper
È? Ë÷Ïû×ßÑ?ÎÚÄÒ ×á È?Å÷ CGI)
ÌÌÈÆÖ?Îþ APIÈ? Ë÷Ïû×ßÏ? Ì-ÊåÍÊÀÕÊÞÀ?ÀíÐË ×â Ì? ÐæÄÒ
ÑÅÐÜÄé. ÐÜÇÁ ÐÜÐ?Æ?É?ÏÅ IRIXÈ? Ñ?Ïì×á ÎÖÕÀÕèÓÔÏÅÌ-
ÐÜ ÉöÉÐË Ë÷Ïû×ßÑ? ÎÚÄÒÄé (ÄûÊÞÊàÐ× IRIX ÔÔ×ËÕÝÏÅÌ-
ÎåÐ× ÅÞ ÉöÉÐÊ Ñ?Ã?ÔÅÀä É?ÀÜÄé).
AcceptMutex pthread
(1.3À? Áç ÐÜØÔ) ÐÜ ÉöÉÐÊ POSIX mutexÈ? Ë÷Ïû×ßÁòÆ?É?ÏÅ POSIX ÎÂÇÉÅõ ÁäÎðÐË ÏßÐ?Ø? ÁÈ×?×á ÎÖÕÀÕèÓÔÆ?Èù È?ÅÞ Ë÷ÏûÀÅÄÙ×ßÑ?ÈÈ, (2.5 ÐÜØÔ) SolarisÏÅÌ-ÈÈ ÁçÀÝÅÅ Ö?Ñ? ÁÈÌÊÏÅÌ-ÈÈ ÅÏÐë×ßÄÒ Åý×ßÄé. ÐÜ ÉöÉÐË ÍÓÅÅ×èÊËÄéÈù Ì-É?ÀÅ ÈèÓ÷Ì- ÐÐÄôÐË ÎØ×ßÄÒÑ? ËüÖüÊÑÎï ×áÄé. Ñ?Ð? ÃËÏûÈÈ Ì-ÊåÍÊ×ßÄÒ Ì-É?ÄÒ Ðï ÅÏÐë×ßÄÒ ÀÝ ÀÀÄé.
AcceptMutex posixsem
(2.0À? Áç ÐÜØÔ) ÐÜ ÉöÉÐÊ POSIX ÌÌÈÆÖ?ÎþÈ? Ë÷Ïû×áÄé. mutexÈ? ÀÅÑ? ×ÑÇÞÌÌÍÊÐ× ÎÂÇÉÅõÀÅ ÑçÄÒÄéÈù(segfault) ÌÌÈÆÖ?Îþ ÌâÐ?Á×ÐÜ ØÈÊÉÅ×Ñ? ÎÚÎÖÌ- Ð?Ì-É?ÀÅ ÈèÓñÄé.
ÍÓÍÊÕëÏÅ Ð? ÈåÇßÏÅ Î?ÄÒ Ñ?ÇÔØ-(serialization) ÉöÉÐÜ ÐæÄéÈù Áç ÉöÉÐË Ë÷Ïû×ßÄÒ ÔêÅõÈ? APRÏÅ ÓïÀÅ×â ÀÅÔÅÀÅ ÐæÄé.
ÀýÇÑÄÒ ×èÊÓÑ?ÈÈ ÁÈ×?×ßÑ?ÎÚÐÊ ÄéÈ? ÉöÉÐÊ ÊÞÊàÐ?ÐÈÇÞ ÉíÊÉÉ?ÐË Ñ?ÇÔØ-×ßÄÒ ÉöÉÐÜÄé. Ñÿ, ×ÑÇÞÌÌÌ-È? ÈþÀÃÈÈ ÅùÏ?ÊÈÃËÄÒ ÀÝÐÜÄé. ÐÜ ÉöÉÐÊ Ï?Ç? ÐêÍÔÐË ÅÏÍÓÏÅ Í××ð×â Ì? ÐæÎþÌ- Ñ?ÇÔØ-Æ?É?ÏÅ Ð?ÓÌ ÄûÏ?Ö?ÐË ØÀÏû×ßÑ? È?×ßÄÒ ÄéÑï×ÑÇÞÌÌÌ- ÔÔ×ËÕÝÏÅÌ-ÈÈ À?ÍÙÐË ÀÅÑ?ÊÌ Ì? ÐæÄé. ÎåÐÈÇÞ ËüÖüÊÌ ÊÞÊàÐÜÑ?ÈÈ, ÈÕÏü ÊÄÇÔØ-ÅØ Ð?Ì-É?ÀÅ Ø÷×ßÑ? ÎÚÎÖÌ- ÏüÌÁÌ?Ð?ÀÅ ÃÇÄé.
ÓæË?Ð× ÌÊÄÙÐË Î?ÁòÐ?×èÌ-ÄÒ Ï?Ç? Listen
É?ÐË Ë÷Ïû×ßÑ? ÎÚÄÒ
ÀÝÐÜ ÐÜË?Ð?ÐÜÄé. ÁçÇ?Ã? ÀøÌã ÌÃÈý×áÄé.
ÎåÐ× ÌÃÈýÐÊ ÄéÑïÌâÔß Ì-É?ÏÅÄÒ ÑÑÑ?ÈÈ, ÌâÔßÐÜ ×áÀÃÐÞ
Ì-É?ÄÒ ÎþÆÂÀÅ? Ï?ÀñÐÜ ÅÅÒ?×âÆ?ÁþÑ? È?Å÷ ÐêÍÔÐÜ
accept(2)
ÏÅÌ- ÈèÓ÷ÐæÁòÆ?É?ÏÅ ÐÜÇàË? ÀÀÐÊ
É?Ñ?ÀÅ ÉïË×ßÑ? ÎÚÀý, ÀýÀ? É?Ñ?ÅÅ Î?Äé. ÁçÇ?Ã? Í×Ñ?ÇÞÄÒ
ÎåÏÅÌ- ÈË×á ÄûÁò×ßÑ? ÎÚÄÒ (non-blocking) ÉöÉÏÅÌ- ÉïË×ßÄÒ
"À?ØÈÐ?(spinning)" ×?Ë?ÐË À?ÓïÀý ÐæÄé. ÄûÊÞÊàÐ× TCP ÍÊÕÓÐÊ
Ï?ÀñÐÜ ÅÅÒ?×ßÈù ÔÏÃÞÐÜ accept
ÏÅÌ- ÈèÓ÷ÐæÄÒ
È?Å÷ ÐêÍÔÐË Á?ÏüÅÅÇß ÁÈ×?Å×ÐæÄé. ×ÑÇÞÌÌÍÊÑï ×áÀÃÀÅ Ï?ÀñÐË
Î?Àý Ë÷ÏûÐêÏÅÏ?ÐÈÇÞ ÅÉÎÖÀÅÀý, Ã?ÈãÑ?ÄÒ ÔÏÃÞÏÅÌ- À?ØÈÐ?×ßÏ?
Ï?ÀñÐÜ Î?ÐÍÐË ÉïÀï×ßÈù ÄéÍÓ ÐñÐË ÐìÄé. Ë÷ÏûÐêÏÅÏ? ÔêÅõÏÅÌ-ÄÒ
ÐÜÇÁ À?ØÈÐ?ÐË ÎÛ Ì? Î?Ñ?ÈÈ, ÊàÈýØ? ÑÈÐ÷×áÄé. ÁçÇÅÌ- ÄéÑïÌâÔßÐ×
ÄûÁò×ßÑ? ÎÚÄÒ ÉöÉÀ? ÅÏÐß×ßÀä ÊÞ×ßÈ? Ã?ÐÜÄÒ Êâ×ÚÏô×á ×ðÅÏÐÜ
ÐßÎþÃ-Äé.
ÁçÇÅÌ- ÏüÈ?ÄÒ Ï?Ç? ÎÖÕÀÕèÓÔÏÅÌ- ÌâÔßÐÜ ×áÀÃÐÞ ÀöÏüÏÅÅÅ
Ñ?ÇÔØ-×ßÈù Ä? "Ðï" ÅÏÐë×äÐË ÉïÀï×ïÄé. ÁçÇÅÌ- ÀÕÐ× ÄûÊÞÊàÐ×
ÀöÏü ÁòÊËÐ?ÐÈÇÞ Ñ?ÇÔØ-È? Ë÷Ïû×áÄé. È?Ä?ÍÊÏÅÌ- (ÔÏÃÞ 2.0.30,
128Mb ÈîÈ?È?ÏÅ ÅðÎ? Pentium pro) Í××ø×á ÀñÀ? ÌâÔß ×áÀÃÈ?
Ñ?ÇÔØ-×ßÈù ×ßÑ? ÎÚÐÊ ÀöÏüÏÅ Êå×è ÓÚÄ÷ ÏôÓËÐÜ 3% ÉÜÈÈ
ÑéÎþÅùÎ?Äé. ÁçÇ?Ã? Ñ?ÇÔØ-È? ×ßÑ? ÎÚÐÊ ÀöÏü ÏôÓËÄ÷ 100ms
Ñ?Ï?ÐÜ ÉïË×ïÄé. ÐÜ Ñ?Ï?ÐÊ ÎÖÈÆÅÅ LANÏÅÌ- ÉïË×ßÄÒ Áô
Ï?ÀñÌÁÆ?É?Ðß ÀÝÐÜÄé. ÌâÔßÐÜ ×áÀÃÐÞ ÀöÏü Ñ?ÇÔØ-È? Ë÷Ïû×ßÑ?
ÎÚÐÈÇÑÈù SINGLE_LISTEN_UNSERIALIZED_ACCEPT
È?
Ñ?Ð××áÄé.
draft-ietf-http-connection-00.txt 8ÐÏÅÌ- ÌÃÈý×ßÅýÐÜ ÎØÑ?Ð?ÐÞ Ð?Ì-É?ÀÅ Å×ÇÑÈù, ÕûÍÕÐ× Î÷ Éö×òÐË ÅÆÈÃÐ?ÐÈÇÞ ÄíÐË Ì? ÐæÎþÎï ×áÄé (TCP Ï?ÀñÐÊ ÍæÉö×òÐÜÀý, Éö×òÐÊ Ì-ÇÞ ÅÆÈÃÐ?ÐÜÄé). ÐÜÑÅÐË ÄéÈ? Ì-É?ÏÅÌ-ÄÒ ÐêÑæ À?À?×ßÑ?ÈÈ, ÎÖÖÔÔÅÄÒ 1.2ÊÞÕÝ Ñ?Ø?Ø? ÁÈ×?×èÏäÄé.
ÐÜ ÁòÄÙÐË ÊÞÑæÐ××ßÀä ÎÖÖÔÔÅÏÅ ÓïÀÅ×ïÐËÆ? Ï?Ç? Ð?ÄàÍÊ
É?Ð?ÏÅÌ- ÈÉÐÊ É?Ñ?ÀÅ ÉïË×ïÄé. TCP ÁäÎðÐÊ
FIN_WAIT_2
ÏÅ ÕÈÐãÎÖÏ?ÐÜ ÐæÄéÀý Ñ?×ßÑ? ÎÚÎâÑ?ÈÈ,
ÁíÑ?×ßÑ?ÅÅ ÎÚÎâÄé. ÕÈÐãÎÖÏ?ÐÜ Î?ÄÒ ÍÓÍÊÕëÏÅÌ- ÎÖÖÔÔÅ 1.2ÄÒ
ÈÉÐÊ ÌâÔßÐË ÏÅÏ?Ø? FIN_WAIT_2
Ë?ÕÒÇÞ ÈÈÅùÎ?Äé.
ÈÉÐÊ ÀöÏü ÐÜ É?Ñ?ÄÒ Ñ?ÐëË÷ÀÅ Ñ?À?×ßÄÒ ÓæÍÕ TCP/IP ÖàÔÅÈ?
Ð?Ïû×ßÏ? ×èÀñ×â Ì? ÐæÄé. ÁçÇ?Ã? Ñ?ÐëË÷ÀÅ ÖàÔÅÈ? Éï×?×ßÑ?
ÎÚÄÒ ÀöÏüÀÅ (Ñÿ, SunOS4 -- ÌâÍÊ Æ?ÐÜÌÁÍÊÀÅ ÐæÄÒ
Ë÷Æ?ÐÊ Ñ?Ñ? ÖàÔÅ×â Ì? ÐæÑ?ÈÈ) ÐæÁòÆ?É?ÏÅ ÐÜ ÁòÄÙÐË Ë÷Ïû×ßÑ?
ÎÚÁòÇÞ ÀñÑ?×ïÄé.
ÉöÉÐÊ ÅÞÀÅÑ?Äé. ×ßÃ?ÄÒ ÌâÔß ÏÙÌ× SO_LINGER
È?
Ë÷Ïû×ßÄÒ ÉöÉÐÜÄé. ÁçÇ?Ã? Êâ×ðØ?ÅÅ ÄûÊÞÊàÐ× TCP/IP ÍÊÕÓÐÊ
ÐÜ ÏÙÌ×ÐË ÏÓÉéÇÞ ÁÈ×?×ßÑ? ÎÚÎâÄé. ÏÓÉéÇÞ ÁÈ×?×á ÍÊÕÓÏÅÌ-
ÑÆÒ?ÅÅ (Ñÿ, È?Ä?ÍÊ 2.0.31) ÐÜ ÉöÉÐÊ ÄéÐÍ ÉöÉÊÈÄé
Ä? cpuÈ? ÐòÎÖÈäÄÒÄé.
ÎÖÖÔÔÅÄÒ ÊÈÕû (http_main.c
ÏÅ ÐæÄÒ)
lingering_close
Æ?ÄÒ ×äÌ?È? Ë÷Ïû×áÄé. ÐÜ ×äÌ?ÄÒ
ÄûÓö ÄéÐÍÀ? ÀÀÄé:
void lingering_close (int s)
{
char junk_buffer[2048];
/* shutdown the sending side */
shutdown (s, 1);
signal (SIGALRM, lingering_death);
alarm (30);
for (;;) {
select (s for reading, 2 second timeout);
if (error) break;
if (s is ready for reading) {
if (read (s, junk_buffer, sizeof (junk_buffer)) <= 0) {
break;
}
/* just toss away whatever is here */
}
}
close (s);
}
ÐÜ ÔêÅõÄÒ Ï?ÀñÐË ÄíÐËÆ? Ä? CPUÈ? Ë÷Ïû×ßÑ?ÈÈ, ÎØÑ?Ð?ÐÞ
ÁÈ×?ÐË Ð?×è ×ÚÏô×ßÄé. HTTP/1.1ÐÜ Ä? ÃÞÈ? ÖëÑ?Àý È?Å÷ Ï?ÀñÐË
Ð?Ñ?×áÄéÈù(persistent), Ï?ÀñÐË ÉîÄÒ ÊåÏûÐÊ Ï?Ç? ÏôÓËÐË
ÓÃÈ?×ßÈùÌ- Ë?ÌòÅÙ ÀÝÐÜÄé. Ð?×ø×ßÀäÅÅ
NO_LINGCLOSE
È? Ñ?Ð××ßÏ? ÐÜ ÁòÄÙÐË Ë÷Ïû×ßÑ?
ÎÚÐË Ì? ÐæÑ?ÈÈ, ÐÄûÇÞ Á××ßÑ? ÎÚÄÒÄé. Ö?Ø? HTTP/1.1
ÖÔÐÜ×ÑÆ?ÐÞ (Ï?Ñæ; Ï?ÀñÐ?Ñ? Ë?ÕÒÏÅÌ- ÐÐÄôÐË ÁòÄéÈ?Ñ?
ÎÚÀý Ï?Ç? ÏôÓËÐË ÊÈÃËÄÒ ÁòÌ?) Ï?ÀñÐ?Ñ?ÏÅÄÒ
lingering_close
ÀÅ ×ÚÌ?Ð?ÐÜÄé (ÁçÈ?Àý
ÖÔÐÜ×ÑÆ?ÐÞ Ï?ÀñÐÜ Ä? Ê?È?ÁòÆ?É?ÏÅ Ë÷Ïû×ßÁö ÉéÆ? ÀÝÐÜÄé).
ÎÖÖÔÔÅÐ× ÊÞÈ?ÏÝ ÐêÍÔÐÊ scoreboardÆ?ÄÒ ÀÝÐË Õû×è Ì-ÇÞ
ÕûÍÕ×áÄé. ÐÜË?Ð?ÐÈÇÞÄÒ scoreboardÈ? À?Ð?ÈîÈ?È?ÇÞ ÁÈ×?×èÎï
×áÄé. ÏüÈ? ÀÃÉïÐêÀÅ ×èÄ÷ ÏþÏÅÓÌÑ?ÏÅ Ñ?Áé×â Ì? ÐæÀÕÃ? Ë?ÌÌ×á
Ö?ÖÓ ÀñÀ?È? ÉîÐÊ ÀöÏü ÊÈÕû À?Ð?ÈîÈ?È?È? Ë÷Ïû×ßÏ? ÁÈ×?×áÄé.
Ã?ÈãÑ?ÄÒ Å?ÍÊÕ?ÏÅ ÐæÄÒ ÖÔÐßÐË Ë÷Ïû×ßÏ? ÁÈ×?×áÄé. Å?ÍÊÕ?ÏÅ
ÐæÄÒ ÖÔÐßÐÊ ÄÐÈ?Àý ÍÕÇêÅÅÀÅ ÆÃÎþÑ?Äé (ÁòÄÙÅÅ Ä? Ð?Äé).
src/main/conf.h
ÖÔÐßÏÅÌ- Ë÷Ïû×ßÄÒ ÎÖÕÀÕèÓÔÈ?
Ó?ÎÖÌ- USE_MMAP_SCOREBOARD
Ø?ÐÊ
USE_SHMGET_SCOREBOARD
ÐÞÑ? Ø?ÐÞ×áÄé. ÅáÑï
×ßÃ?È? (À?À? ×ä Ë÷Ïû×â HAVE_MMAP
ÐÜÃ?
HAVE_SHMGET
ÅÅ ÀÀÐÜ) Ñ?Ð××ßÈù À?Ð?ÈîÈ?È? ÔêÅõÈ?
Ë÷Ïû×áÄé. ÍÓÍÊÕëÐÜ ÄéÈ? ÑÎÇ?Ð× À?Ð?ÈîÈ?È?È? Ë÷Ïû×áÄéÈù
src/main/http_main.c
ÖÔÐßÐË Ì?Ñ?×ßÏ? ÎÖÖÔÔÅÏÅÌ-
À?Ð?ÈîÈ?È?È? Ë÷Ïû×â Ì? ÐæÅÅÇß ØÕ(hook)ÐË ÓïÀÅ×ßÆ?. (Æ××á
ÖàÔÅÈ? ÏüÈ?ÏÅÀä ÊÈÃËÑæÁö ÉéÆ?Äé.)
È?ÅòÐË ÅÏÐ?ÐÈÇÞ ÐàÎþÅùÐÜÑ? ÎÚÄÒÄéÈù (ÀÅÄÙ×á ÑÆÁíÐÜÆ?ÅÅ
ÌÊÄÙÐË Ã?ÐÜÁòÐ?×è ÐÜ ÁëÐË ÐàÄÒÄéÈù ÎÖÈÆÅÅ È?ÅòÐË ÅÏÐ?ÐÈÇÞ
ÐàÎþÅùÐÜÑ? ÎÚÐË ÀÝÐÜÄé), Ì-É?È? ÔÔÖÔÐß×âÆ?
-DDYNAMIC_MODULE_LIMIT=0
ÐË ÓïÀÅ×áÄé. ÁçÇ?Èù
È?ÅòÐË ÅÏÐ?ÐÈÇÞ ÐàÎþÅùÐÜÁòÐ?×è ×âÄ÷×ßÄÒ ÈîÈ?È?È? ÐÎð×áÄé.
ÄéÐÍÐÊ Solaris 8ÏÅÌ- worker MPMÐË Ë÷Ïû×á ÎÖÖÔÔÅ 2.0.38Ð× ÍÓÍÊÕëØ?Óò ÁòÇß(trace)ÐÜÄé. ÎÖÇÅ ÈýÇÙÎþÈ? Ë÷Ïû×ßÏ? ÁòÇßÐË Î?Î?Äé:
truss -l -p httpd_child_pid.
-l
ÏÙÌ×ÐË Ë÷Ïû×ßÈù trussÄÒ ÍÓÍÊÕëØ?ÓòÐË
×ßÄÒ LWP (lightweight process, ÀöÇ?Áî ×ÑÇÞÌÌÍÊ--SolarisÐ×
ÔÏÃÞÌ?Ñè ÎÂÇÉÅõ) IDÈ? ÀÀÐÜ ÁòÇß×áÄé.
ÄéÈ? ÍÓÍÊÕëÏÅÄÒ strace
, ktrace
,
par
ÀÀÐÊ ÍÓÍÊÕëØ?Óò ÓïÐ? ÅÅÁÈÀÅ ÐæÄé. ÀñÀ?ÄÒ
ÊåÍÑ×ßÄé.
Õ?Æ?ÐÜÎ?Ö?ÄÒ Ð?Ì-É?ÏÅÀä Õ?ÁòÀÅ 10KBÐÞ Ñ?Ð? ÖÔÐßÐË ÏôÓË×áÄé. Ñ?Ð?ÐÞ ÖÔÐßÐË ÏôÓË×ßÑ? ÎÚÀÕÃ? ÃËÏû×?Ë?×ßÄÒ ÏôÓËÐË ×á ÀöÏü ÁòÇßÐÜ ÈÕÏü ÄéÈ?Äé (Æ?ÇÞÄÒ ÈÕÏü ÎÛÎÖÊÈÁò Ø?ÅùÄé).
/67: accept(3, 0x00200BEC, 0x00200C0C, 1) (sleeping...) /67: accept(3, 0x00200BEC, 0x00200C0C, 1) = 9
Ð?ÏÅÌ- Ï?ÀñÄûÁò(listener) ÎÂÇÉÅõÀÅ LWP #67ÏÅÌ- Í××ðÅÚÐË ÎÛ Ì? ÐæÄé.
accept(2)
Ñ?ÇÔØ-È? Ë÷Ïû×ßÑ? ÎÚÐÍÐË ÑæÈå×ßÆ?.
Ï?Ç? Ö?Ö?È? ÁòÄéÈ?Ñ?ÎÚÄÒ ÀöÏü ÐÜ ×ÓÇÅÖ?Ð× worker MPMÐÊ
ÁòÊËÐ?ÐÈÇÞ Ñ?ÇÔØ-×ßÑ? ÎÚÐÊ acceptÈ? Ë÷Ïû×áÄé./65: lwp_park(0x00000000, 0) = 0 /67: lwp_unpark(65, 1) = 0
Ï?ÀñÐÊ ÉîÎÖÅùÐÜÀý(accept) Ï?ÀñÄûÁò ÎÂÇÉÅõÄÒ worker ÎÂÇÉÅõÈ? Á?Ï?Ì- ÏôÓËÐË ÓÃÈ?×ßÀä ×áÄé. ÎÖÇÅ ÁòÇßÏÅÌ- ÏôÓËÐË ÓÃÈ?×ßÄÒ worker ÎÂÇÉÅõÀÅ LWP #65ÐãÐË ÎÛ Ì? ÐæÄé.
/65: getsockname(9, 0x00200BA4, 0x00200BC4, 1) = 0
ÀÅË?Ø?ÍÊÖ?È? ÁÈ×?×ßÁòÐ?×è ÎÖÖÔÔÅÄÒ Ï?ÀñÐË ÉîÎÖÅùÐÞ
Ñ?Ï?(local) ÌâÔß ÑæÌâÈ? ÎÛÎÖÎï ×áÄé. (ÀÅË?Ø?ÍÊÖ?È? Ë÷Ïû×ßÑ?
ÎÚÀÕÃ? Listen
Ñ?ÍÓÎþÏÅ ÏÝÐßÅõÔ?Åõ ÑæÌâÈ? Ë÷Ïû×ßÑ? ÎÚÐÊ ÀöÏü Åþ) ÈÉÐÊ ÀöÏü
ÐÜ Ø?ÓòÐË Î?Îé Ì? ÐæÄé. ÁçÇ?Ã? ÎÖÑ? ÐÜÇÁ ÓæÐ?Ø- ÐëÎ?ÐÜ
ÎØÅ×ÐæÄé.
/65: brk(0x002170E8) = 0 /65: brk(0x002190E8) = 0
brk(2)
Ø?ÓòÐÊ Ø?(heap)ÏÅÌ- ÈîÈ?È?È? ×âÄ÷×áÄé.
Ð?Ì-É?ÄÒ ÄûÊÞÊàÐ× ÏôÓË ÓÃÈ?ÍÓ ÐêÓÌ ÈîÈ?È?
×âÄ÷Ðê(apr_pool
À? apr_bucket_alloc
)È?
Ë÷Ïû×ßÁòÆ?É?ÏÅ ÍÓÍÊÕëØ?Óò ÁòÇßÏÅÌ- ÐÜ ÍÓÍÊÕëØ?ÓòÐË ÊÈÁòÀÅ
ÅõÉÀÄé. ÐÜ ÁòÇßÏÅÌ- Ð?Ì-É?ÄÒ ÍÓÐë×ßÐêÈÆÐê ÐêÓÌ ÈîÈ?È? ×âÄ÷ÐêÀÅ
Ë÷Ïû×â ÈîÈ?È?ÊýÇßÐË Î?ÁòÐ?×è malloc(3)
ÐË Ø?Óò×áÄé.
/65: fcntl(9, F_GETFL, 0x00000000) = 2 /65: fstat64(9, 0xFAF7B818) = 0 /65: getsockopt(9, 65535, 8192, 0xFAF7B918, 0xFAF7B910, 2190656) = 0 /65: fstat64(9, 0xFAF7B818) = 0 /65: getsockopt(9, 65535, 8192, 0xFAF7B918, 0xFAF7B914, 2190656) = 0 /65: setsockopt(9, 65535, 8192, 0xFAF7B918, 4, 2190656) = 0 /65: fcntl(9, F_SETFL, 0x00000082) = 0
ÄéÐÍ worker ÎÂÇÉÅõÄÒ Õ?Æ?ÐÜÎ?Ö?Ð× Ï?Àñ(ÖÔÐßÁòÌ?Ðê 9)ÐË
ÄûÁòÎØ×ä(non-blocking) Ë?ÕÒÇÞ ÉéÂëÄé. setsockopt(2)
ÏÝ
getsockopt(2)
Ø?ÓòÐÊ SolarisÐ× libcÀÅ ÌâÔßÏÅ
Äû×á fcntl(2)
ÐË ÎþÆËÀä ÓÃÈ?×ßÄÒÑ? ÊÈÏ?ÑèÄé.
/65: read(9, " G E T / 1 0 k . h t m".., 8000) = 97
worker ÎÂÇÉÅõÄÒ Õ?Æ?ÐÜÎ?Ö?ÇÞ ÊÞÕÝ ÏôÓËÐË ÐàÄÒÄé.
/65: stat("/var/httpd/apache/httpd-8999/htdocs/10k.html", 0xFAF7B978) = 0 /65: open("/var/httpd/apache/httpd-8999/htdocs/10k.html", O_RDONLY) = 10
Ð?Ì-É? ÌÃÑ?ÐÊ Options FollowSymLinks
ÏÝ
AllowOverride None
ÐÜÄé. ÁçÇÅÌ- ÏôÓË×á ÖÔÐßÀöÇÞÐ×
À? Å?ÇÊÕôÈ?ÏÅ Äû×è lstat(2)
×ßÀÕÃ?
.htaccess
ÖÔÐßÐË ÀÛË÷×â ×ÚÏôÀÅ Î?Äé. ÖÔÐßÐË
ÀÛË÷×ßÁòÐ?×è, 1) ÖÔÐßÐÜ ÐæÄÒÑ?, 2) Å?ÇÊÕôÈ?ÀÅ ÎÖÄá ÐßÉíÖÔÐßÐÞÑ?,
stat(2)
Ø?ÓòÈÈ ×ßÈù ÅØÄé.
/65: sendfilev(0, 9, 0x00200F90, 2, 0xFAF7B53C) = 10269
ÐÜ ÀöÏü Ð?Ì-É?ÄÒ ×áÉ?Ð× sendfilev(2)
ÍÓÍÊÕëØ?ÓòÇÞ
HTTP ÐÐÄô×üÄ?ÏÝ ÏôÓË×á ÖÔÐßÐË Ð?Ìë×â Ì? ÐæÄé. Sendfile Ñ?Ï?Ï?ÊÞÄÒ
ÏþÏÅÓÌÑ?ÈÆÄé ÄéÈ?Äé. ÄéÈ? ÍÓÍÊÕëÐÜÆ?Èù sendfile(2)
ÐË
Ø?Óò×ßÁò Ð?ÏÅ ×üÄ?È? ÊÈÃËÁòÐ?×è write(2)
Ã?
writev(2)
Ø?ÓòÐË ×áÄé.
/65: write(4, " 1 2 7 . 0 . 0 . 1 - ".., 78) = 78
write(2)
Ø?ÓòÐÊ Ñ?ÁéÇÞÁç(access log)ÏÅ ÏôÓËÐË
ÁòÇß×áÄé. ÐÜ ÁòÇßÏÅ time(2)
Ø?ÓòÐÜ Î?ÐÍÐË ÑæÈå×ßÆ?.
ÎÖÖÔÔÅ 1.3À? ÄîÈ? ÎÖÖÔÔÅ 2.0ÐÊ ÍÓÀ?ÐË ÎÛÁòÐ?×è
gettimeofday(3)
È? Ë÷Ïû×áÄé.
gettimeofday
È? ÓæÐ?Ø-×á È?Ä?ÍÊÏÝ Solaris ÀÀÐÊ
ÈþÈþ ÏþÏÅÓÌÑ?ÏÅÌ-ÄÒ ÐßÉíÐ?ÐÞ ÍÓÍÊÕëØ?Óò ÊÞÄóÐÜ Î?Äé.
/65: shutdown(9, 1, 1) = 0 /65: poll(0xFAF7B980, 1, 2000) = 1 /65: read(9, 0xFAF7BC20, 512) = 0 /65: close(9) = 0
worker ÎÂÇÉÅõÄÒ Ï?ÀñÐË Ñ?Ï?ÄíÁò(lingering close)×áÄé.
/65: close(10) = 0 /65: lwp_park(0x00000000, 0) (sleeping...)
ÈÆÑ?ÈÇÐÈÇÞ worker ÎÂÇÉÅõÄÒ ÉöÁí Ð?Ìë×á ÖÔÐßÐË ÄíÀý, Ï?ÀñÄûÁò(listener) ÎÂÇÉÅõÀÅ ÄéÈ? Ï?ÀñÐË ×âÄ÷×â Æ?ÁþÑ? Ñ?Ñ?×áÄé.
/67: accept(3, 0x001FEB74, 0x001FEB94, 1) (sleeping...)
ÁçÅÏÎØ Ï?ÀñÄûÁò ÎÂÇÉÅõÄÒ Ï?ÀñÐË (È?Å÷ workerÀÅ ÐëÎ?ÑïÐÜÈù
Ï?ÀñÄûÁò ÎÂÇÉÅõÈ? ÈèÓïÄÒ worker MPMÐ× ØõÈ?Ñ?Îþ ÁòÄÙÏÅ Å?Æ?)
worker ÎÂÇÉÅõÏÅ ×âÄ÷×ßÐêÈÆÐê ÄéÈ? Ï?ÀñÐË ÉîÎÖÅùÐß Ì? ÐæÄé.
ÐÜ ÁòÇßÏÅÄÒ Ã?ÏÐÑ? ÎÚÑ?ÈÈ, worker ÎÂÇÉÅõÀÅ ÉöÁí ÉîÐÊ Ï?ÀñÐË
ÓÃÈ?×ßÄÒ ÅÏÎØ ÄéÐÍ accept(2)
ÀÅ (ÏôÓËÐÜ ÈÕÏü
ÈÉÐÊ ÀöÏü ×çË?) ÐßÎþÃ? Ì? ÐæÄé.