名前

Perlbal::Manual::Internals - Perlbalの構造の一望

バージョン

Perlbal 1.78.

説明

Connections come in from wherever and get to the TCPListener. それはどの種類のClient*をspawnするかを決めるためにServiceオブジェクトを使用します。クライアントのクラスはその後ユーザのための応答を作成します。

                            {{ INTERNET }}
                                  |
                                  v
              [Service]<===>[TCPListener]
                          ___/    |    \___
                         v        v        v
             [ClientManage]  [ClientHTTP] [ClientProxy]
                                                ^
                                                |
                                                v
                                          [BackendHTTP]

Perlbalはリクエストをどのバックエンドに送信するかをランダムに決めます(現在のところ唯一サポートされているメソッドです)。サービスがbackend_persist および connect_aheadで定義される利用可能な空いているバックエンド接続を持つ場合、それらの接続を再利用し、待ち時間を大幅に減らします。詳細は the Perlbal::Manual::LoadBalancer manpage を見てください。

Perlbalはまた遅いクライアントに対して "spoonfeeding" データに特化しています。これにより、バックエンドはPerlbalが応答をクライアントが読み込めるだけ速く戻している間にリクエストに応え続けることができます。

Classes

以下はPerlbalのメインのクラスの短い紹介/概要です。

Perlbal::Socket

the Danga::Socket manpageを継承します。

基本クラスにHTTPソケットを作成するために特別便利ないくつかの機能を追加します。

Fields

headers_string

読み込まれたままのヘッダ。

req_headers

入ってくる最終的なthe Perlbal::HTTPHeaders manpageオブジェクト。

res_headers

出て行く応答ヘッダ (the Perlbal::HTTPHeaders manpage オブジェクト)。

create_time

生成時間。

alive_time

最後にaliveと記された時間。

state

一般的な目的の状態; 継承クラスで使われます。

do_die

onであれば、dieしそれ以上リクエストしません。

read_buf

クライアントから読み込んだscalarrefのArrayref。

read_ahead

read_bufにあるバイト。

read_size

これまでクライアントから読み込んだ総バイト数。

ditch_leading_rn

trueであれば、次のヘッダのパースは先頭の\r\nを無視するでしょう。

observed_ip_string

定義されている場合は、応えているpeerのIP文字列を含みます。これはX-Forwarded-Forの値を保持するためのものであり、ACLを運用するために使われます。

Perlbal::TCPListener

the Perlbal::Socket manpageから継承します。

Very lightweight and fast connection accept class. Takes incoming connections as fast as possible and passes them off, instantiating one of the various Client* classes to handle it.

Fields

service

the Perlbal::Service manpage.

hostport

このサービスが新しい接続を受け取るためにlistenしているIPポートのスカラです。

sslopts

SSLオプション。

    use Data::Dumper;
    warn Dumper( $tcp_listener->{'sslopts'} );

上の行は以下のようなものを出力するでしょう:

    $VAR1 = {
              'ssl' => {
                         'SSL_cipher_list' => '...',
                         'SSL_cert_file' => '...',
                         'SSL_key_file' => ',,,',
                         'SSL_ca_path' => '...',
                         'SSL_verify_mode' => '...'
                       }
            };
v6

booleanはインストールされたPerlbalがIPv6をサポートするかどうかを示します (これは基本的に the Danga::Socket manpage v1.6.1 および the IO::Socket::INET6 manpage が利用可能に落ち着きます)。

Perlbal::BackendHTTP

the Perlbal::Socket manpageから継承します。

このクラスはユーザに返すデータを取得するためにバックエンドのwebノードへの接続を処理します。このクラスは内部のノードへリクエストを送るためにthe Perlbal::ClientProxy manpage のようなほかのクラスによって使われます。

Fields

client

the Perlbal::ClientProxy manpage 接続、あるいは 未定義。

service

the Perlbal::Service manpage.

プール

the Perlbal::Pool manpage; whatever pool we spawned from.

ip

IP scalar.

port

Port scalar.

ipport

$ip:$port.

reportto

オブジェクト; reporter インタフェースを実装していなければなりません。

has_attention

webサーバによって受け付けられ、確実にTCP須宅に話しかけているだけでは無いことを知っています。

waiting_options

trueであれば、いつ注目されるかを決めるために OPTIONS * 応答を待ちます。

disconnect_at

kept-aliveおよびバックエンドが教える場合は、この接続が切断される時間; そうでなく未知であれば undef

content_length

転送されたドキュメントの長さ。バックエンドのサーバがcontent-lengthヘッダを送信した場合にのみ適用されます。

content_length_remain

読み残しているバイト数。バックエンドのサーバがcontent-lengthヘッダを送信した場合にのみ適用されます。

use_count

このバックエンドが使われたリクエストの数。

generation

Int; 何世代spawnしたかの数。

buffered_upload_mode

Boolean. noであれば、バッファされたupload転送をしています。

scratch

特別なストレージ; プラグインは必要であれば使うことができます。

Perlbal::HTTPHeaders

Header management. ヘッダ(リクエストおよび応答)をパースし、更なるユーザのためにデータを保持します。また、HTTPの仕様に従うようにリクエスト行の検証を管理します。

Fields

headers

href; lowercase header -> comma-sep list of values.

origcase

Href; lowercase header -> provided case.

hdorder

Aref; order headers were received (canonical order).

method

Scalar; request method (if GET request).

uri

Scalar; request URI (if GET request).

type

res or req.

code

HTTP 応答ステータスコード。

codetext

応答コードのためのステータス文字列。

ver

バージョン(文字列) "1.1".

vernum

バージョン (番号: major*1000+minor): "1.1" => 1001.

responseLine

(応答の場合は)HTTP応答の最初の行。

requestLine

(リクエストの場合は)HTTPリクエストの最初の行。

Perlbal::ClientHTTPBase

the Perlbal::Socket manpageから継承します。

the Perlbal::ClientHTTP manpage および the Perlbal::ClientProxy manpage へ基本機能を提供します。特に、リモートのユーザにファイルをっ送信する機能があります。Also handles most of the state logic for statistics and such. サービスの種類のselectorとしても使われます。the Perlbal::ClientHTTPBase manpage then reads in the request headers, and asks the service to re-bless the client instance to a more specific type, for either a the Perlbal::ClientProxy manpage or the Perlbal::ClientHTTP manpage (depending on selector's mapping).

Fields

service

the Perlbal::Service manpage オブジェクト。

replacement_uri

リクエストされたURIの代わりに送信されるURI; ディレクトリを提供しようとして失敗する代わりに_serve_requestにインデックスファイルを送信するように教えるために使われます。

scratch

特別なストレージ; プラグインは必要であれば使うことができます。

reproxy_file

バックエンドが私たちに開き始めることを伝えるファイル名。

reproxy_file_size

ファイルのサイズ。かつて stat() したもの。

reproxy_fh

必要であれば、fdのthe IO::Handle manpage

reproxy_file_offset

そのファイルからどれだけ送信したか。

post_sendfile_cb

Subref to run after we're done sendfile'ing the current file.

requests

このオブジェクトがユーザのために実施したリクエストの数。

selector_svc

私たちがやってきた元のサービス。

is_ssl

ソケットがSSLに所属していたかどうか(制限された操作)。

Perlbal::ClientHTTP

the Perlbal::ClientHTTPBase manpageから継承します。

とても単純で軽いクラス。あまりオーバーヘッド無しにユーザへのファイル送信を処理します。ほとんどの機能は親のクラスに含まれており、このクラスは新しいものをあまり実装していません。

Fields

put_in_progress

返すための非同期jobを今待っているのであれば 1。

put_fh

データを書くために使われるファイルハンドル。

put_fh_filename

put_fhのファイル名。

put_pos

次のデータを書くファイルのオフセット。

content_length

転送されたドキュメントの長さ。

content_length_remain

読み残しているバイト数。

chunked_upload_state

Boolean/obj: チャンクされたuploadを処理する場合は、the Perlbal::ChunkedUploadState manpage オブジェクト。そうでなければ未定義。

Perlbal::ClientProxy

the Perlbal::ClientHTTPBase manpageから継承します。

ユーザからやってくる接続を取り、バックエンドノード(Perlbal::BackendHTTP) に接続しリクエストを中継します。バックエンドは、プロキシにreporxyしてディスクからファイルをロードするように言うか、あるいはファイルを直接返すかのどちらかをすることができます。あるいは単にステータスメッセージを返します。

Fields

backend

the Perlbal::BackendHTTP manpage オブジェクト (あるいは切断された場合は undef)。

backend_requested

このリクエストのためのバックエンドをリクエストした場合はtrue。

reconnect_count

バックエンドに再接続しようとした回数。

high_priority

Boolean; 高優先度キューであるか、そうであった場合には 1。

low_priority

Boolean; 低優先度キューであるか、そうであった場合には 1。

reproxy_uris

Arrayref; reproxyするURIを並べたもの。

reproxy_expected_size

Int: reproxyで返ると期待されている応答のサイズ。

currently_reproxying

Arrayref; 現在reproxyしているホストの情報とURI。

content_length_remain

Int: まだ待っているデータの総量。

responded

Bool: ユーザに応答を既に送信したかそうでないか。

last_request_time

Int: 最後にリクエストを受け取った時間。

primary_res_hdrs

If defined, we are doing a transparent reproxy-URI and the headers we get back aren't necessarily the ones we want. Instead, get most headers from the provided res headers object here.

is_buffering

Bool; リクエストのいくつか/全てをメモリ/ディスクにバッファしている場合。

is_writing

Bool; onであれば、現在aio_write を出力しています。

start_time

データをアップロードしている場合のHi-res時間。

bufh

バッファされたアップロードファイルハンドル オブジェクト。

bufilename

String; バッファされたアップロードファイル名。

bureason

String; 定義された場合は、ディスクにバッファしている理由。

buoutpos

Int; バッファされた出力の位置。

backend_stalled

Boolean: あまりに遅いためにバックエンドが読み込みを停止した場合。

unread_data_waiting

Boolean: クライアントから読み込まれるデータがまだあると知っているが読み込みを停止した場合。

chunked_upload_state

Bool/obj: チャンクされたアップロードを処理する場合、the Perlbal::ChunkedUploadState manpage オブジェクト。そうでなければ 未定義。

request_body_length

Integer: リクエストボディの長さ。宣言されたものか、あるいはチャンクされたアップロードが完了した後で計算されたもののどちらか。

last_upload_packet

最後にUDPアップロードパケットを送信したunixtime。perlbalは(xmlhttprequestアップロードバーのための)アップロードの状態に関係したUDPパケットを送信します。

upload_session

クライアントが自己生成したアップロードセッション。perlbalは(xmlhttprequestアップロードバーのための)アップロードの状態に関係したUDPパケットを送信します。

retry_count

500 エラーを受け取ってから今までこのリクエストを再送した回数。

Perlbal::ClientManage

the Perlbal::Socket manpageから継承します。

ユーザがPerlbalの管理インタフェースを使う方法を提供する簡単なインタフェース。webブラウザまたは通常のtelnetを使って(設定ファイルに定義された)管理ポートに接続することができます (詳しくは the Perlbal::Manual::Management manpage を見てください)。

Fields

service

the Perlbal::Service manpage.

buf

読み込みバッファ。

is_http

リクエストがHTTPかどうかのboolean。

ctx

the Perlbal::CommandContext manpage.

Perlbal::Service

サービスはPerlbalが実施している特定の項目です。サービスはどのように動作するかを定義するroleを持つことができます。各サービスは挙動をさらに調整するために一連のパラメータを持つこともできます。サービスのクラスはそれ自身でバックエンドの接続のプールの管理と統計の管理を処理します。

Fields

名前

サービスの名前。

role

role タイプ (web_server, reverse_proxy, など)。

enabled

Boolean; 有効にしているかそうでないか(有効 = listenしている)。

プール

プロキシモードの場合に、ノードを割り当てるために使用しているthe Perlbal::Pool manpage

listener

有効な場合は、the Perlbal::TCPListener manpage オブジェクト。

reproxy_cache

有効な場合は、the Perlbal::Cache manpage オブジェクト。

End-user tunables

listen

新しい接続のためにlistenしているIP:port

docroot

web_server role のための ドキュメントルート。

dirindexing

Boolean; ディレクトリのインデックス(web_server roleのためのもの)。Not async.

index_files

Arrayref of filenames to try for index files.

enable_concatenate_get

Boolean; ユーザが連結されたファイルをリクエストできる場合。

enable_put

Boolean; PUTがサポートされているかどうか。

max_put_size

putファイルの最大サイズのバイト数。

max_chunked_request_size

チャンクされたリクエストの最大バイト数(まず、ディスクに書き込まれます)。

min_put_directory

putのURIの最初に存在する必要があるディレクトリの数。

enable_delete

Boolean; DELETE がサポートされているかどうか。

high_priority_cookie

クライアントリクエストが高優先度と見なされるべきかどうかを調べるクッキーの名前。

high_priority_cookie_contentsも見てください。

high_priority_cookie_contents

前述したクッキーの値はこの文字列を含む必要があります。

backend_persist_cache

クライアントが無い間に保持する永続的なバックエンドの最大数。

persist_client

Boolean; クライアントのための永続的な接続。

persist_backend

Boolean; バックエンドのための永続的な接続。

verify_backend

Boolean; get attention of backend before giving it clients (using OPTIONS).

verify_backend_path

Path to check with the OPTIONS request (default is *).

max_backend_uses

Max requests to send per kept-alive backend (default 0 = unlimited).

connect_ahead

Number of spare backends to connect to in advance all the time.

buffer_size

How much data a the Perlbal::ClientProxy manpage object should buffer from a backend.

buffer_size_reproxy_url

Same as above but for backends that are reproxying for us.

queue_relief_size

Number of outstanding standard priority connections to activate pressure relief at.

queue_relief_chance

Int, 0-100; % chance to take a standard priority request when we're in pressure relief mode.

trusted_upstream_proxies

信頼できるupstreamのネットマスクを含んでいるthe Net::Netmask manpageオブジェクトの配列。

always_trusted

Boolean; trueであれば、常にupstreamを信頼します。

blind_proxy

Boolean; trueであれば、X-Forwarded-For, X-Host, あるいは X-Forwarded-Host ヘッダを修正しません。

enable_reproxy

Boolean; trueであれば、サーバがファイル および/あるいは URL をreporoxyすると通知します。

reproxy_cache_maxsize

キャッシュされるreproxyの結果の最大数。(0は無効で、デフォルトです。)

client_sndbuf_size

SO_SNDBUFのバイト数。

server_process

サーバプロセスへのパス(実行可能ファイル)。

persist_client_idle_timeout

クライアントのkeep-aliveタイムアウトの秒数(デフォルトは30)。

idle_timeout

keep-aliveタイムを除くIdle タイムアウト(デフォルトは30)。

Internal state

waiting_clients

バックエンドのhttp接続を待っているクライアントのarrayref。

waiting_clients_highpri

バックエンドのhttp接続を待っている高優先度のクライアントのarrayref。

waiting_clients_lowpri

バックエンドのhttp接続を待っている低優先度のクライアントのarrayref。

waiting_client_count

バックエンドを待っているクライアントの数。

waiting_client_map

Map of clientproxy fd -> 1 (if they're waiting for a connection).

pending_connects

Hashref of ip:port -> $time (only one pending connect to backend at a time).

pending_connect_count

Number of outstanding backend connects.

bored_backends

既に接続しているが、クライアントがいないバックエンドのarrayref。

hooks

Hashref: hookname => [ [ plugin, ref ], [ plugin, ref ], ... ].

プラグイン

Hashref: name => 1.

plugin_order

Arrayref: name, name, name...

plugin_setters

Hashref: { plugin_name => { key_name => coderef } }.

extra_config

特別な設定オプションを持つhashref; name => values.

spawn_lock

Boolean; if true, we're currently in spawn_backends.

extra_headers

{ insert => [ [ header, value ], ... ], remove => [ header, header, ... ], set => [ [ header, value ], ... ] }.

Used in header management interface.

generation

Int; generation count so we can slough off backends from old pools.

backend_no_spawn

{ "ip:port" => 1 }.

on であれば、spawn_backends はこの ip:port の組み合わせを無視するでしょう。

buffer_backend_connect

0 if off; otherwise, number of bytes to buffer before we ask for a backend.

selector

CODE ref, or undef, for role selector services.

default_service

セレクタがデフォルトとするサービスの名前。

buffer_uploads

Boolean; ディスクシステムへのバッファされたアップロードを有効/無効 にする。

buffer_uploads_path

バッファされたアップロードファイルの格納されているパス。

buffer_upload_threshold_time

Int; buffer uploads estimated to take longer than this.

buffer_upload_threshold_size

Int; これ以上のサイズ(バイト)のアップロードをバッファする。

buffer_upload_threshold_rate

Int; このレート(bytes/sec)より小さなアップロードをバッファアップロードする。

upload_status_listeners

Comma separated list of ip:port of UDP upload status receivers.

upload_status_listeners_sockaddr

sockaddrs (packed ip/port) のarrayref。

enable_ssl

Boolean; クライアントへこのサービスがSSLを話すかどうか。

ssl_key_file

key pemファイルへのパス。

ssl_cert_file

cert pem ファイルへのパス。

ssl_cipher_list

OpenSSL cipher リストの文字列。

ssl_ca_path

証明書のディレクトリへのパス。

ssl_verify_mode

Int; 検証モード。the IO::Socket::SSL manpageを見てください。

enable_error_retries

Boolean; エラーの後でリクエストを再試行しなければならないかどうか。

error_retry_schedule

Comma-separated seconds (full or partial) to delay between retries.

latency

リクエストに追加する遅延時間のミリ秒数。

server_tokens

Boolean; "Server"ヘッダを提供するかどうか。

_stat_requests

このサービスへの総リクエスト。

_stat_cache_hits

reproxy-urlキャッシュを使って提供されるこのサービスへの総リクエスト。

TOP
inserted by FC2 system