Skip to content

Commit 8f25f37

Browse files
committed
Updated docs and highlighted thread safety and maxsize
Closes elastic#329
1 parent 51defea commit 8f25f37

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

docs/index.rst

+27-11
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ Persistent Connections
8585

8686
``elasticsearch-py`` uses persistent connections inside of individual connection
8787
pools (one per each configured or sniffed node). Out of the box you can choose
88-
to use ``http``, ``thrift`` or an experimental ``memcached`` protocol to
89-
communicate with the elasticsearch nodes. See :ref:`transports` for more
88+
between two ``http`` protocol implementations. See :ref:`transports` for more
9089
information.
9190

9291
The transport layer will create an instance of the selected connection class
@@ -105,14 +104,6 @@ of the relevant component and pass it in as a parameter to be used instead of
105104
the default implementation.
106105

107106

108-
.. note::
109-
110-
Since we use persistent connections throughout the client it means that the
111-
client doesn't tolerate ``fork`` very well. If your application calls for
112-
multiple processes make sure you create a fresh client after call to
113-
``fork``.
114-
115-
116107
Automatic Retries
117108
~~~~~~~~~~~~~~~~~
118109

@@ -149,8 +140,33 @@ Some example configurations::
149140
es = Elasticsearch(["seed1", "seed2"], sniff_on_start=True)
150141

151142
# you can also sniff periodically and/or after failure:
152-
es = Elasticsearch(["seed1", "seed2"], sniff_on_start=True, sniff_on_connection_fail=True, sniffer_timeout=60)
143+
es = Elasticsearch(["seed1", "seed2"],
144+
sniff_on_start=True,
145+
sniff_on_connection_fail=True,
146+
sniffer_timeout=60)
147+
148+
Thread safety
149+
~~~~~~~~~~~~~
153150

151+
The client is thread safe and can be used in a multi threaded environment. Best
152+
practice is to create a single global instance of the client and use it
153+
throughout your application. If your application is long-running consider
154+
turning on :ref:`sniffing` to make sure the client is up to date on the cluster
155+
location.
156+
157+
By default we allow ``urllib3`` to open up to 10 connections to each node, if
158+
your application calls for more paralelism, use the ``maxsize`` parameter to
159+
raise the limit::
160+
161+
# allow up to 25 connections to each node
162+
es = Elasticsearch(["host1", "host2"], maxsize=25)
163+
164+
.. note::
165+
166+
Since we use persistent connections throughout the client it means that the
167+
client doesn't tolerate ``fork`` very well. If your application calls for
168+
multiple processes make sure you create a fresh client after call to
169+
``fork``.
154170

155171
SSL and Authentication
156172
~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)