Skip to content

This is the multi-page printable view of this section. .

Return to the regular view of this page.

Benchmarks

Performance measures for etcd

Benchmarks

etcd benchmarks will be published regularly and tracked for each release below:

Memory Usage Benchmarks

It records expected memory usage in different scenarios.

1 - Storage Memory Usage Benchmark

Performance measures for etcd storage (in-memory index & page cache)

Two components of etcd storage consume physical memory. The etcd process allocates an in-memory index to speed key lookup. The process’s page cache, managed by the operating system, stores recently-accessed data from disk for quick re-use.

The in-memory index holds all the keys in a B-tree data structure, along with pointers to the on-disk data (the values). Each key in the B-tree may contain multiple pointers, pointing to different versions of its values. The theoretical memory consumption of the in-memory index can hence be approximated with the formula:

N * (c1 + avg_key_size) + N * (avg_versions_of_key) * (c2 + size_of_pointer)

where c1 is the key metadata overhead and c2 is the version metadata overhead.

The graph shows the detailed structure of the in-memory index B-tree.



                                In mem index

                               +------------+
                               | key || ... |
  +--------------+             |     ||     |
  |              |             +------------+
  |              |             | v1  || ... |
  |   disk    <----------------|     ||     | Tree Node
  |              |             +------------+
  |              |             | v2  || ... |
  |           <----------------+     ||     |
  |              |             +------------+
  +--------------+       +-----+    |   |   |
                         |     |    |   |   |
                         |     +------------+
                         |
                         |
                         ^
                      ------+
                      | ... |
                      |     |
                      +-----+
                      | ... | Tree Node
                      |     |
                      +-----+
                      | ... |
                      |     |
                      ------+

Page cache memory is managed by the operating system and is not covered in detail in this document.

Testing Environment

etcd version

GCE n1-standard-2 machine type

  • 7.5 GB memory
  • 2x CPUs

In-memory index memory usage

In this test, we only benchmark the memory usage of the in-memory index. The goal is to find c1 and c2 mentioned above and to understand the hard limit of memory consumption of the storage.

We calculate the memory usage consumption via the Go runtime.ReadMemStats. We calculate the total allocated bytes difference before creating the index and after creating the index. It cannot perfectly reflect the memory usage of the in-memory index itself but can show the rough consumption pattern.

N versions key size memory usage
100K 1 64bytes 22MB
100K 5 64bytes 39MB
1M 1 64bytes 218MB
1M 5 64bytes 432MB
100K 1 256bytes 41MB
100K 5 256bytes 65MB
1M 1 256bytes 409MB
1M 5 256bytes 506MB

Based on the result, we can calculate c1=120bytes, c2=30bytes. We only need two sets of data to calculate c1 and c2, since they are the only unknown variable in the formula. The c1=120bytes and c2=30bytes are the average value of the 4 sets of c1 and c2 we calculated. The key metadata overhead is still relatively nontrivial (50%) for small key-value pairs. However, this is a significant improvement over the old store, which had at least 1000% overhead.

Overall memory usage

The overall memory usage captures how much RSS etcd consumes with the storage. The value size should have very little impact on the overall memory usage of etcd, since we keep values on disk and only retain hot values in memory, managed by the OS page cache.

N versions key size value size memory usage
100K 1 64bytes 256bytes 40MB
100K 5 64bytes 256bytes 89MB
1M 1 64bytes 256bytes 470MB
1M 5 64bytes 256bytes 880MB
100K 1 64bytes 1KB 102MB
100K 5 64bytes 1KB 164MB
1M 1 64bytes 1KB 587MB
1M 5 64bytes 1KB 836MB

Based on the result, we know the value size does not significantly impact the memory consumption. There is some minor increase due to more data held in the OS page cache.

2 - Watch Memory Usage Benchmark

Performance measures for etcd watchers
Note

The watch features are under active development, and their memory usage may change as that development progresses. We do not expect it to significantly increase beyond the figures stated below.

A primary goal of etcd is supporting a very large number of watchers doing a massively large amount of watching. etcd aims to support O(10k) clients, O(100K) watch streams (O(10) streams per client) and O(10M) total watchings (O(100) watching per stream). The memory consumed by each individual watching accounts for the largest portion of etcd’s overall usage, and is therefore the focus of current and future optimizations.

Three related components of etcd watch consume physical memory: each grpc.Conn, each watch stream, and each instance of the watching activity. grpc.Conn maintains the actual TCP connection and other gRPC connection state. Each grpc.Conn consumes O(10kb) of memory, and might have multiple watch streams attached.

Each watch stream is an independent HTTP2 connection which consumes another O(10kb) of memory. Multiple watchings might share one watch stream.

Watching is the actual struct that tracks the changes on the key-value store. Each watching should only consume < O(1kb).

                                          +-------+
                                          | watch |
                              +---------> | foo   |
                              |           +-------+
                       +------+-----+
                       |   stream   |
      +--------------> |            |
      |                +------+-----+     +-------+
      |                       |           | watch |
      |                       +---------> | bar   |
+-----+------+                            +-------+
|            |         +------------+
|   conn     +-------> |   stream   |
|            |         |            |
+-----+------+         +------------+
      |
      |
      |
      |                +------------+
      +--------------> |   stream   |
                       |            |
                       +------------+

The theoretical memory consumption of watch can be approximated with the formula: memory = c1 * number_of_conn + c2 * avg_number_of_stream_per_conn + c3 * avg_number_of_watch_stream

Testing Environment

etcd version

GCE n1-standard-2 machine type

  • 7.5 GB memory
  • 2x CPUs

Overall memory usage

The overall memory usage captures how much RSS etcd consumes with the client watchers. While the result may vary by as much as 10%, it is still meaningful, since the goal is to learn about the rough memory usage and the pattern of allocations.

With the benchmark result, we can calculate roughly that c1 = 17kb, c2 = 18kb and c3 = 350bytes. So each additional client connection consumes 17kb of memory and each additional stream consumes 18kb of memory, and each additional watching only cause 350bytes. A single etcd server can maintain millions of watchings with a few GB of memory in normal case.

clients streams per client watchings per stream total watching memory usage
1k 1 1 1k 50MB
2k 1 1 2k 90MB
5k 1 1 5k 200MB
1k 10 1 10k 217MB
2k 10 1 20k 417MB
5k 10 1 50k 980MB
1k 50 1 50k 1001MB
2k 50 1 100k 1960MB
5k 50 1 250k 4700MB
1k 50 10 500k 1171MB
2k 50 10 1M 2371MB
5k 50 10 2.5M 5710MB
1k 50 100 5M 2380MB
2k 50 100 10M 4672MB
5k 50 100 25M OOM

3 - Benchmarking etcd v3

Performance measures for etcd v3

Physical machines

GCE n1-highcpu-2 machine type

  • 1x dedicated local SSD mounted under /var/lib/etcd
  • 1x dedicated slow disk for the OS
  • 1.8 GB memory
  • 2x CPUs
  • etcd version 2.2.0

etcd Cluster

1 etcd member running in v3 demo mode

Testing

Use etcd v3 benchmark tool .

Performance

reading one single key

key size in bytes number of clients read QPS 90th Percentile Latency (ms)
256 1 2716 0.4
256 64 16623 6.1
256 256 16622 21.7

The performance is nearly the same as the one with empty server handler.

reading one single key after putting

key size in bytes number of clients read QPS 90th Percentile Latency (ms)
256 1 2269 0.5
256 64 13582 8.6
256 256 13262 47.5

The performance with empty server handler is not affected by one put. So the performance downgrade should be caused by storage package.

4 - Benchmarking etcd v2.2.0-rc-memory

Performance measures for etcd v2.2.0-rc-memory

Physical machine

GCE n1-standard-2 machine type

  • 1x dedicated local SSD mounted under /var/lib/etcd
  • 1x dedicated slow disk for the OS
  • 7.5 GB memory
  • 2x CPUs

etcd

etcd Version: 2.2.0-rc.0+git
Git SHA: 103cb5c
Go Version: go1.5
Go OS/Arch: linux/amd64

Testing

Start 3-member etcd cluster, each of which uses 2 cores.

The length of key name is always 64 bytes, which is a reasonable length of average key bytes.

Memory Maximal Usage

  • etcd may use maximal memory if one follower is dead and the leader keeps sending snapshots.
  • max RSS is the maximal memory usage recorded in 3 runs.
value bytes key number data size(MB) max RSS(MB) max RSS/data rate on leader
128 50000 6 433 72x
128 100000 12 659 54x
128 200000 24 1466 61x
1024 50000 48 1253 26x
1024 100000 96 2344 24x
1024 200000 192 4361 22x

Data Size Threshold

  • When etcd reaches data size threshold, it may trigger leader election easily and drop part of proposals.
  • For most cases, the etcd cluster should work smoothly if it doesn’t hit the threshold. If it doesn’t work well due to insufficient resources, decrease its data size.
value bytes key number limitation suggested data size threshold(MB) consumed RSS(MB)
128 400K 48 2400
1024 300K 292 6500

5 - Benchmarking etcd v2.2.0-rc

Performance measures for etcd v2.2.0-rc

Physical machine

GCE n1-highcpu-2 machine type

  • 1x dedicated local SSD mounted under /var/lib/etcd
  • 1x dedicated slow disk for the OS
  • 1.8 GB memory
  • 2x CPUs

etcd Cluster

3 etcd 2.2.0-rc members, each runs on a single machine.

Detailed versions:

etcd Version: 2.2.0-alpha.1+git
Git SHA: 59a5a7e
Go Version: go1.4.2
Go OS/Arch: linux/amd64

Also, we use 3 etcd 2.1.0 alpha-stage members to form cluster to get base performance. etcd’s commit head is at c7146bd5 , which is the same as the one that we use in etcd 2.1 benchmark .

Testing

Bootstrap another machine and use the hey HTTP benchmark tool to send requests to each etcd member. Check the benchmark hacking guide for detailed instructions.

Performance

reading one single key

key size in bytes number of clients target etcd server read QPS 90th Percentile Latency (ms)
64 1 leader only 2804 (-5%) 0.4 (+0%)
64 64 leader only 17816 (+0%) 5.7 (-6%)
64 256 leader only 18667 (-6%) 20.4 (+2%)
256 1 leader only 2181 (-15%) 0.5 (+25%)
256 64 leader only 17435 (-7%) 6.0 (+9%)
256 256 leader only 18180 (-8%) 21.3 (+3%)
64 64 all servers 46965 (-4%) 2.1 (+0%)
64 256 all servers 55286 (-6%) 7.4 (+6%)
256 64 all servers 46603 (-6%) 2.1 (+5%)
256 256 all servers 55291 (-6%) 7.3 (+4%)

writing one single key

key size in bytes number of clients target etcd server write QPS 90th Percentile Latency (ms)
64 1 leader only 76 (+22%) 19.4 (-15%)
64 64 leader only 2461 (+45%) 31.8 (-32%)
64 256 leader only 4275 (+1%) 69.6 (-10%)
256 1 leader only 64 (+20%) 16.7 (-30%)
256 64 leader only 2385 (+30%) 31.5 (-19%)
256 256 leader only 4353 (-3%) 74.0 (+9%)
64 64 all servers 2005 (+81%) 49.8 (-55%)
64 256 all servers 4868 (+35%) 81.5 (-40%)
256 64 all servers 1925 (+72%) 47.7 (-59%)
256 256 all servers 4975 (+36%) 70.3 (-36%)

performance changes explanation

  • read QPS in most scenarios is decreased by 5~8%. The reason is that etcd records store metrics for each store operation. The metrics is important for monitoring and debugging, so this is acceptable.

  • write QPS to leader is increased by 20~30%. This is because we decouple raft main loop and entry apply loop, which avoids them blocking each other.

  • write QPS to all servers is increased by 30~80% because follower could receive latest commit index earlier and commit proposals faster.

6 - Benchmarking etcd v2.2.0

Performance measures for etcd v2.2.0

Physical Machines

GCE n1-highcpu-2 machine type

  • 1x dedicated local SSD mounted as etcd data directory
  • 1x dedicated slow disk for the OS
  • 1.8 GB memory
  • 2x CPUs

etcd Cluster

3 etcd 2.2.0 members, each runs on a single machine.

Detailed versions:

etcd Version: 2.2.0
Git SHA: e4561dd
Go Version: go1.5
Go OS/Arch: linux/amd64

Testing

Bootstrap another machine, outside of the etcd cluster, and run the hey HTTP benchmark tool with a connection reuse patch to send requests to each etcd cluster member. See the benchmark instructions for the patch and the steps to reproduce our procedures.

The performance is calculated through results of 100 benchmark rounds.

Performance

Single Key Read Performance

key size in bytes number of clients target etcd server average read QPS read QPS stddev average 90th Percentile Latency (ms) latency stddev
64 1 leader only 2303 200 0.49 0.06
64 64 leader only 15048 685 7.60 0.46
64 256 leader only 14508 434 29.76 1.05
256 1 leader only 2162 214 0.52 0.06
256 64 leader only 14789 792 7.69 0.48
256 256 leader only 14424 512 29.92 1.42
64 64 all servers 45752 2048 2.47 0.14
64 256 all servers 46592 1273 10.14 0.59
256 64 all servers 45332 1847 2.48 0.12
256 256 all servers 46485 1340 10.18 0.74

Single Key Write Performance

key size in bytes number of clients target etcd server average write QPS write QPS stddev average 90th Percentile Latency (ms) latency stddev
64 1 leader only 55 4 24.51 13.26
64 64 leader only 2139 125 35.23 3.40
64 256 leader only 4581 581 70.53 10.22
256 1 leader only 56 4 22.37 4.33
256 64 leader only 2052 151 36.83 4.20
256 256 leader only 4442 560 71.59 10.03
64 64 all servers 1625 85 58.51 5.14
64 256 all servers 4461 298 89.47 36.48
256 64 all servers 1599 94 60.11 6.43
256 256 all servers 4315 193 88.98 7.01

Performance Changes

  • Because etcd now records metrics for each API call, read QPS performance seems to see a minor decrease in most scenarios. This minimal performance impact was judged a reasonable investment for the breadth of monitoring and debugging information returned.

  • Write QPS to cluster leaders seems to be increased by a small margin. This is because the main loop and entry apply loops were decoupled in the etcd raft logic, eliminating several blocks between them.

  • Write QPS to all members seems to be increased by a significant margin, because followers now receive the latest commit index sooner, and commit proposals more quickly.

7 - Benchmarking etcd v2.1.0

Performance measures for etcd v2.1.0

Physical machines

GCE n1-highcpu-2 machine type

  • 1x dedicated local SSD mounted under /var/lib/etcd
  • 1x dedicated slow disk for the OS
  • 1.8 GB memory
  • 2x CPUs
  • etcd version 2.1.0 alpha

etcd Cluster

3 etcd members, each runs on a single machine

Testing

Bootstrap another machine and use the hey HTTP benchmark tool to send requests to each etcd member. Check the benchmark hacking guide for detailed instructions.

Performance

reading one single key

key size in bytes number of clients target etcd server read QPS 90th Percentile Latency (ms)
64 1 leader only 1534 0.7
64 64 leader only 10125 9.1
64 256 leader only 13892 27.1
256 1 leader only 1530 0.8
256 64 leader only 10106 10.1
256 256 leader only 14667 27.0
64 64 all servers 24200 3.9
64 256 all servers 33300 11.8
256 64 all servers 24800 3.9
256 256 all servers 33000 11.5

writing one single key

key size in bytes number of clients target etcd server write QPS 90th Percentile Latency (ms)
64 1 leader only 60 21.4
64 64 leader only 1742 46.8
64 256 leader only 3982 90.5
256 1 leader only 58 20.3
256 64 leader only 1770 47.8
256 256 leader only 4157 105.3
64 64 all servers 1028 123.4
64 256 all servers 3260 123.8
256 64 all servers 1033 121.5
256 256 all servers 3061 119.3