1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
|
.. -*- rst -*-
Comparison
==========
There are many differences between :doc:`groonga` and
:doc:`groonga-httpd`. Here is a comparison table.
+----------------------------+------------------------+----------------------+
| | groonga | groonga-httpd |
+============================+========================+======================+
| Performance | o | o |
+----------------------------+------------------------+----------------------+
| Using multi CPU cores | o (by multi threading) | o (by multi process) |
+----------------------------+------------------------+----------------------+
| Configuration file | optional | required |
+----------------------------+------------------------+----------------------+
| Custom prefix path | x | o |
+----------------------------+------------------------+----------------------+
| Custom command version | o | o |
+----------------------------+------------------------+----------------------+
| Multi databases | x | o |
+----------------------------+------------------------+----------------------+
| Authentication | x | o |
+----------------------------+------------------------+----------------------+
| Gzip compression | x | o |
+----------------------------+------------------------+----------------------+
| POST | o | o |
+----------------------------+------------------------+----------------------+
| HTTPS | x | o |
+----------------------------+------------------------+----------------------+
| Access log | x | o |
+----------------------------+------------------------+----------------------+
| Upgrading without downtime | x | o |
+----------------------------+------------------------+----------------------+
Performance
-----------
Both :doc:`groonga` and :doc:`groonga-httpd` are very fast. They can
work with the same throughput.
Using multi CPU cores
---------------------
Groonga scales on multi CPU cores. :doc:`groonga` scales by multi
threading. :doc:`groonga-httpd` scales by multi processes.
:doc:`groonga` uses the same number of threads as CPU cores by
default. If you have 8 CPU cores, 8 threads are used by default.
:doc:`groonga-httpd` uses 1 process by default. You need to set
`worker_processes
<http://nginx.org/en/docs/ngx_core_module.html#worker_processes>`_
directive to use CPU cores. If you have 8 CPU cores, specify
``worker_processes 8`` in configuration file like the following::
worker_processes 8;
http {
# ...
}
Configuration file
------------------
:doc:`groonga` can work without configuration file. All configuration
items such as port number and the max number of threads can be
specified by command line. Configuration file is also used to specify
configuration items.
It's very easy to run groonga HTTP server because :doc:`groonga`
requires just a few options to run. Here is the most simple command
line to start HTTP server by :doc:`groonga`::
% groonga --protocol http -d /PATH/TO/DATABASE
:doc:`groonga-httpd` requires configuration file to run. Here is the
most simple configuration file to start HTTP server by
:doc:`groonga-httpd`::
events {
}
http {
server {
listen 10041;
location /d/ {
groonga on;
groonga_database /PATH/TO/DATABASE;
}
}
}
Custom prefix path
------------------
:doc:`groonga` accepts a path that starts with ``/d/`` as command URL
such as ``http://localhost:10041/d/status``. You cannot change the
prefix path ``/d/``.
:doc:`groonga-httpd` can custom prefix path. For example, you can use
``http://localhost:10041/api/status`` as command URL. Here is a sample
configuration to use ``/api/`` as prefix path::
events {
}
http {
server {
listen 10041;
location /api/ { # <- change this
groonga on;
groonga_database /PATH/TO/DATABASE;
}
}
}
Custom command version
----------------------
Groonga has :doc:`/reference/command/command_version` mechanism. It is for
upgrading groonga commands with backward compatibility.
:doc:`groonga` can change the default command veresion by
``--default-command-version`` option. Here is a sample command line to
use command version 2 as the default command version::
% groonga --protocol http --default-command-version 2 -d /PATH/TO/DATABASE
:doc:`groonga-httpd` cannot custom the default command version
yet. But it will be supported soon. If it is supported, you can
provides different command version groonga commands in the same
:doc:`groonga-httpd` process. Here is a sample configuration to
provide command version 1 commands under ``/api/1/`` and command
version 2 comamnds under ``/api/2/``::
events {
}
http {
server {
listen 10041;
groonga_database /PATH/TO/DATABASE;
location /api/1/ {
groonga on;
groonga_default_command_version 1;
}
location /api/2/ {
groonga on;
groonga_default_command_version 2;
}
}
}
Multi databases
---------------
:doc:`groonga` can use only one database in a process.
:doc:`groonga-httpd` can use one or more databases in a process. Here
is a sample configuration to provide ``/tmp/db1`` database under
``/db1/`` path and ``/tmp/db2`` database under ``/db2/`` path::
events {
}
http {
server {
listen 10041;
location /db1/ {
groonga on;
groonga_database /tmp/db1;
}
location /db2/ {
groonga on;
groonga_database /tmp/db2;
}
}
}
Authentication
--------------
HTTP supports authentications such as basic authentication and digest
authentication. It can be used for restricting use of danger command such
as :doc:`/reference/commands/shutdown`.
:doc:`groonga` doesn't support any authentications. To restrict use of
danger command, other tools such as iptables and reverse proxy are
needed.
:doc:`groonga-httpd` supports basic authentication. Here is a sample
configuration to restrict use of :doc:`/reference/commands/shutdown`
command::
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;
}
}
}
Gzip compression
----------------
HTTP supports response compression by gzip with ``Content-Encoding:
gzip`` response header. It can reduce network flow. It is useful
for large search response.
:doc:`groonga` doesn't support compression. To support compression,
reverse proxy is needed.
:doc:`groonga-httpd` supports gzip compression. Here is a sample
configuration to compress response by gzip::
events {
}
http {
server {
listen 10041;
groonga_database /PATH/TO/DATABASE;
location /d/ {
groonga on;
gzip on;
gzip_types *;
}
}
}
Note that `gzip_types *` is specified. It's one of the important
configuration. `gzip_types` specifies gzip target data formats by MIME
types. :doc:`groonga-httpd` returns one of JSON, XML or MessagePack
format data. But those formats aren't included in the default value of
`gzip_types`. The default value of `gzip_types` is `text/html`.
To compress response data from :doc:`groonga-httpd` by gzip, you need
to specify `gzip_types *` or `gzip_types application/json text/xml
application/x-msgpack` explicitly. `gzip_types *` is recommended.
There are two reasons for it. The first, groonga may support more
formats in the future. The second, all requests for the `location` are
processed by groonga. You don't need to consider about other modules.
POST
----
You can load your data by POST JSON data. You need follow the
following rules to use loading by POST.
* `Content-Type` header value must be `application/json`.
* JSON data is sent as body.
* Table name is specified by query parameter such as ``table=NAME``.
Here is an example curl command line that loads two users `alice` and
`bob` to `Users` table::
% curl --data-binary '[{"_key": "alice"}, {"_key": "bob"}]' -H "Content-Type: application/json" "http://localhost:10041/d/load?table=Users"
HTTPS
-----
TODO
Access log
----------
TODO
Upgrading without downtime
--------------------------
TODO
|