it's a raspberry pi

Editorials

 Setups & configurations

anchor life saver

 We got some boring movies

🎥 Cinematique

 Regarding unity3d

🙂 In-game char icons
Externals

 All about pirate games

⚓ Pirates ahoy!

 This is German language

💻 Linux - ubuntusers.de
Windward bathtub
Tasharen Windward Game

 Social news aggregation

🌍 Windward #reddit
Windward intensive

 Official Windward wiki

🛠 Wiki @gamepedia
Front desk clerk

No ads, no trackers,
no web beacons

rum barrel
Something else

 Get the weather widget

🌤 Weather code snippet

 Hotchpotch of weblinks

📖 Yellow pages
Archives
Tag cloud

Rasberry Pi | Varnish web accelerator | RAM cache

for OS Raspbian Stretch Lite & varnishd (varnish-4.0.2 revision bfe7cd1)


Raspberry Pi as host Apache http server Varnish cache Outside world


Varnish cache improves the performance of your existing http server. Sometimes it is called http reverse proxy, which reduces the time it takes to serve contents to the clients. In most cases with a Raspberry Pi, Varnish works well with its defaults. I assume that you already have a Apache http server that is listening on http port 80 on your - even dynamic - private IP address.


Major benefit: by accessing your Varnish cache the lifetime of your SDcard gets extended.


Update apt-get and install Varnish with the following commands


root@raspberry:# apt-get update
root@raspberry:# apt-get install varnish


Varnish default configuration


Varnish Configuration Language VLC


## Alternative 2, Configuration with VCL


root@raspberry:# nano /etc/default/varnish


        ## Alternative 2, Configuration with VCL
        #
        # Listen on port 6081, administration on localhost:6082, and forward to
        # one content server selected by the vcl file, based on the request.
        #
        DAEMON_OPTS="-a :6081 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -S /etc/varnish/secret \
             -s malloc,256m"
        

root@raspberry:# nano /etc/varnish/default.vcl


        # Default backend definition. Set this to point to your content server.
        backend default {
        .host = "127.0.0.1";
        .port = "8080";
        }
        

Reboot your RbPi


root@raspberry:# shutdown -r now



Is Varnish active and functioning


The number associated to cached Mem means the amount of physical memory PiRAM that is being used by cache buffers for your file system. Nothing to do with your Varnish cache. It is just misleading.

At present it has no way to smaller the malloc,256m 256 MB PiRAM cache provided by Varnish. It is just fixed as default value.


root@raspberry:# top


        KiB Mem:   1000216 total,   304628 used,   695588 free,    17180 buffers
        KiB Swap:        0 total,        0 used,        0 free.   179556 cached Mem
        
        PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
        ...
        898 nobody    20   0  285752  86896  84580 S   0.3  8.7   0:06.03 varnishd
        911 varnish+  20   0   86272    732  84368 S   0.3  0.1   0:05.51 varnishncsa
        ...
        

Quit Crtl C


Check the service status Active: active (running)


root@raspberry:# service varnish status


         varnish.service - Varnish http accelerator
        Loaded: loaded (/lib/systemd/system/varnish. ...
        Active: active (running) since Sat 2018-03-1 ...
        Process: 925 ExecStart=/usr/sbin/varnishd -a ...
        malloc,256m (code=exited, status=0/SUCCESS)
        Process: 374 ExecStartPre=/usr/sbin/varnishd ...
        ...
        

The terminal command netstat shows some process if used, not used (closed port) if there is no output.


root@raspberry:# netstat -tulnp


Look for varnishd PID/Program name


        Active Internet connections (only servers)
        ...
        

And by the Varnish statistic tool varnishhist.

Functional if in the upper right corner your own Second-Level-Domain (SLD) name appears.


Raspberry Pi Varnish cache


root@raspberry:# varnishhist


Quit Crtl C


Varnish allows us to use several tools to evaluate & monitor the server by means of statistics.


        varnishtop  ← grouped list with the most usual entries from different logs
        varnishhist ← a histogram that shows the time taken for the requests processing
        varnishstat ← it shows many contents on cache hits, resource consumption, etc
        varnishlog  ← it allows us to see all the requests made to the web backend server
        

Exit Crtl C


Get your Varnish version & revision


root@raspberry:# varnishd -V


14-Mar 2018
Revised 17-Mar 2018

Hafenzoll 2019