����ġ ������� - Apache HTTP Server Version 2.4 (original) (raw)
����ġ �������
�� ������ �ֽ��� ������ �ƴմϴ�. �ֱٿ� ����� ������ ���� ������ �����ϼ���.
����ġ 2.0�� ��ɰ� ���ð��ɼ��� ������ ������ �µ��� ������ ���� �������̴�. ��ġ��ũ ����� ��������� �������� �ʾ����� ����ġ 2.0�� ���� ���� ��� ���� ������ ����.
����ġ 1.3�� ���ؼ� 2.0 ������ ó������ Ȯ�强(scalability)�� ���̱����� ���� ����ȭ�� �ߴ�. �⺻������ ��κ� ����ȭ�� ���� ����Ѵ�. ���� �����Ͻ� Ȥ�� ����� ������ ���ɿ� ū ������ �� �� �ִ�. �� ������ ����ġ 2.0�� ������ ����ϱ����� ���� �����ڰ� ������ �� �ִ� �ɼ��� �����Ѵ�. � ���� �ɼ��� �������� �ϵ����� �ü���� ����� �� �� Ȱ���ϵ��� �ϴ� �ݸ�, � �ɼ��� �ӵ��� ���� ����� ����Ѵ�.
����
�ϵ����� �ü���� ���ؼ�
������ ���ɿ� ���� ū ������ �ִ� ���� ��. ������ ��û�� �����ð��� ����ڰ� "����� �����ٰ�" �������� ���ϰ� �ø������ �������� ������ �ϸ� �ȵȴ�. �������� ����ڴ� �����ϰ� �ٽ� �����Ͽ� ���ϰ� ��� �����Ѵ�. [MaxClients](../mod/mpm%5Fcommon.html#maxclients)
���þ �����Ͽ� �������� ������ �� ������ ���� �ڽ��� �������ʵ��� �ؾ� �Ѵ�. ����� �����ϴ�: top
�� ���� �������� ���μ��� ����� ���� ����ġ ���μ����� ��� �� ��뷮�� �˾Ƴ���, ��ü ��밡���� ���� �ٸ� ���μ������� ����� ������ �� ������ ������.
�������� ����ϴ�: ����� ���� CPU, ����� ���� ��Ʈ��ī��, ����� ���� ��ũ, ���⼭ "����� ����"�� ������ �ؼ� �����ؾ� �Ѵ�.
�ü���� ���� ���� �˾Ƽ� ������ ���̴�. ���� �Ϲ������� �����ϴٰ� �Ǹ��� ��� ��ħ�� �ִ�:
- ������ �ü���� �ֽ� ���� ������ ��ġ�� �����Ѵ�. ���� �ü�� ���ۻ�� �ֱ� TCP ���ð� ������ ���̺귯���� ���� �ӵ������ �ߴ�.
- �ü����
sendfile(2)
�ý���ȣ���� �����Ѵٸ�, �̸� ����ϱ����� �����̳� ��ġ�� ��ġ�Ͽ����� Ȯ���Ѵ�. (���� ���, ��������� 2.4 �̻� ������ ���Ѵ�. Solaris 8 �ʱ� ������ ��ġ�� �ʿ��ϴ�.) �����ϴ� �ý����̶�� ����ġ 2��sendfile
�� ����Ͽ� CPU�� �� ����ϸ� ���� ������ �� ���� ������ �� �մ�.
����� ������ ���ؼ�
HostnameLookups�� DNS�� ���� ������ ����
����ġ 1.3 ������ [HostnameLookups](../mod/core.html#hostnamelookups)
�� �⺻����On
�̿���. ��û�� ��ġ������ DNS �˻��� ������ �ϹǷ� ��û���� ������ �����. ����ġ 1.3���� �� ������ �⺻���� Off
�� ����Ǿ���. �α������� �ּҸ� ȣ��Ʈ������ ��ȯ�Ϸ��� ���� �α�ó�� ���α��� �ϳ���, ����ġ�� ���Ե� logresolve ���α��� ����϶�.
�α�ó�� �۾��� ���� ���ɿ� �ǿ����� ��ġ�Ƿ� ���� ����ϴ� �������� �ƴ� �ٸ� ��ǻ�Ϳ��� �α������� ��ó���ϱ� �ٶ���.
`[Allow](../mod/mod%5Faccess.html#allow)` from domain
�̳� `[Deny](../mod/mod%5Faccess.html#deny)` from domain
���þ ����Ѵٸ� (��, IP �ּҰ� �ƴ� ȣ��Ʈ���̳� �����θ��� ����Ѵٸ�) �ε��� �ߺ�-�� DNS �˻��� (���˻��� ���� ���Ƿ� ����Ǿ����� Ȯ���ϱ����� �ٽ� �˻�) �ؾ� �Ѵ�. ���Ƿ� ������ ���̱����� �̷� ���þ�� �����ϸ� �̸���� IP �ּҸ� ����Ѵ�.
<Location /server-status>
���� ������ ���þ��� ��������� ������ �� ������ ����϶�. �� ��� ���ǿ� �´� ��û���� DNS ��ȸ�� �Ѵ�. ������.html
�� .cgi
���ϸ� DNS �˻��� �ϴ� ������:
HostnameLookups off <Files ~ "\.(html|cgi)$"> HostnameLookups on </Files>
���� CGI���� DNS���� �ʿ��� ���̶��, �ʿ��� Ư�� CGI������ gethostbyname
ȣ���� �ϵ��� �����غ� �� �ִ�.
FollowSymLinks�� SymLinksIfOwnerMatch
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
����� ij������ �ʱ���� ��û�� ���� ������ �Ź� ���� �۾��� �Ѵ�. ��¥ �ɺ���ũ ���� �˻縦 ���Ѵٸ� ������ ���� �� �� �ִ�:
` DocumentRoot /www/htdocs
Options FollowSymLinks
<Directory /www/htdocs>
Options -FollowSymLinks +SymLinksIfOwnerMatch
`
�� ��� �ּ��� [DocumentRoot](../mod/core.html#documentroot)
��δ� �˻����� �ʴ´�. DocumentRoot �ۿ� �ִ� ��η� [Alias](../mod/mod%5Falias.html#alias)
�� [RewriteRule](../mod/mod%5Frewrite.html#rewriterule)
�� ����� ��쿡�� ���� ����� ������ �ʿ��ϴ�. �ɺ���ũ ������ �������� �ʰ� �ְ��� ������ ��������,FollowSymLinks
�� �����ϰ�,SymLinksIfOwnerMatch
�� ����� �ȵȴ�.
AllowOverride
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
������ ����� ����� �������� ������ �����϶�.
���� (memory-mapping)
���� ���, server-side-include�� ó���ϴ� �� ����ġ 2.0�� ������ ������ ������ �ü���� mmap(2)
���� �����Ѵٸ� ������ �����Ѵ�.
���� �÷������� ������ ������ ����Ѵ�. ���� ������ ������ ������ ����Ʈ���� ������ �������� ��ġ�� ��찡 �ִ�:
- � �ü������
mmap
�� CPU ������ ��������read(2)
��ŭ Ȯ�强�� ���� �ʴ�. ���� ���, �������μ��� Solaris �������� ����ġ 2.0�� ����mmap
�� ������� ������ ������ ó���� ������ �� ���� �����Ѵ�. - NFS ����Ʈ�� ���Ͻý��ۿ� �ִ� ������ �����ϴ� ���߿� �ٸ� NFS Ŭ���̾�Ʈ�� �ִ� ���μ����� ������ ����ų� ����ũ�⸦ ���̸�, ������ ���μ����� ���� ���� ������ ���ϳ����� ������ bus error�� ���� �� �ִ�.
���� ���ǿ� �ش��ϸ� �����ϴ� ������ �������� �ʵ��� EnableMMAP off
�� ����ؾ� �Ѵ�. (����: �� ���þ�� ���丮���� ������ �� �ִ�.)
Sendfile
����ġ�� �ü���� sendfile(2)
�� �����ϸ� Ŀ�� sendfile�� ����Ͽ� -- ���� ���, ���� ������ �����Ҷ� -- ������ ������ ���� �������� �� �ִ�.
���� �÷������� sendfile�� ����ϸ� read�� send�� ���� �� �ʿ䰡 ��� ��������. ���� sendfile�� ����ϸ� �������� �������� ��ġ�ԵǴ� ��찡 �ִ�:
- sendfile ������ �߸��Ǿ��� ������ �ý����� ������ �߰����� ���ϴ� �÷����� �ִ�. Ư�� �ٸ� ��ǻ�Ϳ��� ���������� �������Ͽ� sendfile ������ �߸��� ��ǻ�ͷ� ������ ��쿡 �����ϴ�.
- Ŀ���� �ڽ��� ij���� ����Ͽ� NFS�� ����Ʈ�� ������ ���������� ������ �� ���� ��찡 �ִ�.
���� ���ǿ� �ش��ϸ� ������ sendfile �������� �ʵ���EnableSendfile off
�� ����ؾ� �Ѵ�. (����: �� ���þ�� ���丮���� ������ �� �ִ�.)
����� ����
����ġ 1.3 �������� [MinSpareServers](../mod/prefork.html#minspareservers)
, [MaxSpareServers](../mod/prefork.html#maxspareservers)
, [StartServers](../mod/mpm%5Fcommon.html#startservers)
������ ��� ��ġ��ũ ����� ū ������ ���ƴ�. Ư�� ����ġ�� �۾��� �����ϱ����� ����� �ڽļ��� �ٴٸ� ������ "����" �Ⱓ�� �ʿ��ߴ�. ó�� [StartServers](../mod/mpm%5Fcommon.html#startservers)
�� �ڽ��� ������, [MinSpareServers](../mod/prefork.html#minspareservers)
���������� �ʴ� �ڽ��� �ϳ��� �������. ���� [StartServers](../mod/mpm%5Fcommon.html#startservers)
�⺻����5
�� ������ Ŭ���̾�Ʈ 100���� ���ÿ� �����ϸ� ���ϸ� ó���ϱ ����� �ڽ��� �������� 95�ʰ� �ɷȴ�. ���� ��������� �ʴ� ���� ���������� �� ����������, 10�а��� �����ϴ� ��ġ��ũ ����� �ſ� ���ڰ� ���´�.
�ʴ� �Ѱ� ��Ģ�� �ڽ��� ���� �����ϸ鼭 ������ ������ ���� �������� ���ߴ�. ��ǻ�Ͱ� �ڽ��� �����ϴ��� �ٻڸ� ��û�� ������ �� ����. ���� �� ��Ģ�� ����ġ�� ü�� ���ɿ� �ǿ����� �־� �����Ͽ���. ����ġ 1.3���� �ʴ� �Ѱ� ��Ģ�� ��ȭ�Ǿ���. �ڵ�� �ڽ� �Ѱ��� �����, 1�� ����, �ΰ��� �����, 1�� ����, �װ��� �����, �̷� ������ �ʴ� �ڽ��� 32�� ���鶧���� ������ �����Ѵ�. �ڽļ��� [MinSpareServers](../mod/prefork.html#minspareservers)
������ �ٴٸ��� ������ �ߴ��Ѵ�.
�� ��� �����ӵ��� �������� [MinSpareServers](../mod/prefork.html#minspareservers)
, [MaxSpareServers](../mod/prefork.html#maxspareservers)
, [StartServers](../mod/mpm%5Fcommon.html#startservers)
�� ���� ������ �ʿ䰡 ����. ���ʿ� �ڽ��� 4�� �̻� �����ϸ� [ErrorLog](../mod/core.html#errorlog)
�� ����Ѵ�. �̷� �������� ���� ���̸� �� �������� �����ϱ� �ٶ���.[mod_status](../mod/mod%5Fstatus.html)
����� ������ �� ���̴�.
���μ��� ������ �����Ͽ� [MaxRequestsPerChild](../mod/mpm%5Fcommon.html#maxrequestsperchild)
������ ���μ����� �����Ѵ�. �⺻���� �ڽĴ� ó���� ��û���� ������ ���ٴ� 0
�̴�. ���� ������ 30
�� ���� �ſ� ���� ������ �������ִٸ�, ���� ����� ���� �ʿ䰡 �ִ�. SunOS�� ������ Solaris ������ ����Ѵٸ�, ��������� �� ���� 10000
������ �����϶�.
��������(keep-alive)�� ����Ѵٸ� �ڽĵ��� �̹� ���� ���ῡ�� �߰� ��û�� ��ٸ��� �ƹ��͵� �����ʱ���� ��� �ٻڴ�. [KeepAliveTimeout](../mod/core.html#keepalivetimeout)
�� �⺻�� 15
�ʴ� �̷� ������ �ּ�ȭ�Ѵ�. ��Ʈ�� �뿪���� ���� �ڿ� ���� ������ �°� �����Ѵ�. ���������� ��κ��� ������ ���������� � ��쿡�� �� ���� 60
�� �̻����� �ø��� ����.
�����Ͻ� ������ ���ؼ�
MPM ����
����ġ 2.x�� ����ó����� (MPMs)�̶�� ��ü�� �� �ִ� ����ȭ ���� �����Ѵ�. ����ġ�� �������Ҷ� MPM�� �����ؾ� �Ѵ�. [beos](../mod/beos.html)
,[mpm_netware](../mod/mpm%5Fnetware.html)
, [mpmt_os2](../mod/mpmt%5Fos2.html)
,[mpm_winnt](../mod/mpm%5Fwinnt.html)
�� ���� Ư�� �÷��������� ����� �� �ִ� MPM�� �ִ�. �Ϲ����� ���н��� �ý����� ���� MPM �߿� �ϳ��� ������ �� �ִ�. �������� �ӵ��� Ȯ�强(scalability)�� � MPM�� �����߳Ŀ� �ȴ�:
[worker](../mod/worker.html)
MPM�� ���� �ڽ� ���μ����� ���� ���� �����带 ����Ѵ�. �� ������� �ѹ��� �� ������ ����Ѵ�. �Ϲ������� worker�� prefork MPM ���� ���� �� ����ϹǷ� ��ŷ��� ���� ������ �����ϴ�.[prefork](../mod/prefork.html)
MPM�� �����尡 �Ѱ��� �ڽ� ���μ����� ������ ����Ѵ�. �� ���μ����� �ѹ��� �� ������ ����Ѵ�. ���� �ý��ۿ��� prefork�� �ӵ��� worker�� ���������, �� ���� �� ����Ѵ�. ������ ���� ��Ȳ���� �����带 ������� �ʴ� prefork ����� worker�� ���� ������ ������: �����忡 �������� (thread-safe) ���� �����ڰ� ���� ����� ����� �� �ְ�, ������ ����� ������ ����� �÷������� ���� ������� �� �ִ�.
�� MPM��� �ٸ� MPM�� ���� �� �ڼ��� ������ MPM ������ �����ϱ� �ٶ���.
���
�� ��뷮�� ���ɿ��� ���� �߿��� �����̱���� ������ ������� �ʴ� ����� �����غ���. ����� DSO�� �������ߴٸ� ������ �� �� ���� [LoadModule](../mod/mod%5Fso.html#loadmodule)
���þ �ּ�ó���ϸ� �ȴ�. ���� ����� �����ϰ� �����Ͽ� ����Ʈ�� �����̵� ���������� �����ϴ��� ���캼 �� �ִ�.
�ݴ�� ����� ����ġ �������Ͽ� �������� ��ũ���ִٸ� ������ �ʴ� ����� �����ϱ����� ����ġ�� ���������ؾ� �Ѵ�.
���⼭ �翬�� � ����� ����ϰ� ������� ���� �ǹ��� �����. ������ ������Ʈ���� �ٸ���. ���� �Ƹ����ּ��� [mod_mime](../mod/mod%5Fmime.html)
,[mod_dir](../mod/mod%5Fdir.html)
, [mod_log_config](../mod/mod%5Flog%5Fconfig.html)
����� ����� ���̴�. ���� ������Ʈ�� �α������� �ʿ���ٸ�mod_log_config
�� ��� �ȴ�. ���� ��õ���� �ʴ´�.
Atomic ����
[mod_cache](../mod/mod%5Fcache.html)
���� ���� �ֱ� �������� 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
�ɼ��� ������ ���� �÷����� ������ �ִ�:
- SPARC���� Solaris
�⺻������ APR�� Solaris/SPARC���� mutex��� atomic�� ����Ѵ�. ���� �����Ҷ�--enable-nonportable-atomics
�� ����ϸ� APR�� ���� �ϵ���� compare-and-swap�� ���� SPARC v8plus ���ɾ ����Ѵ�. �� �ɼ��� ����ϸ� atomic ������ �� ȿ���������� (CPU�� �� ����ϰ� �� ���� ����ȭ�� �����ϴ�), �������� ���������� UltraSPARC Ĩ������ ������ �� �ִ�. - Linux on x86
�⺻������ APR�� ���������� mutex��� atomic�� ����Ѵ�. ���� �����Ҷ�--enable-nonportable-atomics
�� ����ϸ� APR�� ���� �ϵ���� compare-and-swap�� ���� 486 ���ɾ ����Ѵ�. �� ȿ������ atomic ������ ����������, �������� ���������� 486 �̻� Ĩ������ (386�� �ȵȴ�) ������ �� �ִ�.
mod_status�� ExtendedStatus On
����ġ�� �������Ҷ� [mod_status](../mod/mod%5Fstatus.html)
�� �����ϰ� �����Ҷ� ExtendedStatus On
�� �����ϸ� ����ġ�� ��û�� ���������� gettimeofday(2)
(Ȥ�� �ü���� ���� times(2)
)�� �ι� ȣ���ϰ� (1.3 ��������)time(2)
�� �߰��� ������ ȣ���Ѵ�. ���� �������� ���۽ð��� �ʿ��ϱ� �����̴�. �ֻ��� ������ �������� (�⺻����) ExtendedStatus off
�� �����Ѵ�.
accept ����ȭ - ���� ����
����:
�Ʒ� ������ ����ġ ������ 2.0 �������� ����� ������ ��� ���� �ʴ�. ������ ��ȿ�� ������ ������, �����ؼ� ����ϱ� �ٶ���.
���н� ���� API�� ������ �����Ѵ�. �������� ���� ��Ʈ Ȥ�� ���� �ּҸ� ��ٸ������� ���� [Listen](../mod/mpm%5Fcommon.html#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](../mod/mpm%5Fcommon.html#listen)
���þ ����ϸ� �����ϴ�.
����� [AcceptMutex](../mod/mpm%5Fcommon.html#acceptmutex)
���þ ����Ͽ� mutex ������ ������ �� �ִ�.
AcceptMutex flock
�� ����� ��������� ��ױ����� flock(2)
�ý���ȣ���� ����Ѵ� (������� ��ġ�� [LockFile](../mod/mpm%5Fcommon.html#lockfile)
���þ�� ����).
AcceptMutex fcntl
�� ����� ��������� ��ױ����� fcntl(2)
�ý���ȣ���� ����Ѵ� (������� ��ġ�� [LockFile](../mod/mpm%5Fcommon.html#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](../mod/mpm%5Fcommon.html#listen)
���� ������� �ʴ� ���� �̻����̴�. ���� ��� �����Ѵ�.
accept ����ȭ - ���� �Ѱ�
���� ������ ������ �������� ������, ������ �Ѱ��� ������ ���? ������ �����Ҷ����� ��� �ڽ���accept(2)
���� �����ֱ���� �̷л� ���� ������ ������ �ʰ�, ���� ������ ����. ���� �����δ� �տ��� ���� ������� �ʴ� (non-blocking) ������� ���ϴ� "��ȸ��(spinning)" ������ ���߰� �ִ�. ��κ��� TCP ������ ������ �����ϸ� Ŀ���� accept
���� �����ִ� ��� �ڽ��� ���쵵�� �������ִ�. ���μ����� �Ѱ��� ������ ��� ����ڿ������� ���ư���, �������� Ŀ�ο��� ��ȸ���Ͽ� ������ ������ �߰��ϸ� �ٽ� ���� �ܴ�. ����ڿ��� �ڵ忡���� �̷� ��ȸ���� �� �� ������, �и��� �����Ѵ�. ���� �������� ������� �ʴ� ����� �����ϰ� ���ϸ� ���̴� ���ʿ��� �ൿ�� �Ͼ��.
���� �츮�� ���� ��Ű���Ŀ��� ������ �Ѱ��� ��쿡�� ����ȭ�ϸ� �� "��" �������� �߰��ߴ�. ���� ���� ��κ��� ��� �⺻������ ����ȭ�� ����Ѵ�. ���������� (Ŀ�� 2.0.30, 128Mb �� ��� Pentium pro) ������ ��� ���� �Ѱ��� ����ȭ�ϸ� ���� ���� ��쿡 ���� �ʴ� ��û�� 3% �̸� �پ�����. ���� ����ȭ�� ���� ���� ��� ��û�� 100ms ������ ���ߴ�. �� ������ �Ƹ��� LAN���� ���ϴ� �� ���ἱ������ ���̴�. ������ �Ѱ��� ��� ����ȭ�� ������� �������� SINGLE_LISTEN_UNSERIALIZED_ACCEPT
�� �����Ѵ�.
Close ����(lingering)
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��� ���� ���� ���� ����Ѵ�. �̻������δ� scoreboard�� ������ �����ؾ� �Ѵ�. �츮 �����ڰ� �ش� �ü���� ������ �� �ְų� ���� ���� ����� ���� ��� ���� ������ ����Ͽ� �����Ѵ�. �������� ��ũ�� �ִ� ������ ����Ͽ� �����Ѵ�. ��ũ�� �ִ� ������ ������ �ŷڵ��� �������� (��ɵ� �� ����).src/main/conf.h
���Ͽ��� ����ϴ� ��Ű���ĸ� ã�Ƽ� USE_MMAP_SCOREBOARD
Ȥ��USE_SHMGET_SCOREBOARD
���� Ȯ���Ѵ�. ���� �ϳ��� (���� �Բ� ����� HAVE_MMAP
�̳�HAVE_SHMGET
�� ����) �����ϸ� ������ �ڵ带 ����Ѵ�. �ý����� �ٸ� ������ ������ ����Ѵٸ�src/main/http_main.c
������ �����Ͽ� ����ġ���� ������ ����� �� �ֵ��� ��(hook)�� �߰��϶�. (���� ��ġ�� �츮���� �����ֱ� �ٶ���.)
������ ����: ����ġ�� ������ ������ ����ġ 1.2 �������� ������ ����ϱ� �����ߴ�. ���������� �ʱ� ����ġ ������ ������ �ŷڵ��� �������� �����̴�.
DYNAMIC_MODULE_LIMIT
����� �������� �о������ �ʴ´ٸ� (������ �����̶� ������ ���̱����� �� ���� �д´ٸ� �Ƹ��� ����� �������� �о������ ���� ���̴�), ������ �������Ҷ�-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](../mod/mpm%5Fcommon.html#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)
�� (��û�� �ſ� ���� ��� ��) �Ͼ �� �ִ�.