Skip to content

Commit

Permalink
Better control variance docs
Browse files Browse the repository at this point in the history
  • Loading branch information
maddyblue committed Jan 26, 2014
1 parent 13e2dba commit c7d20ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
33 changes: 8 additions & 25 deletions doc.go
Expand Up @@ -71,7 +71,7 @@ Per-request, in-memory cache: fetch the same key twice, the second request is se
Intelligent multi support: running GetMulti correctly fetches from memory, then memcache, then the datastore; each tier only sends keys off to the next one if they were missing.
Memcache variance: Goon limits the length of the memcache requests to minimize outliers
Memcache control variance: long memcache requests are cancelled.
Transactions use a separate context, but locally cache any results on success.
Expand Down Expand Up @@ -125,31 +125,14 @@ goon:
g := &Group{Id: 1}
err := n.Get(g)
Memcache variance:
Put:
MemcachePutTimeoutThreshold is the number of bytes at which the memcache timeout uses the large setting.
MemcachePutTimeoutSmall is the amount of time to wait during memcache Put operations before aborting them and using the datastore.
MemcachePutTimeoutLarge is the amount of time to wait for large memcache Put requests.
Memcache Control Variance
Get:
MemcacheGetTimeout is the amount of time to wait for all memcache Get requests
Memcache is generally fast. When it is slow, goon will timeout the memcache
requests and proceed to use the datastore directly. The memcache put and
get timeout variables determine how long to wait for various kinds of
requests. The default settings were determined experimentally and should
provide reasonable defaults for most applications.
Notes:
The default settings are in effect and used by goon but if you are seeing too many memcache timeout errors in your logs, you may want to bump up the times.
Conversely, if you're using github.com/mjibson/appstats and are seeing Memcache requests finishing routinely before the default values you can bump them down.
Finally, if these are not good default values as thought, please open an issue.
To change defaults:
package myapp
import (
"github.com/mjibson/goon"
"time"
)
func init() {
goon.MemcachePutTimeoutThreshold = 1024 * 50 // 50k
goon.MemcachePutTimeoutSmall = time.Millisecond * 10
}
See: http://talks.golang.org/2013/highperf.slide#23
*/
package goon
7 changes: 4 additions & 3 deletions goon.go
Expand Up @@ -31,18 +31,19 @@ import (
var (
// LogErrors issues appengine.Context.Errorf on any error.
LogErrors = true

// MemcachePutTimeoutThreshold is the number of bytes at which the memcache
// timeout uses the large setting.
MemcachePutTimeoutThreshold = 1024 * 50 // 50K bytes
MemcachePutTimeoutThreshold = 1024 * 50
// MemcachePutTimeoutSmall is the amount of time to wait during memcache
// Put operations before aborting them and using the datastore.
MemcachePutTimeoutSmall = time.Millisecond * 5
// MemcachePutTimeoutLarge is the amount of time to wait for large memcache
// Put requests.
MemcachePutTimeoutLarge = time.Millisecond * 15
// MemcacheGetTimeout is the amount of time to wait for all memcache Get
// requests
MemcacheGetTimeout = time.Millisecond * 10 // the Duration that we'll wait for memcache.Get
// requests.
MemcacheGetTimeout = time.Millisecond * 10
)

// Goon holds the app engine context and the request memory cache.
Expand Down

0 comments on commit c7d20ac

Please sign in to comment.