Browse Source

feat(*): enable snapshots by default

Ben recently added test coverage for snapshots so we should enable it in
etcd. Lets do this.

https://github.com/goraft/raft/commit/1d66f6a111793e66877d4ce8427c2e2e6b9e29df
Brandon Philips 12 years ago
parent
commit
7ee7e910eb
4 changed files with 24 additions and 22 deletions
  1. 1 1
      Documentation/configuration.md
  2. 21 20
      Documentation/tuning.md
  3. 1 0
      server/config.go
  4. 1 1
      server/usage.go

+ 1 - 1
Documentation/configuration.md

@@ -37,7 +37,7 @@ configuration files.
 * `-peer-ca-file` - The path of the CAFile. Enables client/peer cert authentication when present.
 * `-peer-cert-file` - The cert file of the server.
 * `-peer-key-file` - The key file of the server.
-* `-snapshot` - Open or close snapshot. Defaults to `false`.
+* `-snapshot=false` - Disable log snapshots. Defaults to `true`.
 * `-v` - Enable verbose logging. Defaults to `false`.
 * `-vv` - Enable very verbose logging. Defaults to `false`.
 * `-version` - Print the version and exit.

+ 21 - 20
Documentation/tuning.md

@@ -47,46 +47,47 @@ election_timeout = 100
 The values are specified in milliseconds.
 
 
-### Enabling Snapshots
+### Snapshots
 
-By default, the Raft protocol appends all etcd changes to a log file.
-This works well for smaller installations but etcd clusters that are heavily used can see the log grow significantly in size.
+etcd appends all key changes to a log file.
+This log grows forever and is a complete linear history of every change made to the keys.
+A complete history works well for lightly used clusters but clusters that are heavily used would carry around a large log.
 
-Snapshots provide a way for etcd to compact the log by saving the current state of the system and removing old logs.
-You can enable snapshotting by adding the following to your command line:
+To avoid having a huge log etcd makes periodic snapshots.
+These snapshots provide a way for etcd to compact the log by saving the current state of the system and removing old logs.
+
+### Snapshot Tuning
+
+Creating snapshots can be expensive so they're only created after a given number of changes to etcd.
+By default, snapshots will be made after every 10,000 changes.
+If etcd's memory usage and disk usage are too high, you can lower the snapshot threshold by setting the following on the command line:
 
 ```sh
 # Command line arguments:
-$ etcd -snapshot
+$ etcd -snapshot-count=5000
 
 # Environment variables:
-$ ETCD_SNAPSHOT=true etcd
+$ ETCD_SNAPSHOT_COUNT=5000 etcd
 ```
 
-You can also enable snapshotting within the configuration file:
+Or you can change the setting in the configuration file:
 
 ```toml
-snapshot = true
+snapshot_count = 5000
 ```
 
-
-### Additional Snapshot Tuning
-
-Creating snapshots can be expensive so they're only created after a given number of changes to etcd.
-By default, snapshots will be made after every 10,000 changes.
-If etcd's memory usage and disk usage are too high, you can lower the snapshot threshold by setting the following on the command line:
+You can also disable snapshotting by adding the following to your command line:
 
 ```sh
 # Command line arguments:
-$ etcd -snapshot -snapshot-count=5000
+$ etcd -snapshot false
 
 # Environment variables:
-$ ETCD_SNAPSHOT=true ETCD_SNAPSHOT_COUNT=5000 etcd
+$ ETCD_SNAPSHOT=false etcd
 ```
 
-Or you can change the setting in the configuration file:
+You can also enable snapshotting within the configuration file:
 
 ```toml
-snapshot = true
-snapshot_count = 5000
+snapshot = false
 ```

+ 1 - 0
server/config.go

@@ -89,6 +89,7 @@ func NewConfig() *Config {
 	c.MaxClusterSize = 9
 	c.MaxResultBuffer = 1024
 	c.MaxRetryAttempts = 3
+	c.Snapshot = true
 	c.SnapshotCount = 10000
 	c.Peer.Addr = "127.0.0.1:7001"
 	c.Peer.HeartbeatTimeout = defaultHeartbeatTimeout

+ 1 - 1
server/usage.go

@@ -52,7 +52,7 @@ Other Options:
   -max-result-buffer   Max size of the result buffer.
   -max-retry-attempts  Number of times a node will try to join a cluster.
   -max-cluster-size    Maximum number of nodes in the cluster.
-  -snapshot            Open or close the snapshot.
+  -snapshot=false      Disable log snapshots
   -snapshot-count      Number of transactions before issuing a snapshot.
 `