Hi Dmitry, On Fri, Feb 19, 2016 at 05:58:47PM +0300, Dmitry Sivachenko wrote: > Hello, > > I want to define ACL which will evaluate to true if a current number of > connections to a particular backend is greater than a number of usable > servers in that backend multiplied on some constant: > > be_conn(BACK) > nbsrv(BACK) * N > > So far I came up with the following solution: > > frontend FRONT > mode http # can be either http or tcp here > tcp-request content set-var(sess.nb) nbsrv(BACK) # I use tcp-request > here (not http-request) so it works for both http and tcp mode backends > acl my_acl be_conn(BACK),div(sess.nb) gt 10 # "N" in 10 here > > > So I must use set-var here because div() accepts either a number or a > variable. > > Is this a good sulution for my problem or it can be done better?
It currently is the only available solution, and I'm glad that you spotted it because support for variables in arithmetic operators was added in great part to permit such things. I do have one comment regarding your comment about tcp-request vs http-request. What you say is valid only if you don't have "mode http" in your frontend, but I assume that you simplified the config so that it's easy to understand here. Regards, Willy

