最適化

ハッシュテーブル

リクエストの素早い処理を助けるために、NGINXはハッシュテーブルを使います。

During startup and with each reconfiguration, NGINX selects the smallest possible size for the hash tables, taking into account the size of basket, where keys with the coinciding hashed values fall, would not exceed the assigned parameter (hash bucket size).

選択はパラメータ ハッシュの最大サイズをテーブルサイズが超えるまで運用されます。ハッシュの大多数についてディレクティブがあり、それらはこれらのパラメータを変更することができます。例えば、サーバの名前を持つハッシュは server_names_hash_max_sizeserver_names_hash_bucket_size によって制御されます。パラメータのハッシュバケットサイズは常にサイズに等しくされ、プロセッサーキャッシュの行のサイズの倍数になります。This makes it possible to accelerate the search for key in hash on processors, after decreasing the number of turnings to memory. If hash bucket size is equal to the size of one line of processor cache, then during the search for key the number of turnings to memory in the worst case will be equal to two - for the first time for determining the address of basket, and the second - with the search for key inside the basket. Accordingly, if NGINX gave out communication about the need for increasing hash max size or hash bucket size, then it is first necessary to increase the first parameter.

イベントモデル

NGINXは以下の接続を扱うメソッドをサポートします。これは use ディレクティブによって割り当てられることができます。

  • select - 標準のメソッド現在のプラットフォームがもっと効果的なメソッドを持たない場合は、デフォルトでコンパイルされます。設定パラメータ --with-select_module--without-select_moduleを使うことで、このモジュールを有効または無効にすることができます。
  • poll - 標準のメソッド現在のプラットフォームがもっと効果的なメソッドを持たない場合は、デフォルトでコンパイルされます。設定パラメータ --with-poll_module--without-poll_moduleを使うことで、このモジュールを有効または無効にすることができます。
  • kqueue - FreeBSD 4.1+, OpenBSD 2.9+, NetBSD 2.0 および MacOS X で使われる効果的なメソッド。MacOS Xで実行しているデュアルプロセッサを使っているkqueueはカーネルパニックになるかも知れません。
  • epoll - Linux 2.6+で使われる効果的なメソッド。SuSE 8.2のような幾つかのディストリビューションには、カーネル バージョン2.4によってサポートされるepollのためのパッチがあります。
  • rtsig - リアルタイムシグナル。Linux 2.2.19+で使われる実行ファイル。By default no more than 1024 POSIX realtime (queued) signals can be outstanding in the entire system. 高負荷のサーバにとっては非効率です; したがってカーネルパラメータ /proc/sys/kernel/rtsig-maxを使ってキューサイズを増加する必要があります。しかし、Linux 2.6.6-mm2以降は、このパラメータはもう利用できません。そして、各プロセスのために、RLIMIT_SIGPENDINGによって割り当てられるサイズの個別のシグナルのキューがあります。キューが混んでくると、NGINXはそれを無視し、状況が正常になるまでpoll メソッドを使って接続処理を開始します。
  • /dev/poll - Solaris 7 11/99+, HP/UX 11.22+ (eventport), IRIX 6.5.15+ および Tru64 UNIX 5.1A+ で使われる効果的なメソッド。
TOP
inserted by FC2 system