The minimal architecture becomes some thing like this
Varnish will cache all the request in memory. so what about the statefull requests.
I came up with a VCL script with this architecture:
VCL Script used (its a sample one, production one having ACL and other throttling features):
backend default { .host = "localhost"; # Varnish is running on same server as Apache .port = "8080"; } sub vcl_recv { # remove unnecessary cookies if (req.http.cookie ~ "JSESSIONID") { return (pass); } else { unset req.http.cookie; } } sub vcl_fetch { if (req.http.cookie ~ "JSESSIONID" || req.request == "POST") { return (deliver); } else { # remove all other cookies and prevent backend from setting any unset beresp.http.set-cookie; set beresp.ttl = 600s; } } sub vcl_deliver { # send some handy statistics back, useful for checking cache if (obj.hits > 0) { set resp.http.X-Cache-Action = "HIT"; set resp.http.X-Cache-Hits = obj.hits; } else { set resp.http.X-Cache-Action = "MISS"; } }
Dont forgot to benchmark with YSLOW or Apache Benchmark tool. :D
The real speed depands upon how much memory you are allocating for Varnish... its upto you!
You can customize this for you requirement. Take wordpress VCL template as base reference.
Reference Materials:
Varnish Internals
No comments:
Post a Comment