performance using variables?

Ingo Baab ib at baab.de
Tue May 2 12:03:25 UTC 2017


Hello List!

I got a question regarding performance of my nginx configuration files 
using variables.
Will there be any slow LUA-runtime-parsing if I set a variable $phpuser 
inside my server
block and use it afterwards in several common config files.

Q: Is this a performance disadvantage?

    upstream php7_wpexpress_de {
       server unix:/var/run/php7.0-fpm-wpexpress_de.sock;
    }

    server {
         set $phpuser "wpexpress_de";

         server_name wpexpress.dewww.wpexpress.de;

         access_log /var/log/nginx/wpexpress.de.access.log rt_cache;
         error_log /var/log/nginx/wpexpress.de.error.log;

         root /var/www/wpexpress.de/htdocs;

         index index.php index.html index.htm;

         include common/redis-php7.conf;
         include common/wpcommon-php7.conf;
         include common/locations-php7.conf;
    }

In the bottom (three) included config-files I subsequently use

        fastcgi_pass php7_$phpuser;

because they do not distinguish per virtual host except for the 
php-upstream.
Is this a good approach to separate php processors for each virtual host 
or should
I do all configuration better static? Thank you in advance for any 
helpfull information,

Ingo Baab, https://baab.de
______
I did read: http://nginx.org/en/docs/faq/variables_in_config.html and 
also found guys suggesting a global var with nginx-config utilizing map: 
http://stackoverflow.com/questions/14433309/how-to-define-a-global-variable-in-nginx-conf-file 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20170502/5c95e41d/attachment.html>


More information about the nginx mailing list