For faster navigation, this Iframe is preloading the Wikiwand page for FastCGI.

FastCGI

FastCGIとは、Webサーバ上でユーザプログラムを動作させるためのインタフェース仕様の一つである。CGIの問題を解決するためにOpen Market(英語: Open Market社によって1990年代中頃に開発された[1]もので、仕様は公開されている。

概要(従来のCGIの問題点)

[編集]

CGIは、外部アプリケーションをWebサーバに接続するためのプロトコルである。CGIアプリケーションは個別のプロセスで実行され、各リクエストの開始時に作成され、終了時に破棄される。この「リクエスト毎に1つの新しいプロセス」モデルにより、CGIプログラムの実装が非常に簡単になるが、効率とスケーラビリティが制限される。高負荷では、プロセスの作成と破棄のためのオペレーティングシステムオーバーヘッドが大きくなる。また、CGIプロセスモデルは、データベース接続の再利用、インメモリキャッシング等のリソース再利用方法を制限する。

歴史

[編集]

CGIのスケーラビリティの欠点に対処するために、Open Market はFastCGI を開発し、1990年代中頃に最初にWebサーバ製品に導入した。Open Market は当初、Webアプリケーションを開発するためのNetscape独自のインプロセスAPI(Netscapeサーバアプリケーションプログラミングインターフェイス英語版(NSAPI))に対する競争力のある対応としてFastCGIを開発した。 最初はOpen Market によって開発されたが、FastCGI は他のいくつかのWebサーバメーカーによって実装された。ただし、そのアプローチは、サーバとサブプログラム間の通信を高速化および簡素化する他の方法と競合した。mod_perl英語版mod_php英語版等のApache HTTP Serverモジュールがほぼ同時期に登場し、急速に普及した。2019年現在、CGIを含むこれら様々な方法は引き続き使用されている。

詳細

[編集]

リクエスト毎に新しいプロセスを作成する代わりに、FastCGI は永続的なプロセスを使用して一連のリクエストを処理する。これらのプロセスは、WebサーバではなくFastCGI サーバが所有している[2]

受信リクエストを処理するために、Webサーバ環境変数情報とページリクエストを、UNIXドメインソケット名前付きパイプ、または伝送制御プロトコル(TCP)接続のいずれかを介してFastCGI プロセスに送信する。応答は同じ接続を介してプロセスからWebサーバに返され、Webサーバはその応答をエンドユーザに配信する。応答の最後に接続が閉じられる可能性があるが、WebサーバとFastCGI サービスプロセスの両方が存続する[3]

個々のFastCGI プロセスは、その存続期間中に多くの要求を処理できるため、要求毎のプロセスの作成と終了のオーバーヘッドを回避できる。複数の要求を同時に処理するには、いくつかの方法がある。1つの接続を内部多重化(つまり、1つの接続で複数の要求)を使用して行う、複数の接続を使用する、またはこれらの方法の組み合わせによる方法がある。複数のFastCGI サーバを構成できるため、安定性とスケーラビリティが向上する。

Webサイトの管理者とプログラマは、FastCGI でWebサーバからWebアプリケーションを分離すると、組み込みインタプリタ(mod_perl英語版mod_php英語版等)に比べて多くの利点がある。この分離により、サーバプロセスとアプリケーションプロセスを個別に再起動できる。これは、多忙なWebサイトにとって重要な考慮事項である。また、ISPやWebホスティング会社にとって重要な要件である、アプリケーションごとのホスティングサービスセキュリティポリシーの実装も可能になる[4]。様々なタイプの着信要求を、それらのタイプの要求を効率的に処理するように装備されている特定のFastCGI サーバに配布できる。

FastCGI を実装するWebサーバ

[編集]

参考: Webサーバソフトウェアの比較#機能英語版

注: 特に明記しない限り、FastCGI 実装の完全性は不明

API言語バインディング

[編集]

FastCGI は、ネットワークソケットをサポートする任意の言語で実装できる。「FastCGI はプロトコルであり、実装ではない」ため、1つの言語に強く拘束されていない。アプリケーションプログラミングインターフェイス(API)は、次のものに対して存在する[18]:

Ruby on Rails, Catalyst, Django, Kepler英語版Plack英語版等の最近のフレームワークでは、組み込みインタープリタ(mod_ruby英語版, mod_perl英語版, mod_python, mod_lua英語版等)、またはFastCGI を使用できる。

FastCGI が適用できない言語の一つはシェルスクリプトである。一部のシェルの実装では POSIX では規定されてない拡張機能として最低限のネットワークソケットをサポートしてはいるが、言語上の制限が大きく実装が困難なため API 言語バインディングが存在しない。また FastCGI は新しいプロセスを作成しないことで要求毎のオーバーヘッドを回避するのが目的であるが、シェルスクリプトでは多数の外部コマンドを呼び出すことで処理を行うプロセスを多数作成するプログラミングスタイルとなるため、たとえ FastCGI が使えたとしても要求毎のプロセス生成をたかだか 1 つ減らせる程度となり FastCGI のオーバーヘッドの回避の効果は限りなくゼロに近い。

脚注

[編集]

出典

[編集]
  1. ^ About FastCGI”. Open Market, Rob Saccoccio & others. 2012年2月20日閲覧。
  2. ^ FastCGI Specification | FastCGI”. 2020年4月20日閲覧。
  3. ^ FastCGI: A High-Performance Web Server Interface | FastCGI”. 2020年4月20日閲覧。
  4. ^ FastCGI: Persistent Applications for Your Web Server | Linux Journal”. 2020年4月20日閲覧。
  5. ^ a b mod_fcgid - FastCGI interface module for Apache 2 - The Apache HTTP Server Project”. 2020年4月21日閲覧。
  6. ^ #450748 - libapache2-mod-fcgid: Please add support for TCP/IP FastCGI servers - Debian Bug report logs”. 2020年4月21日閲覧。
  7. ^ Issues with Apache 2.4 and PHP-FPM / Daniel He”. 2020年4月21日閲覧。
  8. ^ GitHub - ByteInternet/libapache-mod-fastcgi: libapache-mod-fastcgi”. 2020年4月21日閲覧。
  9. ^ FastCGI -- The Forgotten Treasure”. 2020年4月21日閲覧。
  10. ^ mod_proxy_fcgi - Apache HTTP Server Version 2.4”. 2020年4月21日閲覧。
  11. ^ http.fastcgi - Caddy User Guide”. 2020年4月21日閲覧。
  12. ^ Cherokee Web Server | Handler FastCGI | Cherokee Documentation”. 2020年4月21日閲覧。
  13. ^ HOWTO: Using CGI and FastCGI - Hiawatha webserver”. 2020年4月21日閲覧。
  14. ^ a b Chapter 17. FastCGI Support”. 2020年4月21日閲覧。
  15. ^ Docs ModFastCGI - Lighttpd - lighty labs”. 2020年4月21日閲覧。
  16. ^ FastCGI for IIS : The Official Microsoft IIS Site”. 2020年4月21日閲覧。
  17. ^ httpd(8) - OpenBSD manual pages”. 2020年4月21日閲覧。
  18. ^ FastCGI.com Archives”. 2020年4月21日閲覧。
  19. ^ Matreshka”. 2020年4月21日閲覧。
  20. ^ GitHub - farshadmohajeri/extpascal: Automatically exported from code.google.com/p/extpascal”. 2020年4月21日閲覧。
  21. ^ CLiki: FastCGI”. 2020年4月21日閲覧。
  22. ^ goanna - Revision 630: /trunk/goanna”. 2020年4月21日閲覧。
  23. ^ jFastCGI - fastCGI clients + servers for Java and all languages on the JVM -”. 2020年4月21日閲覧。
  24. ^ node-fastcgi - npm”. 2020年4月21日閲覧。
  25. ^ FCGI - Fast CGI module - metacpan.org”. 2020年4月21日閲覧。
  26. ^ PHP: FastCGI Process Manager (FPM) - Manual”. 2020年4月21日閲覧。
  27. ^ FasterCGI with HHVM | HHVM”. 2020年4月21日閲覧。
  28. ^ いくつかのRustクレイトが存在する: リスナー実装は fastcgi、 また fastcgi-client はクライアント実装。
  29. ^ REAL Software: REAL Studio - das beste Entwicklungswerkzeug für Mac, Windows und Linux”. 2020年4月21日閲覧。

関連項目

[編集]

外部リンク

[編集]
{{bottomLinkPreText}} {{bottomLinkText}}
FastCGI
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?