LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-23-2017, 01:53 PM   #1
redssr
Member
 
Registered: Oct 2013
Location: Dist Nasik MH State Country India
Distribution: Linux
Posts: 106

Rep: Reputation: Disabled
Varnish not using configured malloc memory


Hello,

Experts,

I have one powerful dedicated server with 12 cores CPU and 64GB RAM. I had installed Cpanel with Varnish over easyaapache4

I had configured Varnish to use varnish storage as 40G. but when i hits the top command it shows only 20-25% memory used by varnish all the time. It wont goes beyond it. Is the output of top command is expected as below or i am missing something.

Here are the details below.
Varnish version

Code:
[root@server ~]# rpm -qa|grep varnish
xvarnish-vmods-0.34.4-1.el6.x86_64
xvarnish-repository-1-8.el6.x86_64
varnish-release-4.1-2.el6.noarch
varnish-4.1.6-1.el6.x86_64
xvarnish-0.34.4-1.el6.x86_64
Varnish config file
Code:
[root@server ~]# cat /etc/sysconfig/varnish
# This file is managed by xVarnish and frequently modified without warning and
# without preserving any local changes. We're open to ideas and will do our best
# to help with any problem. Contact us at www.xvarnish.com or help@xvarnish.com.
#
# See `xvctl config --help` for instructions on updating these values.
#
# This environmental configuration file is used by /etc/init.d/varnish

RELOAD_VCL=1
NFILES=131072
MEMLOCK=82000
NPROCS="unlimited"
# DAEMON_COREFILE_LIMIT="unlimited"
VARNISH_VCL_CONF=/etc/varnish.conf.d/default.vcl
VARNISH_LISTEN_ADDRESS=""
VARNISH_LISTEN_PORT=80
VARNISH_PROXY_LISTEN_ADDRESS=127.0.0.1
VARNISH_PROXY_LISTEN_PORT=6086
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
VARNISH_ADMIN_LISTEN_PORT=6082
VARNISH_SECRET_FILE=/usr/local/xvarnish/var/.secret
VARNISH_STORAGE="-s malloc,40G"
VARNISH_USER=varnish
VARNISH_GROUP=varnish
VARNISH_IDENTITY=576001
DAEMON_OPTS="-f $VARNISH_VCL_CONF \
         -a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
         -a ${VARNISH_PROXY_LISTEN_ADDRESS}:${VARNISH_PROXY_LISTEN_PORT},PROXY \
         -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
         -S $VARNISH_SECRET_FILE -i ${VARNISH_IDENTITY:-0} \
         $VARNISH_STORAGE \
             -p http_max_hdr=128 \
             -p pipe_timeout=600 \
             -p send_timeout=900 \
             -p thread_pool_max=1000 \
             -p thread_pool_min=200 \
             -p timeout_idle=90 \
             -p workspace_backend=524288 \
             -p workspace_client=524288"
OS details
Code:
[root@server ~]# cat /etc/*release
CentOS release 6.8 (Final)
CentOS release 6.8 (Final)
CentOS release 6.8 (Final)
my default_vcl file
Code:
[root@server ~]# cat /etc/varnish.conf.d/default.vcl 
# This file is managed by xVarnish and frequently modified without warning and
# without preserving any local changes. We're open to ideas and will do our best
# to help with any problem. Contact us at www.xvarnish.com or help@xvarnish.com.
#
# You may include custom local VCL configuration alongside xVarnish by editing
# the local custom VCL files in directory: /etc/varnish.conf.d/local
#
# If there is a change necessary, you may prevent an overwrite by setting the
# immutable attribute (chattr +i FILE). It's recommended to stop xvhealth if
# you use this technique. Note this will disrupt xVarnish operation, and you
# should remove the immutable attribute before an upgrade (chattr -i FILE).
# Updated by xVarnish 0.34.4 (Build 1), 2017-05-01 01:56:52 EDT

vcl 4.0;
import std;
import header;

include "/usr/local/xvarnish/varnish.conf.d/local/default_pre.vcl";
include "/usr/local/xvarnish/varnish.conf.d/vmod_import.vcl";
include "/usr/local/xvarnish/varnish.conf.d/backends.vcl";
include "/usr/local/xvarnish/varnish.conf.d/acl_purge.vcl";
include "/usr/local/xvarnish/varnish.conf.d/acl_cloudflare.vcl";
include "/usr/local/xvarnish/varnish.conf.d/acl_incapsula.vcl";

sub vcl_init {
    include "/usr/local/xvarnish/varnish.conf.d/local/vcl_init.vcl";
}

sub vcl_fini {
    include "/usr/local/xvarnish/varnish.conf.d/local/vcl_fini.vcl";
}

sub vcl_recv {
    std.log("SERVER_IP: " + server.ip);
    unset req.http.proxy;
    
    call xv_add_real_ip;
    call xv_add_object_type;
    
    include "/usr/local/xvarnish/varnish.conf.d/routes.vcl";
    include "/usr/local/xvarnish/varnish.conf.d/local/vcl_recv_pre_management.vcl";
    include "/usr/local/xvarnish/varnish.conf.d/management.vcl";
    include "/usr/local/xvarnish/varnish.conf.d/patterns.vcl";
    include "/usr/local/xvarnish/varnish.conf.d/local/vcl_recv_pre.vcl";
    
    include "/usr/local/xvarnish/varnish.conf.d/vmod_include.vcl";
    include "/usr/local/xvarnish/varnish.conf.d/local/vcl_recv.vcl";
    
    if (req.restarts == 1 && req.http.XV-Deliver-Found-Uncachable) {
        unset req.http.Connection;
        set req.http.Connection = "close";
        set req.http.XV-Uncacheable-Object-Pipe = "1";
        return (pipe);
    }
    
    if (req.method != "GET"
    		&& req.method != "POST"
    		&& req.method != "HEAD"
    		&& req.method != "PUT"
    		&& req.method != "DELETE"
    		&& req.method != "PATCH"
    		&& req.method != "OPTIONS"
    		&& req.method != "TRACE") {
        return (pipe);
    }
    
    if (header.get(req.http.X-Cachewall-Match, "(pass|pipe)=")) {
        std.log("MATCH_EXCLUSION: " + header.get(req.http.X-Cachewall-Match, "(pass|pipe)="));
        if (header.get(req.http.X-Cachewall-Match, "pipe=")) {
            return (pipe);
        }
        
        elif (header.get(req.http.X-Cachewall-Match, "pass=")) {
            return (pass);
        }
    }
    
    if (req.method != "GET" && req.method != "HEAD") {
        return (pass);
    }
    
    include "/usr/local/xvarnish/varnish.conf.d/normreq_url.vcl";
    include "/usr/local/xvarnish/varnish.conf.d/normreq_cookie.vcl";
    
    set req.http.Surrogate-Capability = "key=ESI/1.0";
    
    if (req.http.Authorization) {
        return (pass);
    }
    
    include "/usr/local/xvarnish/varnish.conf.d/local/vcl_recv_post.vcl";
    
    return (hash);
}

sub vcl_pipe {
    unset bereq.http.Connection;
    set bereq.http.Connection = "close";
    
    include "/usr/local/xvarnish/varnish.conf.d/local/vcl_pipe.vcl";
}

sub vcl_pass {
    include "/usr/local/xvarnish/varnish.conf.d/local/vcl_pass.vcl";
}

sub vcl_hash {
    include "/usr/local/xvarnish/varnish.conf.d/local/vcl_hash.vcl";
    
    hash_data("" + server.ip + std.port(server.ip));
    
    if (req.http.Cookie) {
        hash_data(req.http.Cookie);
    }
}

sub vcl_hit {
    include "/usr/local/xvarnish/varnish.conf.d/local/vcl_hit.vcl";
}

sub vcl_miss {
    include "/usr/local/xvarnish/varnish.conf.d/local/vcl_miss.vcl";
}

sub vcl_backend_fetch {
    include "/usr/local/xvarnish/varnish.conf.d/local/vcl_backend_fetch.vcl";
    
    set bereq.proto = "HTTP/1.1";
    
    if (bereq.retries == 1 && bereq.http.XV-Retry-for-Fetch-to-Pipe) {
        set bereq.method = "HEAD";
    }
    
    if (bereq.retries >= 2) {
        return (abandon);
    }
}

sub vcl_backend_response {
    set beresp.http.XV-URL = bereq.url;
    set beresp.http.XV-Host = bereq.http.Host;
    
    if (bereq.method == "POST" && bereq.url == "/__cachewall/waf/verify.php") {
        return (deliver);
    }
    
    set beresp.grace = 300s;
    
    include "/usr/local/xvarnish/varnish.conf.d/local/vcl_backend_response.vcl";
    
    if (bereq.http.X-Cachewall-Object-Type == "static") {
        unset beresp.http.set-cookie;
    }
    
    if (beresp.was_304) {
        return (deliver);
    }
    
    
    if (std.strstr(beresp.http.Content-Type, "audio") || std.strstr(beresp.http.Content-Type, "video")) {
        set beresp.do_gzip = false;
    }
    
    if (bereq.http.XV-Retry-for-Fetch-to-Pipe) {
        set beresp.uncacheable = true;
        set beresp.http.XV-Fetch-to-Pipe = "1";
        return (deliver);
    }
    
    if (std.integer(beresp.http.Content-Length, 0) > 52428800) {
        set beresp.uncacheable = true;
        
        if (bereq.method == "GET") {
            set bereq.http.XV-Retry-for-Fetch-to-Pipe = "1";
            return (retry);
        }
    }
    
    if (std.strstr(beresp.http.Cache-Control, "no-cache")) {
        set beresp.uncacheable = true;
        return (deliver);
    }
    
    if (beresp.status == 301) {
        unset beresp.http.Content-Encoding;
    }
    
    if (beresp.status != 200 && beresp.status != 301 && beresp.status != 302 && beresp.status != 404) {
        set beresp.uncacheable = true;
        
        set beresp.ttl = 60s;
        return (deliver);
    }
    
    if (bereq.http.X-Cachewall-Object-Type == "static") {
        unset beresp.http.set-cookie;
        if (beresp.http.X-Static) {
            set beresp.ttl = std.duration(beresp.http.X-Static, 300s);
        }
        
        else {
            set beresp.ttl = 1800s;
        }
    }
    
    else {
        if (beresp.http.X-Dynamic) {
            set beresp.ttl = std.duration(beresp.http.X-Dynamic, 300s);
        }
        
        else {
            set beresp.ttl = 5s;
        }
    }
    
    return (deliver);
}

sub vcl_deliver {
    unset resp.http.XV-URL;
    unset resp.http.XV-Host;
    
    if (req.http.X-Forwarded-Host ~ "^(webmail|cpanel|whm|webdisk|cpcalendars|cpcontacts)\." && resp.http.Location ~ "^(\w+://[^/]+):\d+") {
        set resp.http.X-Location-Host = regsub(resp.http.Location, "^\w+://([^/]+):\d+(.*)?", "\1");
        
        if (resp.http.X-Location-Host == req.http.X-Forwarded-Host) {
            set resp.http.Location = regsub(resp.http.Location, "^(\w+://[^/]+):\d+", "\1");
        }
    }
    
    if (req.method == "POST" && req.http.Host == "127.0.0.1" && req.url == "/__cachewall/waf/verify.php") {
        return (synth(resp.status, resp.http.X-Cachewall-Result));
    }
    
    if (obj.hits > 0) {
        set resp.http.X-Cache = "HIT";
        set resp.http.X-Cache-Hits = obj.hits;
    }
    
    else {
        set resp.http.X-Cache = "MISS";
    }
    
    include "/usr/local/xvarnish/varnish.conf.d/local/vcl_deliver.vcl";
    
    if (resp.http.XV-Fetch-to-Pipe) {
        set req.http.XV-Deliver-Found-Uncachable = "1";
        return (restart);
    }
    
    unset resp.http.x-powered-by;
    unset resp.http.server;
    unset resp.http.x-drupal-cache;
    unset resp.http.via;
    unset resp.http.link;
}

sub vcl_synth {
    set resp.http.Content-Type = "text/html; charset=utf-8";
    
    include "/usr/local/xvarnish/varnish.conf.d/local/vcl_synth.vcl";
    
    if (req.method == "POST" && req.http.X-Cachewall-Action == "challenge") {
        	if (req.url == "/__cachewall/preview/challenge") {
            		set resp.status = 200;
            		set resp.reason = "OK";
            		set resp.http.X-Cachewall-Message = "Thank you. We're redirecting you now..";
        	}
        
        elif (req.url == "/__cachewall/waf/verify.php") {
            set resp.http.X-Cachewall-Message = regsub(resp.reason, ".*message=([^;]+);.*", "\1");
            set resp.reason = regsub(resp.reason, ".*reason=([^;]+);.*", "\1");
        }
        
        synthetic(resp.http.X-Cachewall-Message);
        return (deliver);
    }
    
    if (resp.status == 403 && req.http.X-Cachewall-Action == "challenge") {
        set resp.http.X-Cachewall-Result = resp.reason;
        set resp.http.X-Cachewall-Action = req.http.X-Cachewall-Action;
        set resp.reason = "Bob2";
        include "/usr/local/xvarnish/varnish.conf.d/tpl_waf_block.vcl";
    }
    
    elif (resp.status == 429) {
        include "/usr/local/xvarnish/varnish.conf.d/tpl_ratelimit_reached.vcl";
    }
    
    elif (resp.status == 503) {
        include "/usr/local/xvarnish/varnish.conf.d/tpl_frontend_error.vcl";
    }
    
    else {
        include "/usr/local/xvarnish/varnish.conf.d/tpl_synth.vcl";
    }
    
    return (deliver);
}

sub vcl_backend_error {
    set beresp.http.Content-Type = "text/html; charset=utf-8";
    set beresp.http.Retry-After = "5";
    
    include "/usr/local/xvarnish/varnish.conf.d/local/vcl_backend_error.vcl";
    include "/usr/local/xvarnish/varnish.conf.d/tpl_backend_error.vcl";
    
    return (deliver);
}

sub xv_add_object_type {
    if (!std.strstr(req.url, "\.(php)") && req.url ~ "^[^?]*\.(gm|mpe?g|mk[av]|xz|avi|7z|bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpe?g|js|less|mp[34]|pdf|png|rar|iso|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\?.*)?$") {
        set req.http.X-Cachewall-Object-Type = "static";
    }
    
    else {
        set req.http.X-Cachewall-Object-Type = "dynamic";
    }
}

sub req_identity {
    set req.http.X-Cachewall-Identity = 100000000000 * std.integer(server.identity, 1) + 1000000 * std.port(client.ip) + std.integer(req.xid, 0);
}

sub xv_add_real_ip {
    
    if (req.http.CF-Connecting-IP && client.ip ~ acl_cloudflare) {
        set req.http.X-Cachewall-Remote-IP = req.http.CF-Connecting-IP;
        std.log("PROXY_IP: " + client.ip);
    }
    
    elif (req.http.Incap-Client-IP && client.ip ~ acl_incapsula) {
        set req.http.X-Cachewall-Remote-IP = req.http.Incap-Client-IP;
        std.log("PROXY_IP: " + client.ip);
    }
    
    else {
        set req.http.X-Cachewall-Remote-IP = client.ip;
    }
    
    if (!std.strstr(req.http.X-Forwarded-For, req.http.X-Cachewall-Remote-IP)) {
        set req.http.X-Forwarded-For = req.http.X-Cachewall-Remote-IP;
    }
}

sub xv_recv_synth {
    if (req.url == "/__cachewall/status") {
        return (synth(204, "No Content"));
    }
    
    elif (req.url == "/__cachewall/preview/error") {
        return (synth(503, "Frontend and Backend Error"));
    }
    
    elif (req.url == "/__cachewall/preview/ratelimit") {
        return (synth(429, "Resource Rate Limit Reached"));
    }
    
    elif (req.url == "/__cachewall/preview/challenge") {
        set req.http.X-Cachewall-Action = "challenge";
        return (synth(403, "Web Application Firewall Challenge"));
    }
}

include "/usr/local/xvarnish/varnish.conf.d/local/default.vcl";
include "/usr/local/xvarnish/varnish.conf.d/local/default_post.vcl";

Ouput of top command

Code:
[root@server ~]# top c
top - 23:20:33 up 10:13,  1 user,  load average: 22.03, 21.04, 22.06
Tasks: 483 total,   2 running, 480 sleeping,   0 stopped,   1 zombie
Cpu(s):  6.6%us,  1.2%sy,  0.0%ni, 52.2%id, 37.4%wa,  0.0%hi,  2.6%si,  0.0%st
Mem:  66000304k total, 62247092k used,  3753212k free, 18638920k buffers
Swap:  1046520k total,   104288k used,   942232k free, 17017504k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
16382 varnish   20   0 16.9g  15g  81m S 20.6 24.5  29:01.66 /usr/sbin/varnishd -P /var/run/varnish.pid -f /etc/varnish.conf.d/default
 8228 appscubo  20   0  311m  16m 4820 S  5.0  0.0   0:05.21 php-fpm: pool appscubo_com
Warm Regards,
Redssr
 
Old 05-23-2017, 02:36 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: MA, USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 7,214
Blog Entries: 12

Rep: Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656Reputation: 2656
Moved: This thread is more suitable in Linux-Server and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 05-23-2017, 04:16 PM   #3
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,055

Rep: Reputation: 2078Reputation: 2078Reputation: 2078Reputation: 2078Reputation: 2078Reputation: 2078Reputation: 2078Reputation: 2078Reputation: 2078Reputation: 2078Reputation: 2078
Quote:
Originally Posted by redssr View Post
Hello,

Experts,

I have one powerful dedicated server with 12 cores CPU and 64GB RAM. I had installed Cpanel with Varnish over easyaapache4

I had configured Varnish to use varnish storage as 40G. but when i hits the top command it shows only 20-25% memory used by varnish all the time.
Note that memory and storage are not the same thing.
Sorry, I can't help with the precise details though.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Varnish Software's Varnish Massive Storage Engine LXer Syndicated Linux News 0 05-17-2016 06:32 PM
[SOLVED] Virtual Memory limit exhausted at 1TB? malloc/mmap failures even with free memory mfkraft Linux - Server 2 09-16-2012 09:27 AM
Memory map or physical address of some memory allocated by malloc demon007 Programming 1 02-04-2012 07:17 AM
Memory leaks.. *** glibc detected *** ./SuffixTree: malloc(): memory corruption: 0x00 evansash Programming 12 03-21-2011 02:17 PM
C, Malloc, and Memory: Just Curious CoderMan Programming 4 01-20-2010 10:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration