<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-2"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
<font face="Tahoma">Hi Karel,<br>
<br>
you will need some kind of cache invalidation. When you change the
data in CouchDB, your application will have to notify Varnish the
document has changed and should purge it form the cache. Next
request for the same object will fetch the object from CouchDB and
store the new version in Varnish. You do not need ETags for this.
You only need to set correct caching headers that will tell
Varnish to cache the object forever. But you definitely need the
cache invalidation in your app.<br>
<br>
Or, if you don't care Varnish will serve stale version of the
document, you can cache it for some short period without the
invalidation.<br>
<br>
Michal<br>
</font><br>
Dne 6.11.2010 11:18, Karel Minařík napsal(a):
<blockquote
cite="mid:C564B65C-396C-47BF-A78E-2F1B03A5F955@gmail.com"
type="cite">Hello,
<br>
<br>
I've spent the last couple of days trying to figure out how to
accelerate CouchDB [<a class="moz-txt-link-freetext" href="http://couchdb.org/">http://couchdb.org/</a>] with Varnish. I got kinda
lost and would like to ask for some help.
<br>
<br>
CouchDB sends an ETag header in the request:
<br>
<br>
$ curl -I <a class="moz-txt-link-freetext" href="http://localhost:5984/test/abc1">http://localhost:5984/test/abc1</a>
<br>
...
<br>
Etag: "3-6585b511acdd9a73040e673329369ff6"
<br>
Cache-Control: must-revalidate
<br>
<br>
My original thought was that I could use this in Varnish to speed
up responses from Couch, because Varnish could "accumulate"
requests to the backend in certain time frame, and read cached
object from memory, as opposed from disk. (CouchDB view or
CouchDB-Lucene queries send ETag in their responses as well, so
this would work very well accross the whole database.)
<br>
<br>
However, I can't find any definite information about if and how
Varnish uses ETags? Is this a bad/impossible approach in Varnish?
<br>
<br>
In my tests, I got some *huge* speedup (with a default setup) when
querying Couch via Varnish: the mean response time dropped around
half, sometimes more (from ~ 2-3msec to ~0.5-1msec), and the
requests per second went up almost ten times (measured by simple
ApacheBench tests).
<br>
<br>
I couldn't, though, make the cached response to expire by changing
the document in the database and thus changing Etag for its
response. (Which I consider strange given the "must-revalidate"
header?)
<br>
<br>
In the end, I suspect this is because Varnish has some default TTL
(120sec?) and that is what the acceleration is based on. Is that
so? (Again, I couldn't find any definite info about this in docs,
or in the default.vcl.)
<br>
<br>
What would you consider to be the most effective Varnish
configuration for CouchDB? Is time-based caching (eg. setting the
Expires or Last-Modified header) the only option?
<br>
<br>
Thanks for any help in advance!
<br>
<br>
Karel
<br>
<br>
_______________________________________________
<br>
varnish-misc mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.varnish-cache.org/mailman/listinfo/varnish-misc">http://lists.varnish-cache.org/mailman/listinfo/varnish-misc</a>
<br>
<br>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Michal Táborský
chief systems architect
Netretail Holding, B.V.
<a class="moz-txt-link-freetext" href="http://www.nrholding.com">http://www.nrholding.com</a>
</pre>
</body>
</html>