Reg: global variable in vcl

Nils Goroll slink at
Fri May 17 14:29:54 UTC 2019


On 17/05/2019 10:16, Hardik wrote:
> what is difference between below this ?
> and 

I would like to add to Geoff's response:

* Conceptual differences between the vmods:

  while the var vmod uses strings to identify variables, the objvar vmods use
  objects. The main difference is that objects need to be declared in vcl_init,
  which can be an advantage for code clarity, but does not allow for runtime

  Also, object access should be somewhat faster and scale better.

* with respect to global variables and types:

  On 17/05/2019 13:09, Geoff Simmons wrote:
  > VMOD var supports global variables for the STRING, INT and REAL types,

  not that I would be aware, to my knowledge the var vmod only supports
  STRING for global variables.

  vmod globalvar from the objvar project support virtually all types.

In general, to achieve consistent concurrent access to global variables, the var
vmod copies the global variable string value to each caller's workspace.

The globalvar vmod uses refcounting to avoid copying. Other than for short
strings, it should thus use less workspace than the "var" vmod and be more
efficient and scalable. (refcounting will most definitely use less workspace for
multiple read access within the same task).

And once I am at it:

> -I am not able to get any information about this vmod on internet. Means not
> used much ?

It is comparably new (initially released 27 October 2018) and also we at UPLEX
are probably not particularly good with marketing, so vmod var will probably be
more widely used simply for existing _much_ longer and being mentioned more often.

The objvar bundle is being used (and sponsored by) some very high traffic sites
and, as mentioned before, was written for optimal flexibility, scalability and


More information about the varnish-misc mailing list