summaryrefslogtreecommitdiff
path: root/src/docs/rfcs/013-node-types.md
blob: fc5059834f2a40bc279953a4a2b7e434de727f67 (plain)
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
---
name: Node Types
about: Introduce heterogeneous node types to CouchDB 4
title: 'Node Types'
labels: rfc, discussion
assignees: ''

---

# Introduction

This RFC proposes the ability to have different node types in CouchDB 4+. This
would improve performance and allow for a more efficient use of resources.

## Abstract

Previously, in CouchDB 2 and 3, cluster functionality was uniformly distributed
amongst the nodes. Any node could accept HTTP requests, run replication jobs
and build secondary indices. With the FDB-based topology, CRUD operations have
lower resource needs and so it could be useful to have a heterogeneous
topology, where for example, CRUD operations run on lower capacity nodes, and a
few higher capacity nodes handle replication or indexing jobs.


## Requirements Language

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED",  "MAY", and "OPTIONAL" in this
document are to be interpreted as described in
[RFC 2119](https://www.rfc-editor.org/rfc/rfc2119.txt).

## Terminology

*node type* : A label used to designate a subset of CouchDB functionality.

---

# Detailed Description

## Node Types

A node type is a description of a some internal CouchDB functionality. These
are the initially defined node types:

 * `api_frontend` : Indicates this node can accept HTTP API requests.
 * `view_indexing` : Indicates this node can build map/reduce view indices.
 * `search_indexing` : Indicates this node can build search indices.
 * `replication` : Indicates this node can run replication jobs.

Users can configure CouchDB nodes with any combination of those types.

## Configuration

Configuration MAY be specified in the Erlang application or OS environment
variables. OS environment variables have a higher precedence. By default, if
the type is not configured in either one of those places, it defaults to
`true`.

### Erlang Application Environment Configuration

Configuration MUST be specified for the `fabric` application, under the
`node_types` key. The value MUST be proplist which looks like `[{$type, true |
false}, ...]`. For example, the `va.args` file MAY be used like such:

```
-fabric node_types '[{api_frontend, false}, {replication, true}]'

```

### OS Environment Configuration

Node types MAY be set via environment variables using the `COUCHDB_NODE_TYPE_`
prefix. The prefix SHOULD be followed by the type label. If the value of the
variable is `false` the functionality indicated will be disabled on that
node. Any other value, indicates `true`.

Example:

`COUCHDB_NODE_TYPE_API_FRONTEND=false COUCHDB_NODE_TYPE_VIEW_INDEXING=true ...`

## Implementation

Implementation should be minimally invasive, at least for the node types listed
above.

 * `api_frontend` would enable the `chttpd` application, or its top level
   supervisor.

 * All background tasks in FDB are executed via the `couch_jobs` framework. The
top level application supervisors typically have a separate `gen_server` in
charge of accepting jobs and executing them. The implementation then would be
as simple as having a `case` statement around the worker's `start_link()`
function.

# Advantages and Disadvantages

## Disadvantages

 - Increased configuration-state complexity

## Advantages

 - Ability to utilize hardware resources better
 - Possibly better security by running indexing and replication jobs in an
   isolated environment inaccessible from the outside

# Key Changes

 - Heterogeneous node types
 - New configuration section
 - New configuration environment variables

## Applications and Modules Affected

 - chttpd
 - fabric
 - couch_views
 - couch_jobs
 - couch_replicator
 - mango

## HTTP API additions

N/A

## HTTP API deprecations

N/A

# Security Considerations

N/A

# References

[1] https://github.com/apache/couchdb/issues/1338

[2] https://github.com/apache/couchdb/blob/main/src/docs/rfcs/007-background-jobs.md

# Acknowledgments

@kocolosk
@mikerhodes