Quantcast

performance using variables?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

performance using variables?

Ingo Baab
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.de www.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
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: performance using variables?

Francis Daly
On Tue, May 02, 2017 at 02:03:25PM +0200, Ingo Baab wrote:

Hi there,

> I got a question regarding performance of my nginx configuration
> files using variables.

The usual rule with performance questions is: if you do not measure
a performance difference, then there is not an important performance
difference in your use case.

> Q: Is this a performance disadvantage?

There will be a computer run-time performance disadvantage in using a
variable like this.

There may be an administrator config-write-time advantage in using a
variable like this.

> Is this a good approach to separate php processors for each virtual
> host or should
> I do all configuration better static?

Static configuration will have better computer run-time performance. But
unless you measure a difference, the difference is not important to you.

If what you have works well-enough, you don't need to change anything.

Good luck with it,

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Loading...