r4781 - in trunk/varnish-cache/doc/sphinx/tutorial: . vtc_files
phk at varnish-cache.org
phk at varnish-cache.org
Thu May 6 13:21:13 CEST 2010
Author: phk
Date: 2010-05-06 13:21:13 +0200 (Thu, 06 May 2010)
New Revision: 4781
Added:
trunk/varnish-cache/doc/sphinx/tutorial/tut002.rst
trunk/varnish-cache/doc/sphinx/tutorial/vtc_files/C002.vtc
trunk/varnish-cache/doc/sphinx/tutorial/vtc_files/S002.vtc
Modified:
trunk/varnish-cache/doc/sphinx/tutorial/index.rst
Log:
Add the first real example of running varnishd
Modified: trunk/varnish-cache/doc/sphinx/tutorial/index.rst
===================================================================
--- trunk/varnish-cache/doc/sphinx/tutorial/index.rst 2010-05-06 11:04:49 UTC (rev 4780)
+++ trunk/varnish-cache/doc/sphinx/tutorial/index.rst 2010-05-06 11:21:13 UTC (rev 4781)
@@ -11,6 +11,7 @@
intro.rst
tut001.rst
+ tut002.rst
.. todo::
starting varnish with -d, seeing a transaction go through
Added: trunk/varnish-cache/doc/sphinx/tutorial/tut002.rst
===================================================================
--- trunk/varnish-cache/doc/sphinx/tutorial/tut002.rst (rev 0)
+++ trunk/varnish-cache/doc/sphinx/tutorial/tut002.rst 2010-05-06 11:21:13 UTC (rev 4781)
@@ -0,0 +1,92 @@
+.. _TUT002:
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+TUT002: Caching an object with varnish
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+Now it is time to loose your viginity and cache an object with ``varnishd``.
+
+In the first window, start this command::
+
+ varnishd -L20000 -t30
+
+You should see something like this::
+
+ storage_malloc: max size 1 MB.
+ Using old SHMFILE
+ Platform: FreeBSD,9.0-CURRENT,amd64,-smalloc,-hcritbit
+ 200 193
+ -----------------------------
+ Varnish HTTP accelerator CLI.
+ -----------------------------
+ Type 'help' for command list.
+ Type 'quit' to close CLI session.
+ Type 'start' to launch worker process.
+
+We will explain this stuff later, for now just type ``start`` and you should
+see something like::
+
+ child (88590) Started
+ 200 0
+
+ Child (88590) said
+ Child (88590) said Child starts
+
+Next, start a backend in a different window::
+
+ varnishtest -L20000 S002.vtc
+
+And finally, send a request from a third window::
+
+ varnishtest -L20000 -vv C002.vtc
+
+You will notice that both the backend and client windows both do
+their thing, and exit back to the shell prompt.
+
+In the client window you will have a line like::
+
+ **** c1 http[ 6] | X-Varnish: 17443679
+
+This is Varnish telling you that it was involved. (The exact number will
+be different for you, it is just a transaction-id.)
+
+Now, try running *only* the client command again::
+
+ varnishtest -L20000 -vv C002.vtc
+
+Tada! You have just received a cache-hit from varnishd.
+
+This time the ``X-Varnish`` line will have two numbers::
+
+ **** c1 http[ 6] | X-Varnish: 17443680 17443679
+
+The first number is the XID for this request, the second one is the
+XID that brought this object into varnishd's cache, it matches the
+number you saw above.
+
+If you run the client again, you will see::
+
+ **** c1 http[ 6] | X-Varnish: 17443681 17443679
+
+You can keep running the client and you will get hits, but
+30 seconds after the object was put in the cache, ``varnishd``
+will expire it, and then you will get varnish "Guru meditation"
+message, because the backend does not respond::
+
+ **** c1 body| <head>\n
+ **** c1 body| <title>503 Service Unavailable</title>\n
+ **** c1 body| </head>\n
+ **** c1 body| <body>\n
+ **** c1 body| <h1>Error 503 Service Unavailable</h1>\n
+ **** c1 body| <p>Service Unavailable</p>\n
+ **** c1 body| <h3>Guru Meditation:</h3>\n
+ **** c1 body| <p>XID: 1685367940</p>\n
+ **** c1 body| <hr>\n
+
+If you start the backend again:
+
+ varnishtest -L20000 S002.vtc
+
+Then you can fetch the object for another 30 seconds.
+
+
Added: trunk/varnish-cache/doc/sphinx/tutorial/vtc_files/C002.vtc
===================================================================
--- trunk/varnish-cache/doc/sphinx/tutorial/vtc_files/C002.vtc (rev 0)
+++ trunk/varnish-cache/doc/sphinx/tutorial/vtc_files/C002.vtc 2010-05-06 11:21:13 UTC (rev 4781)
@@ -0,0 +1,6 @@
+# $Id$
+
+client c1 {
+ txreq
+ rxresp
+} -run
Added: trunk/varnish-cache/doc/sphinx/tutorial/vtc_files/S002.vtc
===================================================================
--- trunk/varnish-cache/doc/sphinx/tutorial/vtc_files/S002.vtc (rev 0)
+++ trunk/varnish-cache/doc/sphinx/tutorial/vtc_files/S002.vtc 2010-05-06 11:21:13 UTC (rev 4781)
@@ -0,0 +1,6 @@
+# $Id$
+
+server s1 {
+ rxreq
+ txresp -hdr "Foo: bar" -body "Hello World!"
+} -start -wait
More information about the varnish-commit
mailing list