Welcome! Log In Create A New Profile

Advanced

Re: load balancing according to url

April 29, 2013 07:30AM
Hi.

Emm, maybe you want to make some kind of sharding by the value of your
cookie?

upstream <http://wiki.nginx.org/NginxHttpUpstreamModule#upstream> backend {
server <http://wiki.nginx.org/NginxHttpCoreModule#server> server1;
server <http://wiki.nginx.org/NginxHttpCoreModule#server> server2;
hash $customer_id;}





On Mon, Apr 29, 2013 at 3:03 PM, ESWAR RAO <eswar7028@gmail.com> wrote:

> Hi Antonio,
>
> Thanks for the response.
>
> I am unable to understand your solution.
>
> As I said, I am unable to know which server served the requests to
> respective customer-id.
> So I cant write the below map directive.
> map $customer_id $sticky_backend {
> default bad_gateway;
> <cust-id_1> <server 1>;
> <cust-id_2> <server 2>;
> }
>
> Thanks
> Eswar
>
>
> On Mon, Apr 29, 2013 at 2:31 PM, António P. P. Almeida <appa@perusio..net>wrote:
>
>> You chain two map directives. Like this:
>>
>> map $uri $customer_id {
>> ~/customer/(?<cust_id>[^/]+)/.*$ $cust_id;
>>
>> }
>>
>> map $customer_id $sticky_backend {
>> default bad_gateway;
>> <cust-id_1> <server 1>;
>> <cust-id_2> <server 2>;
>> }
>>
>>
>> ----appa
>>
>>
>>
>> On Mon, Apr 29, 2013 at 8:27 AM, ESWAR RAO <eswar7028@gmail.com> wrote:
>>
>>> Hi All,
>>>
>>> Can anyone please help me with the below requirement.
>>>
>>> Host machine contains a plugin and it communicates with a plugin handler
>>> running on backend servers and nginx is used to load balance the requests.
>>>
>>> host machine(plugin) ===== >nginx as load balancer =====>3 backend
>>> servers which hosts plugin handler
>>>
>>> I need to load balance the requests based on customer-id field in host
>>> machine.
>>> # curl '
>>> http://localhost:8031/test1/test2/test3/customer/123456789999999999/......../
>>>
>>> customer-id: 123456789999999999
>>> customer-id changes with customers.
>>>
>>> Since the requests come from same machine, I can't use ip_hash or cookie
>>> based load balancing technique.
>>>
>>> My requirement is to load balance according to customer id and if same
>>> request comes the same customer it should go to same earlier server which
>>> served the request.
>>>
>>>
>>> I am planning to extract the customer-id in nginx configuration file and
>>> add them on the fly in the config file and compare the ids using "map"
>>> directive. But unable to know which server served the requests to
>>> customer-id:
>>>
>>> map $customer_id $sticky_backend {
>>> default bad_gateway;
>>> <cust-id_1> <server 1>;
>>> <cust-id_2> <server 2>;
>>> }
>>> if ( $request_uri ~ ^/(.*)/(customer)/(.*?)/(.*)/ ) {
>>> set $customer_id $3;
>>>
>>> Thanks
>>> Eswar
>>>
>>>
>>> _______________________________________________
>>> nginx mailing list
>>> nginx@nginx.org
>>> http://mailman.nginx.org/mailman/listinfo/nginx
>>>
>>
>>
>> _______________________________________________
>> nginx mailing list
>> nginx@nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx
>>
>
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>



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

load balancing according to url

ESWAR RAO April 29, 2013 02:30AM

Re: load balancing according to url

mex April 29, 2013 03:26AM

Re: load balancing according to url

António P. P. Almeida April 29, 2013 05:02AM

Re: load balancing according to url

ESWAR RAO April 29, 2013 07:06AM

Re: load balancing according to url

Priority1 April 29, 2013 07:30AM

Re: load balancing according to url

ESWAR RAO April 29, 2013 07:10AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 150
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