-
Notifications
You must be signed in to change notification settings - Fork 21
VMOD overhead
Carlos Abalde edited this page Apr 20, 2016
·
6 revisions
VCL is a domain-specific language designed to define Varnish request handling and caching policies. VMODs are extensions useful to extend what you can do using VCL; for example, accessing to a key-value database like Redis. However, it's important to understand the implications of using a VMOD, specially how a VMOD can degrade the performance of your caching layer.
@davidfb and me crunched some numbers that may help you understand the impact of integrating queries to a Redis database in your VCL logic. Please, beware this is not a serious benchmark, but it's definitely something you may want to consider.
- Ubuntu Trusty, Intel Core i3-3220 CPU @ 3.30GHz × 4 (64 bits), 7.5GB RAM.
- Varnish Cache 4.1.2 revision 0d7404e (default configuration).
- Redis 3.0.7 (single server & persistence disabled).
- Redis VMOD 829778b.
- Warming up +
ab -n 100000 -c 1 http://192.168.4.104:6081/
# cmds | SET | GET | EVAL |
---|---|---|---|
0 | 0.708 | 0.708 | 0.708 |
1 | 0.776 | 0.776 | 0.812 |
2 | 0.829 | 0.831 | 0.915 |
4 | 0.916 | 0.915 | 1.015 |
8 | 1.093 | 1.088 | 1.310 |
vcl 4.0;
import redis;
backend default {
.host = "127.0.0.1";
.port = "80";
}
sub vcl_init {
new db = redis.db(
location="127.0.0.1:6379",
type=master,
connection_timeout=500,
connection_ttl=0,
command_timeout=0,
max_command_retries=0,
shared_connections=false,
max_connections=1,
password="",
sickness_ttl=0,
max_cluster_hops=0);
}
sub vcl_recv {
return (synth(200, "OK"));
}
sub vcl_synth {
if (req.url == "/stats") {
synthetic(db.stats());
} else {
#db.command("SET");
#db.push("foo");
#db.push("Hello world!");
#db.execute(true);
#db.free();
#db.command("GET");
#db.push("foo");
#db.execute(true);
#db.free();
#db.command("EVAL");
#db.push({"
# redis.call('SET', KEYS[1], ARGV[1]);
# redis.call('EXPIRE', KEYS[1], ARGV[2]);
#"});
#db.push("1");
#db.push("foo");
#db.push(req.xid);
#db.push("1");
#db.execute(true);
#db.free();
synthetic("");
}
return (deliver);
}