<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>7.3.1. 比較 — groonga v3.0.5ドキュメント</title> <link rel="stylesheet" href="../../_static/groonga.css" type="text/css" /> <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '3.0.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../../_static/jquery.js"></script> <script type="text/javascript" src="../../_static/underscore.js"></script> <script type="text/javascript" src="../../_static/doctools.js"></script> <script type="text/javascript" src="../../_static/translations.js"></script> <link rel="shortcut icon" href="../../_static/favicon.ico"/> <link rel="top" title="groonga v3.0.5ドキュメント" href="../../index.html" /> <link rel="up" title="7.3. HTTP" href="../http.html" /> <link rel="next" title="7.3.2. groonga" href="groonga.html" /> <link rel="prev" title="7.3. HTTP" href="../http.html" /> </head> <body> <div class="header"> <h1 class="title"> <a id="top-link" href="../../index.html"> <span class="project">groonga</span> <span class="separator">-</span> <span class="description">オープンソースのカラムストア機能付き全文検索エンジン</span> </a> </h1> <div class="other-language-links"> <ul> <li><a href="../../../../en/html/server/http/comparison.html"><img src="../../_static/us.png" alt="English">English page</a></li> </ul> </div> </div> <div class="related"> <h3>ナビゲーション</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../../genindex.html" title="総合索引" accesskey="I">索引</a></li> <li class="right" > <a href="groonga.html" title="7.3.2. groonga" accesskey="N">次へ</a> |</li> <li class="right" > <a href="../http.html" title="7.3. HTTP" accesskey="P">前へ</a> |</li> <li><a href="../../index.html">groonga v3.0.5ドキュメント</a> »</li> <li><a href="../../server.html" >7. サーバー</a> »</li> <li><a href="../http.html" accesskey="U">7.3. HTTP</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="comparison"> <h1>7.3.1. 比較<a class="headerlink" href="#comparison" title="このヘッドラインへのパーマリンク">¶</a></h1> <p><a class="reference internal" href="groonga.html"><em>groonga</em></a> と <a class="reference internal" href="groonga-httpd.html"><em>groonga-httpd</em></a> にはたくさんの違いがあります。以下はそれらの違いを示す比較表です。</p> <table border="1" class="docutils"> <colgroup> <col width="38%" /> <col width="32%" /> <col width="30%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head"> </th> <th class="head">groonga</th> <th class="head">groonga-httpd</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><p class="first last">性能</p> </td> <td><p class="first last">○</p> </td> <td><p class="first last">○</p> </td> </tr> <tr class="row-odd"><td><p class="first last">複数CPUコア対応</p> </td> <td><p class="first last">○(マルチスレッドで対応)</p> </td> <td><p class="first last">○(マルチプロセスで対応)</p> </td> </tr> <tr class="row-even"><td><p class="first last">設定ファイル</p> </td> <td><p class="first last">なくてもよい</p> </td> <td><p class="first last">必須</p> </td> </tr> <tr class="row-odd"><td><p class="first last">プレフィックスパスの変更</p> </td> <td><p class="first last">×</p> </td> <td><p class="first last">○</p> </td> </tr> <tr class="row-even"><td><p class="first last">コマンドバージョンの変更</p> </td> <td><p class="first last">○</p> </td> <td><p class="first last">×(まもなく実装予定)</p> </td> </tr> <tr class="row-odd"><td><p class="first last">複数データベース</p> </td> <td><p class="first last">×</p> </td> <td><p class="first last">○</p> </td> </tr> <tr class="row-even"><td><p class="first last">認証</p> </td> <td><p class="first last">×</p> </td> <td><p class="first last">○</p> </td> </tr> <tr class="row-odd"><td><p class="first last">gzip圧縮</p> </td> <td><p class="first last">×</p> </td> <td><p class="first last">○</p> </td> </tr> <tr class="row-even"><td>POST</td> <td><p class="first last">×</p> </td> <td><p class="first last">○</p> </td> </tr> <tr class="row-odd"><td>HTTPS</td> <td><p class="first last">×</p> </td> <td><p class="first last">○</p> </td> </tr> <tr class="row-even"><td><p class="first last">アクセスログ</p> </td> <td><p class="first last">×</p> </td> <td><p class="first last">○</p> </td> </tr> <tr class="row-odd"><td><p class="first last">ダウンタイムなしでのアップグレード</p> </td> <td><p class="first last">×</p> </td> <td><p class="first last">○</p> </td> </tr> </tbody> </table> <div class="section" id="performance"> <h2>7.3.1.1. 性能<a class="headerlink" href="#performance" title="このヘッドラインへのパーマリンク">¶</a></h2> <p><a class="reference internal" href="groonga.html"><em>groonga</em></a> と <a class="reference internal" href="groonga-httpd.html"><em>groonga-httpd</em></a> はどちらも非常に高速です。どちらも同じスループットで動きます。</p> </div> <div class="section" id="using-multi-cpu-cores"> <h2>7.3.1.2. 複数CPUコア対応<a class="headerlink" href="#using-multi-cpu-cores" title="このヘッドラインへのパーマリンク">¶</a></h2> <p>groongaは複数のCPUコアを使って性能を向上できます。 <a class="reference internal" href="groonga.html"><em>groonga</em></a> はマルチスレッドを使って性能を向上させます。 <a class="reference internal" href="groonga-httpd.html"><em>groonga-httpd</em></a> はマルチプロセスを使って性能を向上させます。</p> <p><a class="reference internal" href="groonga.html"><em>groonga</em></a> はデフォルトでCPUコアと同じ数のスレッドを使います。もし、CPUコアが8個あった場合は、デフォルトで8個のスレッドを使います。</p> <p><a class="reference internal" href="groonga-httpd.html"><em>groonga-httpd</em></a> はデフォルトで1つのプロセスを使います。複数のCPUコアを使う場合は <a class="reference external" href="http://nginx.org/en/docs/ngx_core_module.html#worker_processes">worker_processes</a> ディレクティブを設定する必要があります。CPUコアが8個ある場合は、以下のように設定ファイルに <tt class="docutils literal"><span class="pre">worker_processes</span> <span class="pre">8</span></tt> と指定します。:</p> <div class="highlight-none"><div class="highlight"><pre>worker_processes 8; http { # ... } </pre></div> </div> </div> <div class="section" id="configuration-file"> <h2>7.3.1.3. 設定ファイル<a class="headerlink" href="#configuration-file" title="このヘッドラインへのパーマリンク">¶</a></h2> <p><a class="reference internal" href="groonga.html"><em>groonga</em></a> は設定ファイルがなくても動きます。ポート番号や最大スレッド数などといった設定項目はすべてコマンドラインから指定できます。設定ファイルを使っても設定項目を指定することができます。</p> <p><a class="reference internal" href="groonga.html"><em>groonga</em></a> はいくつかのオプションを指定するだけで実行できるので、非常に簡単にgroonga用のHTTPサーバーを起動することができます。以下は <a class="reference internal" href="groonga.html"><em>groonga</em></a> でHTTPサーバーを起動する一番簡単なコマンドラインです。:</p> <div class="highlight-none"><div class="highlight"><pre>% groonga --protocol http -d /PATH/TO/DATABASE </pre></div> </div> <p><a class="reference internal" href="groonga-httpd.html"><em>groonga-httpd</em></a> を実行するには設定ファイルが必須です。以下は <a class="reference internal" href="groonga-httpd.html"><em>groonga-httpd</em></a> でHTTPサーバーを実行する一番簡単な設定ファイルです。:</p> <div class="highlight-none"><div class="highlight"><pre>events { } http { server { listen 10041; location /d/ { groonga on; groonga_database /PATH/TO/DATABASE; } } } </pre></div> </div> </div> <div class="section" id="custom-prefix-path"> <h2>7.3.1.4. プレフィックスパスの変更<a class="headerlink" href="#custom-prefix-path" title="このヘッドラインへのパーマリンク">¶</a></h2> <p><a class="reference internal" href="groonga.html"><em>groonga</em></a> は <tt class="docutils literal"><span class="pre">/d/</span></tt> から始まるパスをコマンドURLとして受け付けます。例えば、 <tt class="docutils literal"><span class="pre">http://localhost:10041/d/status</span></tt> となります。この <tt class="docutils literal"><span class="pre">/d/</span></tt> というプレフィックスパスを変更することはできません。</p> <p><a class="reference internal" href="groonga-httpd.html"><em>groonga-httpd</em></a> はプレフィックスパスを変更することができます。例えば、 <tt class="docutils literal"><span class="pre">http://localhost:10041/api/status</span></tt> というコマンドURLを使うことができます。以下は <tt class="docutils literal"><span class="pre">/api/</span></tt> をプレフィックスパスとして使う設定例です。:</p> <div class="highlight-none"><div class="highlight"><pre>events { } http { server { listen 10041; location /api/ { # <- change this groonga on; groonga_database /PATH/TO/DATABASE; } } } </pre></div> </div> </div> <div class="section" id="custom-command-version"> <h2>7.3.1.5. コマンドバージョンの変更<a class="headerlink" href="#custom-command-version" title="このヘッドラインへのパーマリンク">¶</a></h2> <p>groongaには <a class="reference internal" href="../../reference/command/command_version.html"><em>コマンドバージョン</em></a> という仕組みがあります。これは後方互換性を維持したままgroongaコマンドをアップグレードするための仕組みです。</p> <p><a class="reference internal" href="groonga.html"><em>groonga</em></a> は <tt class="docutils literal"><span class="pre">--default-command-version</span></tt> オプションでデフォルトのコマンドバージョンを変更できます。以下はデフォルトのコマンドバージョンとしてコマンドバージョン2を使うコマンドライン例です。:</p> <div class="highlight-none"><div class="highlight"><pre>% groonga --protocol http --default-command-version 2 -d /PATH/TO/DATABASE </pre></div> </div> <p><a class="reference internal" href="groonga-httpd.html"><em>groonga-httpd</em></a> はまだデフォルトのコマンドバージョンを変更できません。しかし、すぐにサポートする予定です。サポートされたら、同じ <a class="reference internal" href="groonga-httpd.html"><em>groonga-httpd</em></a> プロセス内で異なったコマンドバージョンのgroongaコマンドを提供できます。以下はコマンドバージョン1のコマンドを <tt class="docutils literal"><span class="pre">/api/1/</span></tt> 以下で、コマンドバージョン2のコマンドを <tt class="docutils literal"><span class="pre">/api/2/</span></tt> 以下で提供するための設定例です。:</p> <div class="highlight-none"><div class="highlight"><pre>events { } http { server { listen 10041; groonga_database /PATH/TO/DATABASE; location /api/1/ { groonga on; groogna_default_command_version 1; } location /api/2/ { groonga on; groogna_default_command_version 2; } } } </pre></div> </div> </div> <div class="section" id="multi-databases"> <h2>7.3.1.6. 複数データベース<a class="headerlink" href="#multi-databases" title="このヘッドラインへのパーマリンク">¶</a></h2> <p><a class="reference internal" href="groonga.html"><em>groonga</em></a> は1つのプロセスで1つのデータベースしか使うことができません。</p> <p><a class="reference internal" href="groonga-httpd.html"><em>groonga-httpd</em></a> は同一プロセス内で複数のデータベースを使うことができます。以下は <tt class="docutils literal"><span class="pre">/tmp/db1</span></tt> にあるデータベースを <tt class="docutils literal"><span class="pre">/db1/</span></tt> 以下で、 <tt class="docutils literal"><span class="pre">/tmp/db2</span></tt> にあるデータベースを <tt class="docutils literal"><span class="pre">/db2/</span></tt> 以下で提供する設定例です。:</p> <div class="highlight-none"><div class="highlight"><pre>events { } http { server { listen 10041; location /db1/ { groonga on; groonga_database /tmp/db1; } location /db2/ { groonga on; groonga_database /tmp/db2; } } } </pre></div> </div> </div> <div class="section" id="authentication"> <h2>7.3.1.7. 認証<a class="headerlink" href="#authentication" title="このヘッドラインへのパーマリンク">¶</a></h2> <p>HTTPではベーシック認証やダイジェスト認証などの認証方法をサポートしています。認証することにより <a class="reference internal" href="../../reference/commands/shutdown.html"><em>shutdown</em></a> などのように危険なコマンドの実行を制限することができます。</p> <p><a class="reference internal" href="groonga.html"><em>groonga</em></a> では認証できません。危険なコマンドの使用を制限するためには、iptablesやリバースプロキシなど他のツールを使う必要があります。</p> <p><a class="reference internal" href="groonga-httpd.html"><em>groonga-httpd</em></a> はベーシック認証をサポートしています。以下は <a class="reference internal" href="../../reference/commands/shutdown.html"><em>shutdown</em></a> コマンドの使用を制限する設定例です。:</p> <div class="highlight-none"><div class="highlight"><pre>events { } http { server { listen 10041; groonga_database /PATH/TO/DATABASE; location /d/shutdown { groonga on; auth_basic "manager is required!"; auth_basic_user_file "/etc/managers.htpasswd"; } location /d/ { groonga on; } } } </pre></div> </div> </div> <div class="section" id="gzip-compression"> <h2>7.3.1.8. gzip圧縮<a class="headerlink" href="#gzip-compression" title="このヘッドラインへのパーマリンク">¶</a></h2> <p>HTTPは <tt class="docutils literal"><span class="pre">Content-Encoding:</span> <span class="pre">gzip</span></tt> レスポンスヘッダーを付けてgzipでレスポンスを圧縮する機能をサポートしています。これはネットワーク流量を小さくすることができます。大きな検索結果を返すときに有用です。</p> <p><a class="reference internal" href="groonga.html"><em>groonga</em></a> は圧縮をサポートしていません。圧縮をサポートするためには、リバースプロキシを使う必要があります。</p> <p><a class="reference internal" href="groonga-httpd.html"><em>groonga-httpd</em></a> はgzip圧縮をサポートしています。以下はレスポンスをgzipで圧縮する設定例です。:</p> <div class="highlight-none"><div class="highlight"><pre>events { } http { server { listen 10041; groonga_database /PATH/TO/DATABASE; location /d/ { groonga on; gzip on; gzip_types *; } } } </pre></div> </div> <p><cite>gzip_types *</cite> を指定していることに注意してください。この設定はとても重要な設定です。 <cite>gzip_types</cite> はgzip対象のデータフォーマットをMIMEタイプで指定します。 <a class="reference internal" href="groonga-httpd.html"><em>groonga-httpd</em></a> は JSON、XML、MessagePackのどれかのフォーマットでデータを返します。しかし、これらのフォーマットは <cite>gzip_types</cite> のデフォルト値に含まれていません。 <cite>gzip_types</cite> のデフォルト値は <cite>text/html</cite> です。</p> <p><a class="reference internal" href="groonga-httpd.html"><em>groonga-httpd</em></a> のレスポンスデータをgzip圧縮するには、明示的に <cite>gzip_types *</cite> または <cite>gzip_types application/json text/xml application/x-msgpack</cite> と指定する必要があります。 <cite>gzip_types *</cite> の方がおすすめです。理由は2つあります。1つは、groongaが、将来、他のフォーマットもサポートする可能性もあるからという理由です。2つめは、この <cite>location</cite> のすべてのリクエストはgroongaが処理するので、他のモジュールのことについて考えなくてもよいからという理由です。</p> </div> <div class="section" id="post"> <h2>7.3.1.9. POST<a class="headerlink" href="#post" title="このヘッドラインへのパーマリンク">¶</a></h2> <p>JSONデータをPOSTすることでデータをロードすることができます。POSTでロードする場合は以下のルールに従ってください。</p> <ul class="simple"> <li><p class="first"><cite>Content-Type</cite> ヘッダーの値を <cite>application/json</cite> にする。</p> </li> <li><p class="first">JSONデータはbodyとして送る。</p> </li> <li><p class="first">テーブル名は <tt class="docutils literal"><span class="pre">table=名前</span></tt> というようにクエリーパラメーターで指定する。</p> </li> </ul> <p>以下はcurlを使って <cite>alice</cite> と <cite>bob</cite> という2人のユーザーを <cite>Users</cite> テーブルにロードするコマンドラインの例です:</p> <div class="highlight-none"><div class="highlight"><pre>% curl --data-binary '[{"_key": "alice"}, {"_key": "bob"}]' -H "Content-Type: application/json" "http://localhost:10041/d/load?table=Users" </pre></div> </div> </div> <div class="section" id="https"> <h2>7.3.1.10. HTTPS<a class="headerlink" href="#https" title="このヘッドラインへのパーマリンク">¶</a></h2> <p>TODO</p> </div> <div class="section" id="access-log"> <h2>7.3.1.11. アクセスログ<a class="headerlink" href="#access-log" title="このヘッドラインへのパーマリンク">¶</a></h2> <p>TODO</p> </div> <div class="section" id="upgrading-without-downtime"> <h2>7.3.1.12. ダウンタイムなしでのアップグレード<a class="headerlink" href="#upgrading-without-downtime" title="このヘッドラインへのパーマリンク">¶</a></h2> <p>TODO</p> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../../index.html">目次</a></h3> <ul> <li><a class="reference internal" href="#">7.3.1. 比較</a><ul> <li><a class="reference internal" href="#performance">7.3.1.1. 性能</a></li> <li><a class="reference internal" href="#using-multi-cpu-cores">7.3.1.2. 複数CPUコア対応</a></li> <li><a class="reference internal" href="#configuration-file">7.3.1.3. 設定ファイル</a></li> <li><a class="reference internal" href="#custom-prefix-path">7.3.1.4. プレフィックスパスの変更</a></li> <li><a class="reference internal" href="#custom-command-version">7.3.1.5. コマンドバージョンの変更</a></li> <li><a class="reference internal" href="#multi-databases">7.3.1.6. 複数データベース</a></li> <li><a class="reference internal" href="#authentication">7.3.1.7. 認証</a></li> <li><a class="reference internal" href="#gzip-compression">7.3.1.8. gzip圧縮</a></li> <li><a class="reference internal" href="#post">7.3.1.9. POST</a></li> <li><a class="reference internal" href="#https">7.3.1.10. HTTPS</a></li> <li><a class="reference internal" href="#access-log">7.3.1.11. アクセスログ</a></li> <li><a class="reference internal" href="#upgrading-without-downtime">7.3.1.12. ダウンタイムなしでのアップグレード</a></li> </ul> </li> </ul> <h4>前のトピックへ</h4> <p class="topless"><a href="../http.html" title="前の章へ">7.3. HTTP</a></p> <h4>次のトピックへ</h4> <p class="topless"><a href="groonga.html" title="次の章へ">7.3.2. groonga</a></p> <h3>このページ</h3> <ul class="this-page-menu"> <li><a href="../../_sources/server/http/comparison.txt" rel="nofollow">ソースコードを表示</a></li> </ul> <div id="searchbox" style="display: none"> <h3>クイック検索</h3> <form class="search" action="../../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="検索" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> モジュール、クラス、または関数名を入力してください </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>ナビゲーション</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../../genindex.html" title="総合索引" >索引</a></li> <li class="right" > <a href="groonga.html" title="7.3.2. groonga" >次へ</a> |</li> <li class="right" > <a href="../http.html" title="7.3. HTTP" >前へ</a> |</li> <li><a href="../../index.html">groonga v3.0.5ドキュメント</a> »</li> <li><a href="../../server.html" >7. サーバー</a> »</li> <li><a href="../http.html" >7.3. HTTP</a> »</li> </ul> </div> <div class="footer"> © Copyright 2009-2013, Brazil, Inc. </div> </body> </html>