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

Add --exit-when option #280

Merged
merged 1 commit into from
Nov 30, 2021
Merged

Conversation

acogoluegnes
Copy link
Collaborator

Fixes #279

@acogoluegnes
Copy link
Collaborator Author

acogoluegnes commented Nov 29, 2021

Acceptance steps:

Get the branch and create the binary:

cd /tmp
git clone [email protected]:rabbitmq/rabbitmq-perf-test.git
cd rabbitmq-perf-test
git checkout rabbitmq-perf-test-279-consumer-activity
make binary
tar xf target/rabbitmq-perf-test-2.17.0-SNAPSHOT-bin.tar.gz

Run a local broker instance:

docker run -it --rm --name rabbitmq -p 5672:5672 -p 5552:5552 -p 15672:15672 rabbitmq:3.9-management

Open another terminal tab.

Let's start with the existing behavior when the consumer queue gets empty. Publish some messages:

rabbitmq-perf-test-2.17.0-SNAPSHOT/bin/runjava com.rabbitmq.perf.PerfTest -x 1 -y 0 --queue test --pmessages 50000

Consume from the queue, the program should "hang" when the queue is empty:

rabbitmq-perf-test-2.17.0-SNAPSHOT/bin/runjava com.rabbitmq.perf.PerfTest -x 0 -y 1 --queue test --consumer-rate 10000

Terminate the process with Ctrl+C.

Now let's try with the new option.

Publish some messages:

rabbitmq-perf-test-2.17.0-SNAPSHOT/bin/runjava com.rabbitmq.perf.PerfTest -x 1 -y 0 --queue test --pmessages 50000

Now consume with --exit-when idle, the program should stop after a few seconds:

rabbitmq-perf-test-2.17.0-SNAPSHOT/bin/runjava com.rabbitmq.perf.PerfTest -x 0 -y 1 --queue test --consumer-rate 10000 --exit-when idle
id: test-153245-095, starting consumer #0
id: test-153245-095, starting consumer #0, channel #0
id: test-153245-095, time: 1.000s, received: 7911 msg/s, min/median/75th/95th/99th consumer latency: 0/0/0/0/0 µs
id: test-153245-095, time: 2.000s, received: 10001 msg/s, min/median/75th/95th/99th consumer latency: 0/0/0/0/0 µs
id: test-153245-095, time: 3.000s, received: 9981 msg/s, min/median/75th/95th/99th consumer latency: 0/0/0/0/0 µs
id: test-153245-095, time: 4.000s, received: 10011 msg/s, min/median/75th/95th/99th consumer latency: 0/0/0/0/0 µs
id: test-153245-095, time: 5.000s, received: 10001 msg/s, min/median/75th/95th/99th consumer latency: 0/0/0/0/0 µs
test stopped (No activity for 1 second for queue test)
id: test-153245-095, sending rate avg: 0 msg/s
id: test-153245-095, receiving rate avg: 8028 msg/s

Now let's try with the empty value for the new option.

Publish some messages:

rabbitmq-perf-test-2.17.0-SNAPSHOT/bin/runjava com.rabbitmq.perf.PerfTest -x 1 -y 0 --queue test --pmessages 50000

Consume with --exit-when empty, the program should stop after a few seconds:

rabbitmq-perf-test-2.17.0-SNAPSHOT/bin/runjava com.rabbitmq.perf.PerfTest -x 0 -y 1 --queue test --consumer-rate 10000 --exit-when empty
id: test-093321-464, starting consumer #0
id: test-093321-464, starting consumer #0, channel #0
id: test-093321-464, time: 1.000s, received: 8981 msg/s, min/median/75th/95th/99th consumer latency: 0/0/0/0/0 µs
id: test-093321-464, time: 2.000s, received: 9993 msg/s, min/median/75th/95th/99th consumer latency: 0/0/0/0/0 µs
id: test-093321-464, time: 3.000s, received: 9991 msg/s, min/median/75th/95th/99th consumer latency: 0/0/0/0/0 µs
id: test-093321-464, time: 4.000s, received: 10001 msg/s, min/median/75th/95th/99th consumer latency: 0/0/0/0/0 µs
id: test-093321-464, time: 5.000s, received: 9994 msg/s, min/median/75th/95th/99th consumer latency: 0/0/0/0/0 µs
test stopped (Consumer queue(s) empty)
id: test-093321-464, sending rate avg: 0 msg/s
id: test-093321-464, receiving rate avg: 8157 msg/s

Now let's try with several queues. We'll use only --exit-when idle this time.

Publish some messages on 10 queues:

rabbitmq-perf-test-2.17.0-SNAPSHOT/bin/runjava com.rabbitmq.perf.PerfTest -x 10 -y 0 --queue-pattern 'perf-test-%d' --queue-pattern-from 1 --queue-pattern-to 10 --pmessages 50000

Consume from the queues until they are empty (and consumers become idle):

rabbitmq-perf-test-2.17.0-SNAPSHOT/bin/runjava com.rabbitmq.perf.PerfTest -x 0 -y 10 --queue-pattern 'perf-test-%d' --queue-pattern-from 1 --queue-pattern-to 10 --consumer-rate 10000 --exit-when idle
...
id: test-092646-558, time: 1.000s, received: 62712 msg/s, min/median/75th/95th/99th consumer latency: 18431991/18675068/18808585/18908848/18960014 µs
id: test-092646-558, time: 2.000s, received: 104751 msg/s, min/median/75th/95th/99th consumer latency: 18905643/19342336/19568018/19727979/19772762 µs
id: test-092646-558, time: 3.000s, received: 100006 msg/s, min/median/75th/95th/99th consumer latency: 19763860/20264725/20492636/20681975/20723255 µs
id: test-092646-558, time: 4.000s, received: 100028 msg/s, min/median/75th/95th/99th consumer latency: 20700622/21217464/21458517/21634248/21668870 µs
id: test-092646-558, time: 5.000s, received: 99960 msg/s, min/median/75th/95th/99th consumer latency: 21663328/22164229/22401888/22609875/22643697 µs
test stopped (Consumer is idle for more than 1 second [10])
id: test-092646-558, sending rate avg: 0 msg/s
id: test-092646-558, receiving rate avg: 76173 msg/s

@acogoluegnes acogoluegnes marked this pull request as ready for review November 30, 2021 08:38
@lhoguin
Copy link

lhoguin commented Nov 30, 2021

All good!

One thing I noticed is:

rabbitmq-perf-test-2.17.0-SNAPSHOT/bin/runjava com.rabbitmq.perf.PerfTest -x 0 -y 1 --queue test5 --predeclared --consumer-rate 10000 --exit-when idle
id: test-104850-534, starting consumer #0
id: test-104850-534, starting consumer #0, channel #0
test stopped (Consumer is idle for more than 1 second)
id: test-104850-534, sending rate avg: 0 msg/s
id: test-104850-534, receiving rate avg: 0 msg/s

The queue doesn't exist before using PerfTest and it behaves the same as if the queue did exist and was empty. I don't know if that's wanted or not. It's the same with empty and idle.

Now let's try with several queues. We'll use only --exit-when empty this time.

For what it's worth, your instructions were using idle. I have confirmed both work.

@michaelklishin
Copy link
Member

As far as idle goes, I think a missing and empty queue should be treated differently: the consumer/PerfTest is idle in both cases.

I don't know if it's important enough to bother with differentiating empty and "non-existent".

@acogoluegnes
Copy link
Collaborator Author

One thing I noticed is:

rabbitmq-perf-test-2.17.0-SNAPSHOT/bin/runjava com.rabbitmq.perf.PerfTest -x 0 -y 1 --queue test5 --predeclared --consumer-rate 10000 --exit-when idle
id: test-104850-534, starting consumer #0
id: test-104850-534, starting consumer #0, channel #0
test stopped (Consumer is idle for more than 1 second)
id: test-104850-534, sending rate avg: 0 msg/s
id: test-104850-534, receiving rate avg: 0 msg/s

The queue doesn't exist before using PerfTest and it behaves the same as if the queue did exist and was empty. I don't know if that's wanted or not. It's the same with empty and idle.

Even though --predeclared is enabled, PerfTest check if the queue exists and creates it if it does not. This is exactly what we've been discussing there, but for exchanges. This is the historical behavior of PerfTest.

So PerfTest creates the queue, registers a consumer, and the consumer stays idle for a couple of seconds, and exits. This is the expected behavior (the one I implemented and thought makes sense).

Now let's try with several queues. We'll use only --exit-when empty this time.

For what it's worth, your instructions were using idle. I have confirmed both work.

Thanks, corrected.

@acogoluegnes
Copy link
Collaborator Author

As far as idle goes, I think a missing and empty queue should be treated differently: the consumer/PerfTest is idle in both cases.

I don't know if it's important enough to bother with differentiating empty and "non-existent".

Yes, the missing queue case is an edge case. Currently PerfTest creates the queue anyway and exits because the consumer is idle.

@acogoluegnes acogoluegnes merged commit 85e4083 into main Nov 30, 2021
pivotal-rabbitmq-ci pushed a commit that referenced this pull request Nov 30, 2021
@acogoluegnes acogoluegnes deleted the rabbitmq-perf-test-279-consumer-activity branch October 5, 2022 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exit when queue(s) empty
3 participants