look out honey 'cause I'm using technology

Allow Varnish to reuse its shared object

Varnish logoBACKGROUND:  The following is a proposal I submitted to the Varnish developers in order to make it simpler to integrate Varnish (an HTTP accelerator for web sites) into production environments.  fak3r uses Varnish in front of its webserver, Lighttpd, so it’s likely that the page you’re now reading was served to you not by the webserver, but via Varnish.

Currently Varnish requires a C compiler to be present on the machine it’s running on, since it needs to compile the VCL config file into a shared object each time it starts. During shutdown, Varnish removes this shared object since it will be rebuilt during the next start. This routine repeats regardless of if anything has changed in the VCL config file, and serves as a road bump to getting Varnish into certain production environments since traditionally development applications (such as the C compiler) are not allowed in such instances. For now I am putting aside the arguments as to why it’s is acceptable to have development applications in production instances, since that argument’s outcome will vary in different situations, and I am aiming for a solution that will cover all instances.

My proposal is to allow Varnish to reuse its shared object, instead creating it during on launch, and destroying it on shutdown. The reuse function would be called if a flag was present during startup, either on the command line as -r, or as defined in the DAEMON_OPTS variable. This would cause Varnish to do two things differently than it does now:

  • upon startup it would not create a new shared object, rather it would search for, and use, the first shared object it found in the following location: /var/lib/varnish/`hostname`/bin.*
  • when called to shutdown, Varnish would not remove the existing shared object, thus leaving it to be reused, if called again with the -r flag

The shared object would need to be created (and recreated after any changes to the VCL file) on a clone machine that has a C compiler, and then installed to the production machine during a change window, which would be no different from a normal config file change. The upside of this would be that the C compiler requirement would be conditional upon the use of the reuse flag, which would allow smoother integration of Varnish into production environments.



Related posts

    
  • @pejman just saw yr reply, sorry, I have the link in the post above, it's Varnish
  • pejman
    HI,thanks for help, I need some information about varnish(what is it?how it work?and...) or a website that explain varnish.thank you very much
  • @pejman
    Sure, there are packages for Red Hat available, follow this link:
    http://varnish.projects.linpro.no/wiki/VarnishO...

    After that, check out the default config in /etc/varnish/default.vcl - select the port you want run it on (80) and the port your webserver will run on - change your webserver to run on that different port, launch both, then run varnishlog to see the action in varnish, and finally surf and check out the results in the logs.
  • pejman
    HI, I want to install varnish on redhat linux,please help me
  • Hey, glad you liked the post, it was more to mirror my idea to the Varnish devs, I was going to write a howto, but it's really easy.

    > 1. Which distro/OS gives me the best performance & stability?
    > I am thinking about using Ubuntu.

    Varnish is developed to work with the features of FreeBSD 6.x and Linux 2.6 - so any current Linux would be fine. I run it on Debian at home, so Ubuntu will be identical.

    > 2. Is varnish sitting in-path in reg. of cabling?

    I have it on the same server, just running on :80 and pointing to the other port for the 'real' webserver. If you are just running it on server, it's even easier. Is it in-path? Not sure what you're asking, see the next question for the layout.

    3. Can I cable like this: webserver-varnish-firewall-router?

    Internet
    |
    Firewall
    |
    Varnish
    |
    Webserver

    > 4. How do I set up IP addresses for this setup?

    If you're just running on a separate server, just give it whatever IP you are running on your internal private network; only thing to do is have any www requests port :80, be directed to your Varnish server by your Firewall/Router instead of your webserver.

    > 5. Should do a vanilla/default install or is there more config to do?

    To get started, very little config to do, there's two things you need to change after install:

    edit /etc/default/varnish

    change:
    VARNISH_LISTEN_PORT=6081

    to:
    VARNISH_LISTEN_PORT=80

    edit /etc/varnish/vcl.conf

    backend default {
    set backend.host = "127.0.0.1";
    set backend.port = "80";
    }

    Just change the set backend.host line to your webserver's IP - so if it was 192.168.1.10

    set backend.host = "192.168.1.10";

    > I mean, as far as I understad, this varnish http-accelerator
    > can be installed on a standalone box so it doesn’t need
    > to change anything on the web server it is accelerating
    > the connection to.

    Yep, that's right, just have Varnish handle the web requests before the webserver, and you're set.

    One thing, instead of installing the version Debian/Ubuntu has in the repos (something like 1.0.x) download the latest (1.1.1) from here:
    http://sourceforge.net/project/showfiles.php?gr...

    Grab the libvarnish and varnish debs and install those. Give me a shout if you have any other questions for install, I've been running it at work on a few Red Hat Enterprise servers (not a fan of that distro though...) and it's been amazing.

    While you're at it, feel free to checkout another (simplified) article I wrote about Varnish for Tech Republic, the graph should tell you about its performance:
    http://phil.cryer.us/articles/varnish.html
  • Stian Maurstad
    Hi!

    I want to try out varnish first as a test, then later maybe in
    production as a front end to our Siebel web application which is way
    to slow. What I am not sure of is how to implement it physically, cabling wise and how to setup ip adr. etc. Would have been great if this could have been better explained.

    Here are some questions that I would be glad to have answered:
    1. Which distro/OS gives me the best performance & stability?
    I am thinking about using Ubuntu.
    2. Is varnish sitting in-path in reg. of cabling?
    3. Can I cable like this: webserver-varnish-firewall-router?
    4. How do I set up IP addresses for this setup?
    5. Should do a vanilla/default install or is there more config to do?

    I mean, as far as I understad, this varnish http-accelerator can be installed on a standalone box so it doesn't need to change anything on the web server it is accelerating the connection to.

    Best regards: Stian Maurstad
blog comments powered by Disqus

We like








We support


EFF - Electronic Frontier Foundation       TOR - The Onion Router       HRC - Human Rights Campaign