Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce duplicate rdy update requests #243

Merged

Conversation

andyxning
Copy link
Member

This PR will reduct duplicate rdy update requests.

@andyxning andyxning force-pushed the reduce_duplicate_rdy_update_requests branch 30 times, most recently from 5a5352c to c306b08 Compare January 16, 2020 06:13
@andyxning andyxning force-pushed the reduce_duplicate_rdy_update_requests branch 10 times, most recently from e761592 to fb8bd5d Compare January 16, 2020 08:18
@andyxning
Copy link
Member Author

@ploxiln @mreiferson

tests/test_backoff.py Outdated Show resolved Hide resolved
@ploxiln
Copy link
Member

ploxiln commented Feb 9, 2020

I'm not convinced about the benefit of this change. How often does the overall "ready" algorithm generate redundant RDY messages, and is this the simplest way to improve it? Maybe, but I'm not convinced.

@andyxning
Copy link
Member Author

I'm not convinced about the benefit of this change. How often does the overall "ready" algorithm generate redundant RDY messages, and is this the simplest way to improve it? Maybe, but I'm not convinced.

When:

  • the max_in_flight setting to 4000
  • the nsqd instances is about 1500

When consumer connects to every nsqd, it needs to rebalance the rdy around all the existing connections, at this time, a connection may send continuous duplicate rdy value.

@andyxning
Copy link
Member Author

@ploxiln You can just take a look at the go-nsq change. Its change is simpler. nsqio/go-nsq#282

@andyxning andyxning force-pushed the reduce_duplicate_rdy_update_requests branch from fb8bd5d to fc09c9a Compare February 29, 2020 13:42
@andyxning
Copy link
Member Author

@ploxiln Code has been cleaned in the correct way. PTAL.

@andyxning andyxning force-pushed the reduce_duplicate_rdy_update_requests branch 2 times, most recently from b93676a to e0ac940 Compare March 1, 2020 06:15
@andyxning
Copy link
Member Author

@ploxiln This PR's code has been cleaned. PTAL.~

@ploxiln
Copy link
Member

ploxiln commented Mar 4, 2020

here's an idea for an even simpler test change:

--- a/tests/test_backoff.py
+++ b/tests/test_backoff.py
@@ -260,9 +260,15 @@ def test_backoff_many_conns(mock_ioloop_current):
     for i in range(num_conns):
         conn = get_conn(r)
         conn.expected_args = [b'SUB test test\n', b'RDY 1\n']
+        conn.last_exp_rdy = b'RDY 1\n'
         conn.fails = 0
         conns.append(conn)
 
+    def add_exp_rdy(conn, rdy):
+        if conn.last_exp_rdy != rdy:
+            conn.expected_args.append(rdy)
+            conn.last_exp_rdy = rdy
+
     fail = True
     total_fails = 0
     last_timeout_time = 0
@@ -271,7 +277,7 @@ def test_backoff_many_conns(mock_ioloop_current):
         msg = send_message(conn)
 
         if r.backoff_timer.get_interval() == 0:
-            conn.expected_args.append(b'RDY 1\n')
+            add_exp_rdy(conn, b'RDY 1\n')
 
         if fail or not conn.fails:
             msg.trigger(event.REQUEUE, message=msg)
@@ -279,7 +285,7 @@ def test_backoff_many_conns(mock_ioloop_current):
             conn.fails += 1
 
             for c in conns:
-                c.expected_args.append(b'RDY 0\n')
+                add_exp_rdy(c, b'RDY 0\n')
             conn.expected_args.append(b'REQ 1234 0\n')
         else:
             msg.trigger(event.FINISH, message=msg)
@@ -287,7 +293,7 @@ def test_backoff_many_conns(mock_ioloop_current):
             conn.fails -= 1
 
             for c in conns:
-                c.expected_args.append(b'RDY 0\n')
+                add_exp_rdy(c, b'RDY 0\n')
             conn.expected_args.append(b'FIN 1234\n')
...

@andyxning andyxning force-pushed the reduce_duplicate_rdy_update_requests branch from e0ac940 to 07ffcde Compare March 4, 2020 11:21
@andyxning andyxning force-pushed the reduce_duplicate_rdy_update_requests branch from 07ffcde to 86cbb1b Compare March 4, 2020 11:26
@andyxning
Copy link
Member Author

@ploxiln code format is done. PTAL.

@ploxiln
Copy link
Member

ploxiln commented Mar 4, 2020

cool. thanks.

@ploxiln ploxiln merged commit 3f61477 into nsqio:master Mar 4, 2020
@andyxning andyxning deleted the reduce_duplicate_rdy_update_requests branch March 5, 2020 02:29
@andyxning
Copy link
Member Author

@ploxiln Thanks for your review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants