Revolyssup opened a new issue, #9305:
URL: https://github.com/apache/apisix/issues/9305

   ### Current Behavior
   
   Following the docs here for cookie based consistent hashing, two nodes are 
provided in upstream. Even after passing the same cookie consistently as given 
in the doc, the requests are being load balanced in a round robin fashion.
   Here is the output of `/apisix/admin/routes`
   ---
   
{"list":[{"key":"/apisix/routes/1","createdIndex":16,"value":{"id":"1","update_time":1681400381,"create_time":1681377310,"uri":"/","priority":0,"status":1,"upstream":{"type":"chash","pass_host":"pass","hash_on":"cookie","nodes":{"revoly.dev":1,"google.com":1},"scheme":"http","key":"sid"}},"modifiedIndex":46}],"total":1}
   ---
   For the above configuration, here is the request being routed to 
node2(google.com) for a given cookie with key sid
   <img width="977" alt="Screenshot 2023-04-13 at 9 13 52 PM" 
src="https://user-images.githubusercontent.com/43276904/231813624-a89086ad-9eff-4c31-88b7-e52435b595dc.png";>
   
   For the same exact sid cookie, the very next request goes to another node
   <img width="936" alt="Screenshot 2023-04-13 at 9 14 53 PM" 
src="https://user-images.githubusercontent.com/43276904/231813780-4e747b7d-96b3-403b-abc1-a2a1092fc2a6.png";>
   
   
   
   
   ### Expected Behavior
   
   Requests with a given "sid" (`key`) in the Cookie should be consistently 
routed to the same node in upstream.
   
   ### Error Logs
   
   _No response_
   
   ### Steps to Reproduce
   
   1. Run APISIX using helm chart and port forward on the APISIX pod.
   2. Add the following configuration on route
   ---
   curl http://127.0.0.1:9180/apisix/admin/routes/1 \                           
                                          ─╯
   -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
   {
       "uri": "/",
       "upstream": {
           "key": "sid",
           "type": "chash",
           "hash_on": "cookie",
           "nodes": {
               "google.com": 1,
               "revoly.dev": 1
           }
       }
   }'
   ---
   
   Send multiple requests on the below endpoint to see it being round robin'ed 
across nodes instead of being consistently routed.
   ---
   curl http://127.0.0.1:9080 \
    -H "Cookie: sid=3c183a30cffcda1408daf1c61d47b274"
   ---
   
   
   ### Environment
   
   - APISIX version 3.2.0:
   - Operating system x86_64 GNU/Linux:
   - OpenResty / Nginx version openresty/1.21.4.1
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to