Skip to content

Commit 3ab68dc

Browse files
committed
import features pages
1 parent 5dc22c3 commit 3ab68dc

File tree

2 files changed

+174
-0
lines changed

2 files changed

+174
-0
lines changed

content/features/restart.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
+++
2+
title = 'Warm Restart'
3+
date = 2024-09-04T13:57:33-07:00
4+
+++
5+
6+
Memcached 1.5.18 and newer can recover its cache between clean restarts. It can restart after upgrades of the
7+
binary, most changes in settings, and so on. It now also supports
8+
using persistent memory via DAX filesystem mounts. See below for more details.
9+
10+
Use it by adding: `-e /tmpfs_mount/memory_file` to your startup options.
11+
12+
`/tmpfs_mount/` must be a ram disk of some sort, big enough to satisfy the
13+
memory limit specified on startup with `-m`. To gracefully restart; send a
14+
SIGUSR1 signal to the daemon, and wait for it to shut down and exit.
15+
16+
It will create a `/tmpfs_mount/memory_file.meta` file on shutdown. On restart
17+
it will read this file and ensure the restart is compatible. If it is not
18+
compatible or the file is corrupt, it will start with a clean cache.
19+
20+
If you change some parameters the cache will come up clean:
21+
22+
- The memory limit (`-m`)
23+
- The max item size.
24+
- Slab chunk sizes.
25+
- Whether CAS is enabled or not.
26+
- Whether slab reassignment is allowed or not.
27+
28+
... you are able to change all other options inbetween restarts!
29+
30+
Important Caveats (see below for more detail):
31+
32+
- System clock must be set correctly and must not jump while memcached
33+
is down.
34+
- Deletes, sets, adds, incr/decr/etc commands will be missed while instance
35+
restarts!
36+
- The earliest version you can restart from is 1.5.18. Older versions cannot
37+
upgrade to 1.5.18 without losing the cache.
38+
39+
## DETAILS
40+
41+
This works by putting memory related to item data into an external
42+
mmap file (specified via `-e`). All other memory: the hash table, connection
43+
memory, etc, stay in main RAM. When the daemon is restarted, it runs a pass
44+
over the item data and fixes up the internal pointers and regenerates
45+
the hash table. This typically takes a few seconds, but if you have close to a
46+
billion items in memory it can take two or three minutes.
47+
48+
Once restarted, there is no performance difference between restartable and
49+
non-restartable modes.
50+
51+
### DAX mounts and persistent memory
52+
53+
If you have a persistent memory device, you can utilize this feature to extend
54+
memcached's memory into persistent memory. This does _not_ make
55+
memcached crash safe! It will put item memory into your persistent memory
56+
mount, while the rest of memory (hash table/buffers/etc) use system DRAM. This
57+
is a very high performance mode as the majority of memory accesses stay in DRAM. Also, with a graceful shutdown memcached can be
58+
restarted after reboots so long as the DAX mount persists.
59+
60+
See your persistent memory vendor's documentation for how to configure a DAX
61+
mount.
62+
63+
You can see extensive testing we did in this and other modes on our blog: https://memcached.org/blog/persistent-memory/
64+
65+
### CAVEATS
66+
67+
Your system clock _must_ be set correctly, or at least it must not move before
68+
memcached has restarted. The only way to tell how much time has passed while
69+
the binary was dead, is to check the system clock. If the clock jumps forward
70+
or backwards it could impact items with a specific TTL.
71+
72+
Users must keep in mind that while an instance is stopped, it may be missing
73+
updates from the network; deletes, sets, and so on. It is only safe to restart
74+
memcached if your architecture can handle this by either pausing/buffering
75+
updates, or restarting at a time when no changes are happening to the cache.
76+
77+
### FUTURE WORK
78+
79+
This feature is presently incompatible with extstore. Please let us know if
80+
you have other feedback or requests related to this feature.
81+

content/features/tls.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
+++
2+
title = 'TLS Support'
3+
date = 2024-09-04T13:57:26-07:00
4+
+++
5+
6+
This documentation is incomplete but the TLS support in memcached is stable. See `doc/tls.txt` in the repository for design and some implementation details.
7+
8+
## Quick Start
9+
10+
Memcached 1.5.13+ supports authentication and encryption via TLS. This requires:
11+
- OpenSSL 1.1.1 or later
12+
- Memcached client which can communicate over TLS
13+
- Server built using ./configure --enable-tls.
14+
15+
### When to use this?
16+
17+
- Encryption: data is required to be encrypted on the wire between clients and the server.
18+
- Authentication : server and client are required to authenticate each other.
19+
- Data integrity: ensure data is not tampered or altered when transmitted between client and server.
20+
21+
### How to use it?
22+
23+
Grab the latest memcached.
24+
25+
Build with `./configure --enable-tls && make && make test && sudo make install`
26+
27+
Obtain a valid certificate and a key
28+
29+
Use your normal startup options and add `-Z -o ssl_chain_cert=/home/user/cert,ssl_key=/home/user/key`
30+
31+
`-Z` (or `--enable-ssl`) enables the TLS and `ssl_chain_cert` and `ssl_key` to specify the cert and the key.
32+
33+
If you have trouble starting the server, use verbose levels ('memcached -v') to print errors and warnings.
34+
35+
If there are no errors, all TCP interfaces you’ve specified support TLS.
36+
37+
You can quickly test the server with OpenSSL `s_client`.
38+
39+
`$ openssl s_client -connect host:port`
40+
41+
### Other options
42+
You can obtain all available options using the `memcached -h`
43+
44+
If required, you can specify a different private key format using `-o ssl_keyformat=`. The default format is PEM (1). This value has to be an integer. Refer to OpenSSL certificate formats for more details.
45+
46+
To change the peer certificate verification mode, use `-o ssl_verify_mode=`. Default is 0 (None). Valid values are 0 (None), 1 (Request), 2 (Require) or 3 (Once). Refer OpenSSL verification modes for more details.
47+
48+
To limit supported ciphers, use `-o ssl_ciphers=`. Refer OpenSSL cipher names for valid options.
49+
50+
If required, provide a CA cert using `-o ssl_ca_cert=`. Only PEM file format is accepted.
51+
52+
If you invalidate old server certificates, received new ones and requires memcached to use them, you don’t need to restart the server.
53+
Connect with the server and run the `refresh_certs` command.
54+
Memcached will reload new certificates (cert name and paths has to be same as the original ones) and new connections will use new certificates.
55+
Existing connections will continue to use session keys created using old certificates.
56+
57+
You can opt out TLS for certain interfaces (e.g. use plain text on localhost). This can be specified via `-l` or `--listen=`. Add `notls:` prefix to the interfaces that don’t require TLS.
58+
E.g. `-l notls:<host>:<port>`
59+
60+
### Monitoring
61+
You can increase the verbosity of the server to print detailed error/warning messages.
62+
63+
`stats settings` command will show the current TLS settings, prefixed with `ssl_`.
64+
65+
`stats` will print `time_since_server_cert_refresh`. This shows the number of seconds elapsed since server loaded certificates. This is helpful when you need to refresh certificates.
66+
67+
### How to tune it?
68+
69+
The current TLS implementation splits large messages (more than 16K by default) and send them in chunks.
70+
71+
This limit can be increased via `--o ssl_wbuf_size=` option. The size is in KB and the default is 16KB.
72+
This buffer is allocated at each worker thread level; hence you can calculate the memory budget (in KB) by `ssl_wbuf_size * number of worker threads`.
73+
74+
---
75+
76+
## Performance
77+
78+
`TBD`
79+
80+
---
81+
82+
## Session Resumption
83+
84+
`TODO` see `memcached -h`
85+
86+
---
87+
88+
## Quick notes
89+
90+
See `doc/tls.txt` for design and some implementation details.
91+
See `memcached -h` for start arguments.
92+
Run `./configure --enable-tls` to compile the feature in.
93+

0 commit comments

Comments
 (0)