agentzh
June 10, 2011 12:32AM
On Fri, Jun 10, 2011 at 7:40 AM, Richard Kearsley
<Richard.Kearsley@m247.com> wrote:
> I’m using nginx-lua to get some info from a back end “auth” server for each
> request
>

Sounds cool :)

> The back end server is a simple http server written by myself – i.e. it is
> nowhere near as fast or as optimised as nginx and can therefore be
> considered a bottleneck
>
> I could run multiple backend server instances to give it a better chance of
> keeping up (i.e. one per cpu core) – but then I’d need to load balance (only
> round-robin style) to the multiple backends in my lua code.
>

Why not use the nginx upstream block directly? For example:

upstream backend {
server 10.32.56.4;
server 10.32.56.3;
}

location = /auth {
proxy_pass http://backend;
}

No Lua is required here unless you need to custimize the load
balancing algorithm.

> Is there something I can do in lua code to accomplish this?
>

If you insist in using Lua, just a quick note on this: the standard
ngx_proxy module supports dynamic resolvers by interpolating nginx
variables into the proxy_pass directive. I think you can use Lua to
compute the value of your nginx variables, which points to a custom
backend server.

Regards,
-agentzh

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

lua back-end load balancing

Richard Kearsley June 09, 2011 07:42PM

Re: lua back-end load balancing

agentzh June 10, 2011 12:32AM

RE: lua back-end load balancing

Richard Kearsley June 10, 2011 07:06AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 242
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready