Merge pull request #604 from hashicorp/f-log-cache

consul: Use new LogCache to improve write throughput
This commit is contained in:
Armon Dadgar 2015-01-14 15:50:54 -08:00
commit c84643590a
1 changed files with 12 additions and 1 deletions

View File

@ -49,6 +49,10 @@ const (
// Maximum number of cached ACL entries
aclCacheSize = 256
// raftLogCacheSize is the maximum number of logs to cache in-memory.
// This is used to reduce disk I/O for the recently commited entries.
raftLogCacheSize = 512
)
// Server is Consul server which manages the service discovery,
@ -362,6 +366,13 @@ func (s *Server) setupRaft() error {
}
s.raftStore = store
// Wrap the store in a LogCache to improve performance
cacheStore, err := raft.NewLogCache(raftLogCacheSize, store)
if err != nil {
store.Close()
return err
}
// Create the snapshot store
snapshots, err := raft.NewFileSnapshotStore(path, snapshotsRetained, s.config.LogOutput)
if err != nil {
@ -392,7 +403,7 @@ func (s *Server) setupRaft() error {
s.config.RaftConfig.LogOutput = s.config.LogOutput
// Setup the Raft store
s.raft, err = raft.NewRaft(s.config.RaftConfig, s.fsm, store, store,
s.raft, err = raft.NewRaft(s.config.RaftConfig, s.fsm, cacheStore, store,
snapshots, s.raftPeers, trans)
if err != nil {
store.Close()