Balancer_by_lua performance issues

131 views
Skip to first unread message

Paul Berthaux

unread,
Mar 20, 2018, 6:08:03 AM3/20/18
to openresty-en
Hi, 

I'm currently working on an openresty based loadbalancer with redis as dynamic backend, and I noticed some performances issues when comparing to our static nginx based current solution.

I stripped down most of of the openresty configuration in order to isolate the part causing most of latency variations.
The performance issue seems to be related to the balancer by lua bloc.

When I replace in my legacy nginx static config :

upstream upstream-server-group {
        server test_server_fqdn:443;
        keepalive 64;
    }

with :

upstream upstream-server-group {
        server 127.0.0.1;
        balancer_by_lua_block
        {
          local balancer = require "ngx.balancer"

          local ok, err = balancer.set_current_peer("test_server_ip", 443)
          if not ok then
            ngx.log(ngx.ERR, "failed to set the current peer: ", err)
            return ngx.exit(500)
          end
        }      
        keepalive 64;
    }

the results of my tests goes from : 

Latencies     [mean, 50, 95, 99, max]  2.011923ms, 1.972201ms, 2.068322ms, 2.757951ms, 37.345576ms

to 

Latencies     [mean, 50, 95, 99, max]  3.164499ms, 2.011021ms, 2.171413ms, 43.643579ms, 214.515421ms

Is this a normal behaviour ? is there something special to do to tune balancer_by_lua_block ?

Regards,
Paul

Peter Booth

unread,
Mar 20, 2018, 7:47:42 AM3/20/18
to openre...@googlegroups.com
The values that you report sound very high. How are you taking your latency measurements and what is your test workload? What are the best case (minimum ) latencies?

Are your two test scenarios both stable systems or are they in an overload state?

Sent from my iPad
--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vinicius Mignot

unread,
Mar 20, 2018, 8:10:38 AM3/20/18
to openre...@googlegroups.com
Hello, Paul

I'm working with lua-resty-core for just a few weeks now, so this is mostly a guess.

Your results with balancer by lua seem to be very similar to static nginx results in the 95%. I think the difference here is that nginx already did all work on creating the upstream structure with the static config, but has to do it on the first request with balancer by lua.

Is it possible to increase the sample size? Or do a first request to balancer by lua, wait for a sec and then start measuring?



--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en+unsubscribe@googlegroups.com.

Paul Berthaux

unread,
Mar 20, 2018, 10:02:49 AM3/20/18
to openresty-en
I'll do a longer measurement and post the results here.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages