Varnish Modules - kly.no · Varnish Modules Kristian Lyngstøl Product Specialist Varnish Software...

13

Transcript of Varnish Modules - kly.no · Varnish Modules Kristian Lyngstøl Product Specialist Varnish Software...

Page 1: Varnish Modules - kly.no · Varnish Modules Kristian Lyngstøl Product Specialist Varnish Software AS Paris, March, 2012
Page 2: Varnish Modules - kly.no · Varnish Modules Kristian Lyngstøl Product Specialist Varnish Software AS Paris, March, 2012

Varnish Modules

Kristian LyngstølProduct Specialist

Varnish Software AS

Paris, March, 2012

Page 3: Varnish Modules - kly.no · Varnish Modules Kristian Lyngstøl Product Specialist Varnish Software AS Paris, March, 2012

Config to Code

Policy based configurationVCL

Page 4: Varnish Modules - kly.no · Varnish Modules Kristian Lyngstøl Product Specialist Varnish Software AS Paris, March, 2012

VCL

State engine

Varnish runs VCL

You provide VCL (except the default, Andreas tells me it's appended)

VCL is translated to C

Compiled

Linked

???

Profit

Page 5: Varnish Modules - kly.no · Varnish Modules Kristian Lyngstøl Product Specialist Varnish Software AS Paris, March, 2012

In-line C!

Dear VCL compiler,

This is the sysadmin, I'd like to inform you that the following is already C-code:

C{ here_it_is(); }C

Ta!

Page 6: Varnish Modules - kly.no · Varnish Modules Kristian Lyngstøl Product Specialist Varnish Software AS Paris, March, 2012

In-line C!

Added because it was “free”.

Escape hatch

Not meant to be used....

BUT PEOPLE DO!

(and it's awesome)

Page 7: Varnish Modules - kly.no · Varnish Modules Kristian Lyngstøl Product Specialist Varnish Software AS Paris, March, 2012

Varnish modules

In-line C, except maintainable!

Almost the same “hooks”

Accessed from VCL

Eg:

Import std;

Sub vcl_recv {

Set req.http.x-random = std.random();

}

Page 8: Varnish Modules - kly.no · Varnish Modules Kristian Lyngstøl Product Specialist Varnish Software AS Paris, March, 2012

VMOD examples

NULL-data for synthetic()

Digest vmod, for hmac, md5, sha256, etc...

Redis

Crash handler (or crash initiator? If (req.request == “BOOM”) { crashhandler.crash(); })

Curl-vmod?

Many many more

Page 9: Varnish Modules - kly.no · Varnish Modules Kristian Lyngstøl Product Specialist Varnish Software AS Paris, March, 2012

https://www.varnish-cache.org/vmods

Page 10: Varnish Modules - kly.no · Varnish Modules Kristian Lyngstøl Product Specialist Varnish Software AS Paris, March, 2012

I have no more time to improvise slides!

Page 11: Varnish Modules - kly.no · Varnish Modules Kristian Lyngstøl Product Specialist Varnish Software AS Paris, March, 2012

Here's the kitty, again

Photo by: Sasan Geranmehr (cc-by-sa)

Page 12: Varnish Modules - kly.no · Varnish Modules Kristian Lyngstøl Product Specialist Varnish Software AS Paris, March, 2012

DEMO

Page 13: Varnish Modules - kly.no · Varnish Modules Kristian Lyngstøl Product Specialist Varnish Software AS Paris, March, 2012

Contact information

Kristian Lyngstøl

Product Specialist

[email protected]

@kristianlyng (twitter)

http://www.varnish-software.com