You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/internal/DistributedArchitectureGuide.md
+221-2Lines changed: 221 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,227 @@ A guide to the general Elasticsearch components can be found [here](https://gith
12
12
13
13
# Networking
14
14
15
+
Every elasticsearch node maintains various networking clients and servers,
16
+
protocols, and synchronous/asynchronous handling. Our public docs cover user
17
+
facing settings and some internal aspects - [Network Settings](https://www.elastic.co/docs/reference/elasticsearch/configuration-reference/networking-settings).
18
+
19
+
## HTTP Server
20
+
21
+
The HTTP Server is a single entry point for all external clients (excluding
22
+
cross-cluster communication). Management, ingestion, search, and all other
23
+
external operations pass through the HTTP server.
24
+
25
+
Elasticsearch works over HTTP 1.1 and supports features such as TLS, chunked
26
+
transfer encoding, content compression, and pipelining. While attempting to
27
+
be HTTP spec compliant, Elasticsearch is not a webserver. ES Supports `GET`
28
+
requests with a payload (though some old proxies may drop content) and
29
+
`POST` for clients unable to send `GET-with-body`. Requests cannot be cached
30
+
by middle boxes.
31
+
32
+
There is no connection limit, but a limit on payload size exists. The default
33
+
maximum payload is 100MB after compression. It's a very large number and almost
34
+
never a good target that the client should approach. See
35
+
`HttpTransportSettings` class.
36
+
37
+
Security features, including basic security: authentication(authc),
38
+
authorization(authz), Transport Layer Security (TLS) are available in the free
39
+
tier and achieved with separate x-pack modules.
40
+
41
+
The HTTP server provides two options for content processing: full aggregation
42
+
and incremental processing. Aggregated content is a preferable choice for small
43
+
messages that do not fit for incremental parsing (e.g., JSON). Aggregation has
44
+
drawbacks: it requires more memory, which is reserved until all bytes are
45
+
received. Concurrent incomplete requests can lead to unbounded memory growth and
46
+
potential OOMs. Large delimited content, such as bulk indexing, which is
47
+
processed in byte chunks, provides better control over memory usage but is more
48
+
complicated for application code.
49
+
50
+
Incremental bulk indexing includes a back-pressure feature. See `org.
51
+
elasticsearch.index.IndexingPressure`. When memory pressure grows high
52
+
(`LOW_WATERMARK`), reading bytes from TCP sockets is paused for some
53
+
connections, allowing only a few to proceed until the pressure is resolved.
54
+
When memory grows too high (`HIGH_WATERMARK`) bulk items are rejected with 429.
55
+
This mechanism protects against unbounded memory usage and `OutOfMemory`
56
+
errors (OOMs).
57
+
58
+
ES supports multiple `Content-Type`s for the payload. These are
59
+
implementations of `MediaType` interface. A common implementation is called
60
+
`XContentType`, including CBOR, JSON, SMILE, YAML, and their versioned types.
61
+
X-pack extensions includes PLAIN_TEXT, CSV, etc. Classes that implement
62
+
`ToXContent` and friends can be serialized and sent over HTTP.
63
+
64
+
HTTP routing is based on a combination of Method and URI. For example,
65
+
`RestCreateIndexAction` handler uses `("PUT", "/{index}")`, where curly braces
66
+
indicate path variables. `RestBulkAction` specifies a list of routes
67
+
68
+
```java
69
+
@Override
70
+
publicList<Route> routes() {
71
+
returnList.of(
72
+
newRoute(POST, "/_bulk"),
73
+
newRoute(PUT, "/_bulk"),
74
+
newRoute(POST, "/{index}/_bulk"),
75
+
newRoute(PUT, "/{index}/_bulk")
76
+
);
77
+
}
78
+
```
79
+
80
+
Every REST handler must be declared in the `ActionModule` class in the
81
+
`initRestHandlers` method. Plugins implementing `ActionPlugin` can extend the
82
+
list of handlers via the `getRestHandlers` override. Every REST handler
83
+
should extend `BaseRestHandler`.
84
+
85
+
The REST handler’s job is to parse and validate the HTTP request and construct a
86
+
typed version of the request, often a Transport request. When security is
87
+
enabled, the HTTP layer handles authentication (based on headers), and the
88
+
Transport layer handles authorization.
89
+
90
+
Request handling flow from Java classes view goes as:
0 commit comments