Browse Source

remove memcache support

Shared storage for carbonzipper instances need to be completely
rethought.
Damian Gryski 1 year ago
parent
commit
7a887fe0bb
3 changed files with 9 additions and 77 deletions
  1. 1
    5
      cache/cache.go
  2. 6
    27
      main.go
  3. 2
    45
      pathcache/pathcache.go

+ 1
- 5
cache/cache.go View File

@@ -99,13 +99,9 @@ func (m *MemcachedCache) Get(k string) ([]byte, error) {
99 99
 }
100 100
 
101 101
 func (m *MemcachedCache) Set(k string, v []byte, expire int32) {
102
-	go m.SyncSet(k, v, expire)
103
-}
104
-
105
-func (m *MemcachedCache) SyncSet(k string, v []byte, expire int32) {
106 102
 	key := sha1.Sum([]byte(k))
107 103
 	hk := hex.EncodeToString(key[:])
108
-	m.client.Set(&memcache.Item{Key: m.prefix + hk, Value: v, Expiration: expire})
104
+	go m.client.Set(&memcache.Item{Key: m.prefix + hk, Value: v, Expiration: expire})
109 105
 }
110 106
 
111 107
 func (m *MemcachedCache) Timeouts() uint64 {

+ 6
- 27
main.go View File

@@ -60,8 +60,6 @@ var Config = struct {
60 60
 	GraphiteHost         string
61 61
 	InternalMetricPrefix string
62 62
 
63
-	MemcachedServers []string
64
-
65 63
 	MaxIdleConnsPerHost int
66 64
 
67 65
 	ConcurrencyLimitPerServer int
@@ -100,8 +98,6 @@ var Metrics = struct {
100 98
 
101 99
 	Timeouts *expvar.Int
102 100
 
103
-	MemcacheTimeouts expvar.Func
104
-
105 101
 	CacheSize         expvar.Func
106 102
 	CacheItems        expvar.Func
107 103
 	CacheMisses       *expvar.Int
@@ -626,8 +622,8 @@ func main() {
626 622
 	/* Configure zipper */
627 623
 	// set up caches
628 624
 	zipperConfig := &zipper.Config{
629
-		PathCache:   pathcache.NewPathCache(Config.MemcachedServers, Config.ExpireDelaySec),
630
-		SearchCache: pathcache.NewPathCache(Config.MemcachedServers, Config.ExpireDelaySec),
625
+		PathCache:   pathcache.NewPathCache(Config.ExpireDelaySec),
626
+		SearchCache: pathcache.NewPathCache(Config.ExpireDelaySec),
631 627
 
632 628
 		ConcurrencyLimitPerServer: Config.ConcurrencyLimitPerServer,
633 629
 		MaxIdleConnsPerHost:       Config.MaxIdleConnsPerHost,
@@ -653,17 +649,6 @@ func main() {
653 649
 
654 650
 	Config.zipper = zipper.NewZipper(sendStats, zipperConfig)
655 651
 
656
-	if len(Config.MemcachedServers) > 0 {
657
-		logger.Info("memcached configured",
658
-			zap.Strings("servers", Config.MemcachedServers),
659
-		)
660
-
661
-		Metrics.MemcacheTimeouts = expvar.Func(func() interface{} {
662
-			return zipperConfig.PathCache.MCTimeouts() + zipperConfig.SearchCache.MCTimeouts()
663
-		})
664
-		expvar.Publish("memcacheTimeouts", Metrics.MemcacheTimeouts)
665
-	}
666
-
667 652
 	http.HandleFunc("/metrics/find/", httputil.TrackConnections(httputil.TimeHandler(cu.ParseCtx(findHandler), bucketRequestTimes)))
668 653
 	http.HandleFunc("/render/", httputil.TrackConnections(httputil.TimeHandler(cu.ParseCtx(renderHandler), bucketRequestTimes)))
669 654
 	http.HandleFunc("/info/", httputil.TrackConnections(httputil.TimeHandler(cu.ParseCtx(infoHandler), bucketRequestTimes)))
@@ -705,17 +690,11 @@ func main() {
705 690
 			graphite.Register(fmt.Sprintf("%s.%s.requests_in_%dms_to_%dms", prefix, hostname, i*100, (i+1)*100), bucketEntry(i))
706 691
 		}
707 692
 
708
-		if Metrics.CacheSize != nil {
709
-			graphite.Register(fmt.Sprintf("%s.%s.cache_size", prefix, hostname), Metrics.CacheSize)
710
-			graphite.Register(fmt.Sprintf("%s.%s.cache_items", prefix, hostname), Metrics.CacheItems)
711
-
712
-			graphite.Register(fmt.Sprintf("%s.%s.search_cache_size", prefix, hostname), Metrics.SearchCacheSize)
713
-			graphite.Register(fmt.Sprintf("%s.%s.search_cache_items", prefix, hostname), Metrics.SearchCacheItems)
714
-		}
693
+		graphite.Register(fmt.Sprintf("%s.%s.cache_size", prefix, hostname), Metrics.CacheSize)
694
+		graphite.Register(fmt.Sprintf("%s.%s.cache_items", prefix, hostname), Metrics.CacheItems)
715 695
 
716
-		if Metrics.MemcacheTimeouts != nil {
717
-			graphite.Register(fmt.Sprintf("%s.%s.memcache_timeouts", prefix, hostname), Metrics.MemcacheTimeouts)
718
-		}
696
+		graphite.Register(fmt.Sprintf("%s.%s.search_cache_size", prefix, hostname), Metrics.SearchCacheSize)
697
+		graphite.Register(fmt.Sprintf("%s.%s.search_cache_items", prefix, hostname), Metrics.SearchCacheItems)
719 698
 
720 699
 		graphite.Register(fmt.Sprintf("%s.%s.cache_hits", prefix, hostname), Metrics.CacheHits)
721 700
 		graphite.Register(fmt.Sprintf("%s.%s.cache_misses", prefix, hostname), Metrics.CacheMisses)

+ 2
- 45
pathcache/pathcache.go View File

@@ -2,8 +2,6 @@ package pathcache
2 2
 
3 3
 import (
4 4
 	"github.com/dgryski/go-expirecache"
5
-	"github.com/go-graphite/carbonzipper/cache"
6
-	"github.com/go-graphite/carbonzipper/internal/ipb3"
7 5
 
8 6
 	"time"
9 7
 )
@@ -15,13 +13,11 @@ type pathKV struct {
15 13
 
16 14
 type PathCache struct {
17 15
 	ec *expirecache.Cache
18
-	mc *cache.MemcachedCache
19
-	q  chan pathKV
20 16
 
21 17
 	expireDelaySec int32
22 18
 }
23 19
 
24
-func NewPathCache(servers []string, ExpireDelaySec int32) PathCache {
20
+func NewPathCache(ExpireDelaySec int32) PathCache {
25 21
 
26 22
 	p := PathCache{
27 23
 		ec:             expirecache.New(0),
@@ -30,18 +26,6 @@ func NewPathCache(servers []string, ExpireDelaySec int32) PathCache {
30 26
 
31 27
 	go p.ec.ApproximateCleaner(10 * time.Second)
32 28
 
33
-	if len(servers) > 0 {
34
-		p.q = make(chan pathKV, 1000)
35
-		p.mc = cache.NewMemcached("czip", servers...).(*cache.MemcachedCache)
36
-
37
-		go func() {
38
-			for kv := range p.q {
39
-				var b, _ = (&ipb3.PathCacheEntry{Hosts: kv.v}).Marshal()
40
-				p.mc.SyncSet(kv.k, b, p.expireDelaySec)
41
-			}
42
-		}()
43
-	}
44
-
45 29
 	return p
46 30
 }
47 31
 
@@ -53,10 +37,6 @@ func (p *PathCache) ECSize() uint64 {
53 37
 	return p.ec.Size()
54 38
 }
55 39
 
56
-func (p *PathCache) MCTimeouts() uint64 {
57
-	return p.mc.Timeouts()
58
-}
59
-
60 40
 func (p *PathCache) Set(k string, v []string) {
61 41
 
62 42
 	var size uint64
@@ -65,11 +45,6 @@ func (p *PathCache) Set(k string, v []string) {
65 45
 	}
66 46
 
67 47
 	p.ec.Set(k, v, size, p.expireDelaySec)
68
-
69
-	select {
70
-	case p.q <- pathKV{k: k, v: v}:
71
-	default:
72
-	}
73 48
 }
74 49
 
75 50
 func (p *PathCache) Get(k string) ([]string, bool) {
@@ -77,23 +52,5 @@ func (p *PathCache) Get(k string) ([]string, bool) {
77 52
 		return v.([]string), true
78 53
 	}
79 54
 
80
-	if p.mc == nil {
81
-		return nil, false
82
-	}
83
-
84
-	// check second-level bytes cache
85
-	b, err := p.mc.Get(k)
86
-	if err != nil {
87
-		return nil, false
88
-	}
89
-
90
-	var v ipb3.PathCacheEntry
91
-
92
-	err = v.Unmarshal(b)
93
-
94
-	if err != nil {
95
-		return nil, false
96
-	}
97
-
98
-	return v.Hosts, true
55
+	return nil, false
99 56
 }