PersistentPerl
PersistentPerlとは、Perlを高速化する手法の一つである。主にPerlで書かれたCGIを高速化するために使われているがCGI以外の…
この記事には独自研究が含まれているおそれがあります。 |
PersistentPerlとは、Perlを高速化する手法の一つである。主にPerlで書かれたCGIを高速化するために使われているがCGI以外のシェル等からでも利用できる。
概要
Perlスクリプトは、ユーザーからリクエストがある度に
- Perlプロセスの生成
- Perlスクリプトの文法解釈
- スクリプトのコンパイル
- コンパイルされたバイトコードの実行
- プロセスの破棄
が行われる。大量のリクエストがあればその分だけ繰りかえされ、この事がパフォーマンスの悪化に繋がっている。
PersistentPerlはPerlスクリプトの実行を
- リクエストの受付
- (リクエストを受けられるバックエンドプロセスがいなければ)バックエンドプロセスの生成
- UNIXドメインソケットを使ったバックエンドプロセスとのデータ受け渡し
を行うフロントエンドプロセスと(つまりフロントエンドプロセスはPerlに関わらない)
- 初回のみPerlスクリプトをコンパイルし、バイトコードを保持したままプロセスとして残る
- フロントエンドからのリクエストに従ってコンパイル済みバイトコードを実行
を行うバックエンドプロセスの2つに分けることで2回目以降のスクリプトの文法解釈とコンパイルにかかる時間をカットし結果としてプログラム起動速度の向上およびサーバ負荷の低下が可能となる。
利用方法
CGIとして実行するならばスクリプト冒頭の
#!/usr/bin/perl
などと書かれている部分を
#!/usr/bin/perperl
とするだけで既存のコードはほぼそのまま高速化に寄与できる。
Apacheならmod_persistentperlというモジュールがあり、リクエストの度に行われるフロントエンドプロセスの生成に伴うコストを無くすことが可能である。 ただしmod_persistentperlはworker MPMには非対応である。
関連項目
外部リンク
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.