Comments (5)
Hello @sebest,
Currently we don't have this support in mcrouter. Generally, you would want to try to fail-over using some ordering (e.g. lower latency pools first, or some other heuristic that might apply for your scenario).
If you want to share how is your setup (i.e. how you do sets, deletes, etc), we might be able help you further.
Thank you
from mcrouter.
Hello @andreazevedo ,
Thanx for taking the time to answer to me.
I want to achieve something really similar to the replicated pool with the following criteria:
1/ i just need set and get
2/ for the set i want to write on 2 memcache server and only wait for the first successful set
3/ for the get i want the first non-error and try on the second memcache if the first returned a miss
4/ i want to load balance evenly the the number of "get" requests on my two memcache servers
The only criteria that i can't achieve is number 4 as all the "get' go on the first server on the list as he always has the key.
here is my configuration file:
{
"pools": {
"A": {
"servers": ["172.27.132.244:11211","172.27.135.40:11211",]
}
},
"route": {
"type": "OperationSelectorRoute",
"operation_policies": {
"gets": "LatestRoute|Pool|A",
"set": "AllSyncRoute|Pool|A"
}
}
}
thanx
from mcrouter.
Actually you can achieve this by composing RandomRoute and MissFailoverRoute under get
policy (BTW I noticed you have gets
there - is that intentional? gets
and get
are two different operations).
You probably want to re-write your config as having two different pools. Something like:
{
"pools": {
"A": { "servers": ["172.27.132.244:11211"] },
"B": { "servers": ["172.27.135.40:11211"] }
},
"route": {
"type": "OperationSelectorRoute",
"operation_policies": {
"get": {
// Randomize on every request between two children
"type": "RandomRoute",
"children": [
// First option: send to miss failover, which tries A first, then B
{ "type": "MissFailoverRoute", "children": ["PoolRoute|A", "PoolRoute|B"] },
// Second option: same, but try B first, then A
{ "type": "MissFailoverRoute", "children": ["PoolRoute|B", "PoolRoute|A"] }
]
},
"set": { "type": "AllSyncRoute", "children": ["PoolRoute|A", "PoolRoute|B"] }
}
}
}
from mcrouter.
Thanx @alikhtarov , i understand the logic behind your example.
I really need gets as for some reason the golang memcache library is using gets to do get.
Now i just have to figure out how to generate this kind of configuration file using consul-template as if i have a 3rd server, implementing the "shifting" logic in the list of children may not be easy:
a,b,c
b,c,a
c,a,b
from mcrouter.
@sebest you can just have a map of pools in a separate file (pools.json) and then use the following config:
Your config, config.json:
{
"macros": {
"all-pools": {
"type": "constDef",
"result": "@import(pools.json)"
},
// list of routes for each pool [ "PoolRoute|A", "PoolRoute|B", ... ]
"pool-routes": {
"type": "constDef",
"result": {
"type": "foreach",
"from": "@sort(@keys(%all-pools%))",
"use": [ "PoolRoute|%item%" ]
}
},
// number of pools for failover: min(number of pools, 3)
"failover-cnt": {
"type": "constDef",
"result": {
"type": "if",
"condition": "@less(@size(%pool-routes%), @int(3))",
"is_true": "@size(%pool-routes%)",
"is_false": 3
}
},
// at most %failover-cnt% pool routes starting from %shift%
"shiftedPoolRoutes": {
"type": "macroDef",
"params": [ "shift" ],
"result": {
"type": "foreach",
"from": "@range(@int(0), @sub(%failover-cnt%, @int(1)))",
"use": [
"@select(%pool-routes%, @mod(@add(%shift%, %item%), @size(%pool-routes%)))"
]
}
}
},
"pools": "%all-pools%",
"route": {
"type": "OperationSelectorRoute",
"operation_policies": {
"get": {
// Randomize on every request between children
"type": "RandomRoute",
"children": {
"type": "foreach",
"from": "@range(@int(0), @sub(@size(%all-pools%), @int(1)))",
"use": [
{
"type": "MissFailoverRoute",
"children": "@shiftedPoolRoutes(%item%)"
}
]
}
},
"set": { "type": "AllSyncRoute", "children": "%pool-routes%" }
}
}
}
Corresponding pools.json:
{
"A": { "servers": ["172.27.132.244:11211"] },
"B": { "servers": ["172.27.135.40:11211"] }
}
To get config without macros, one can send get __mcrouter__.preprocessed_config
command to mcrouter.
from mcrouter.
Related Issues (20)
- Simple replication model not working as expected HOT 1
- `mg` for WarmupRoute?
- CentOS 8 RPM/Build Support HOT 1
- Cannot build ubuntu20 docker file HOT 5
- Memcached server specification (TLS/SSL) documentation HOT 1
- Error to build docker image with docker file... HOT 1
- Last stable version
- Warmup related configuration incase we are running mcrouter and memcache on kubernetes
- Mcrouter adds MC_MSG_FLAG_BIG_VALUE flag but never removes it HOT 4
- AsyncSocketException: AsyncMcClient, type = Socket not open HOT 1
- unable to build new py3 thrift changes in upstream
- ubuntu 20.04 building issue HOT 1
- Failed to build on Ubuntu 22.04 HOT 1
- Addition of a pre-populated replica
- New Ubuntu package HOT 2
- Failed to build on ubuntu18.04
- How can I traverse a server in the pool? HOT 1
- Issues after memcached version upgrade
- does AllFastestRoute route consider miss as errors?
- folly build error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mcrouter.