This is the ninth day of my participation in the August More text Challenge. For details, see: August More Text Challenge

The introduction of varnish

The concept of Baidu Encyclopedia:

Varnish is a high performance open source HTTP accelerator. Verdens Gang (www.vg.no), Norway’s largest online newspaper, uses 3 Varnish instead of 12 squid and is even better than before.

Varnish author Poul-Henning Kamp, one of the developers of the FreeBSD kernel, says computers are much more complex today than they were in 1975. In 1975, there were only two types of storage: memory and hard disks. But today, in addition to main memory, computer systems also include L1, L2, and even L3 cache in the CPU. Hard disks also have their own caching devices, so squid Cache’s own architecture for object replacement would not be able to optimize for these things, but the operating system would know, so it should be the operating system that handles this part of the work. That’s the Varnish Cache architecture.

The varnish project was the first version 0.9 released in 2006. It has been more than eight years since this document mentioned that Varnish was not stable yet. That was written in 2007, and with the hard work of varnish development team and netizens, varnish is now very robust. A number of portals have deployed Varnish and it behaves very well, even more robustthan SQUID, and is more efficient and consumes less resources. It is believed that Varnish has enough power to replace SQUID in reverse proxy, web acceleration.

Ports and official Website

Varnish listens on port 3128 of 6081 SQUID

Varnish: Varnish official document -6.3

Varnish features:

Compared with the squids

1) Cache mode: Varnish can be cached in memory or on disk. Virtual memory cache can be used. The precise cache time can be set from 0-60s. Squid caches metadata in memory and storage in hard disk

2) ACL Varnish configuration is done in VAL language. The configuration must be converted to C code first, so the configuration written in VCL must be converted to C code first. Therefore, it is dependent on GCC to temporarily compile the VCL configuration

How Varnish caches data

The installation of the varnish

1. Install dependency packages

yum install autoconf.noarch automake.noarch jemalloc-devel.x86_64 libedit-devel.x86_64 libtool.x86_64 ncurses-devel.x86_64 pcre-devel.x86_64 pkgconfig.x86_64 python-docutils.noarch python-sphinx.noarch graphviz.x86_64 -y

Copy the code

2. Upload the installation package and decompress it

[root @ xinsz08-62 desktop]# lsNethogs 0.8.5-1. El7. X86_64. RPM varnish - 6.2.3. TGZCopy the code

Use file to view files

[root @ xinsz08-62 desktop]# file varnish - 6.2.3. TGZVarn-6.2.3. TGZ: gzip compressed data, from Unix, last Modified: Fri Jan 31 20:18:02 2020, Max compressionCopy the code

[root@xinsz08-62 ~]# file varnish - 6.2.3. TGZVarnish -6.2.3. TGZ: Gzip compressed Data, from Unix, last Modified: Fri Jan 31 20:18:02 2020, max compression [root@xinsz08-62 ~]# gunzip varnish - 6.2.3. TGZ
[root@xinsz08-62 ~]# ls     Varnish - 6.2.3. TarCopy the code

Extract:

[root@xinsz08-62 ~]# tar xf varnish - 6.2.3. Tar
[root@xinsz08-62 ~]# lsVarnish - 6.2.3 varnish - 6.2.3. TarCopy the code

3. Go to the directory and compile the installation

[root@xinsz08-62 ~]# CD varnish - 6.2.3 /[root @ xinsz08-62 varnish - 6.2.3]# lsaclocal.m4 configure lib README.Packaging autogen.sh configure.ac LICENSE README.rst bin doc m4 varnishapi.pc.in build-aux etc Makefile.am varnishapi-uninstalled.pc.in ChangeLog include Makefile.in varnish-legacy.m4 config.h.in INSTALL man varnish. M4 [root@xinsz08-62 Varnish -6.2.3]# 

Copy the code

Compile the installation

[root @ xinsz08-62 varnish - 6.2.3]# ./autogen.sh [root @ xinsz08-62 varnish - 6.2.3]# ./configure && make && make install [root @ xinsz08-62 varnish - 6.2.3]# ldconfig
Copy the code

Note: the ldconfig

The ldconfig command is used to: In the default search directories /lib and /usr/lib and the directories listed in the dynamic library configuration file /etc/ld.so.conf, search for shareable dynamic link libraries (such as lib*.so*) to create the connection and cache files required by the dynamic loader (ld.so).

The default cache file is /etc/ld.so.cache, which contains the sorted names of dynamic link libraries. To make the dynamic link libraries shared by the system, you need to run the command ldconfig to manage the dynamic link libraries, and the execution program is stored in the /sbin directory.

In short: ldconfig is a dynamic link library management command that is designed to make the dynamic link library shared by the system and needs to be run manually when a user installs a new dynamic link library.

4. Check the version and startup

[root @ xinsz08-62 varnish - 6.2.3]# varnishd -V84 d239c93e756ae255b6abb459c1052a36a409e9 varnishd (varnish - 6.2.3 revision) Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2019 Varnish Software AS Launch [root@xinsz08-62 Varnish -6.2.3]# varnishd -a :6081 -T localhost:6802 -b localhost:8080
# 
[root@xinsz08-62 ~]# ps -ef |grep varnishroot 39814 1 0 11:35 ? 00:00:00 varnishd -a :6081 -T localhost:6082 -b localhost:8080 root 39825 39814 0 11:35 ? 00:00:00 varnishd -a :6081 -T localhost:6082 -b localhost:8080 root 43050 41288 0 12:05 pts/5 00:00:00 grep --color=auto  varnishCopy the code

conclusion

Varnish is introduced to you here, in the company is used more or varnish, suggest follow the experiment to do again.