In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to understand varnish. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Varnishi consists of management (main process) and (child/cache) child processes varnishi consists of management (main process) and (child/cache) child processes management work: 1. Provide command line interface 2, monitor and manage child processes The work of initializing varnish 3, compiling default.vcl to binary to generate a new configuration file child/cache: 1, receiving connection requests 2, processing user requests 3, clearing expired objects in cache 4, logging 5, Generate cache policy VCL: 1 according to default.vcl, configure interface 2 for cache policy, and store cache object based on "domain" configuration: flie: a single file for storage Do not support persistence, will produce a large number of disk iUnix o have a certain impact on performance malloc: memory storage, higher performance, higher cost (memory is more expensive than disk), long-term use will produce memory fragments persistent: a single file for storage, support persistence Currently use varnish installation as a test: centos7 environment 1, configure epel source 2, Yum-y install varnish varnish configuration: / etc/varnish/default.vcl # vcl configuration file / etc/varnish/varnish.params # command line parameter configuration file / etc/varnish/secret # connection command line authentication file varnish manager With: systemctl start varnish.service # start varnish varnish default snooping *: 6081 and 127.0.0.1 6082 6081 provision of services 6082 provides management varnishadm # Interactive Command Line Management tool varnishlog # Interactive log acquisition tool varnishncsa # Interactive log acquisition tool (apache format) varnishstat # display status varnishtop # sort varnish.params details: VARNISH_VCL_CONF=/etc/varnish/default.vcl # specify vcl file location VARNISH_LISTEN_PORT=6081 # specify service port Default listens on all addresses VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1 # Management ip VARNISH_ADMIN_LISTEN_PORT=6082 # listening Port VARNISH_SECRET_FILE=/etc/varnish/secret # Authentication File VARNISH_STORAGE= "file,/var/lib/varnish/varnish_storage.bin 1G "# cache mode (single file cache) # VARNISH_STORAGE=" malloc,256M "# cache mode (memory cache) Cannot start VARNISH_USER=varnish # program user VARNISH_GROUP=varnish # program group # DAEMON_OPTS= "- p thread_pool_min=5-p thread_pool_max=500-p thread_pool_timeout=300" # process pool configuration varnish status engine details: status The state engine is used to judge client requests and process them accordingly. Vcl_recv: receive user requests Determine how to handle vcl_pass: bypass the cache, do not query the contents from the cache, and pass the request directly to the backend host vcl_pipe: unable to resolve the request type, directly submit it to the backend for processing vcl_hash: cacheable data Process through hash vcl_hit: cache hit vcl_deliver: return cache data to client vcl_miss: cache miss vcl_fetch: get content from backend host, put content into cache or Return directly to the client vcl_error: if an error occurs in the request The error page built by varnishi is returned to the client varnish load balancing cluster algorithm: random # random round-robin # polling fallback # backup hash # fixed backend Configuration example: vcl 4.0 # varnish version probe cache {# defines health check function .url = "/ index.html"; # check url .timeout = 1s; # timeout = 5s; # retry interval .window = 5; # number of retries .threshold = 3 # if the server is online after three successful retries, backend www1 {# defines the backend host .host = "192.168.0.10"; # backend host .port = "80"; # listening port .probe = cache # call the health check function} backend www2 {.host = "192.168.0.40"; .port = "80"; .probe = cache;} backend www3 {.host = "192.168.0.70"; .port = "80"; .probe = cache;} import directors # Import cluster module sub vcl_init {new www = directors.round_robin (); # use polling algorithm www.add_backend (www1); # cluster host www.add_backend (www2); # cluster host www.add_backend (www3) # Cluster Host} sub vcl_recv {set req.backend_hint = www.backend () # send all traffic to www cluster} so much about how to understand varnish. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 285
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.