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

[mqtt] Benchmark broker message dispatching #2897

Merged
merged 16 commits into from
May 1, 2020

Conversation

dmolokanov
Copy link
Contributor

@dmolokanov dmolokanov commented Apr 29, 2020

In order to verify how quickly broker can dispatch messages we need some benchmark tests.
dispatch_message benches start broker with empty state and no network connections. Firstly, each bench test creates a given number of publishers, subscribers and connects them to a broker. Then it makes a series of exercises to send messages to a broker and measures the time between a message successfully sent to a broker and broker processed this message. For this case broker extended with a on_publish "callback" which has to be exposed only for benchmark tests.

Scenarios supported:

1-to-1

Each publisher sends messages to one corresponding subscriber:

pub1 pub topic/1            sub1 sub topic/1
pub2 pub topic/2            sub2 sub topic/2
pub2 pub topic/N            sub2 sub topic/N

fan-in

All publishers send message to a randomly chose topic

pub1 pub topic/2            sub1 sub topic/1
pub2 pub topic/2            sub2 sub topic/2
pubN pub topic/2            sub2 sub topic/N

fan-out

Multiple publishers sends messages to a topic all subscribers subscribed to

pub1 pub topic/foo            sub1 sub topic/foo
pub2 pub topic/foo            sub2 sub topic/foo
pubN pub topic/foo            sub2 sub topic/foo

How to run benches

cd mqtt 
cargo bench --bench dispatch_messages \
    --features="benches" \
    --manifest-path mqtt-broker/Cargo.toml

or

cd mqtt/mqtt-broker
cargo bench --bench dispatch_messages --features="benches"

to run all benches

cd mqtt/mqtt-broker
cargo bench --all --features="benches"

@dmolokanov dmolokanov changed the title [mqtt] Benchmark broker message dispatching. 1-to-1 case [mqtt] Benchmark broker message dispatching Apr 30, 2020
@dmolokanov dmolokanov marked this pull request as ready for review April 30, 2020 06:17
myagley
myagley previously approved these changes Apr 30, 2020
mqtt/mqtt-broker/Cargo.toml Outdated Show resolved Hide resolved
@dmolokanov dmolokanov requested review from lfitchett, 1VarunCh1, vipeller and varunpuranik and removed request for 1VarunCh1 April 30, 2020 16:31
}
group.finish();
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these three methods look exactly the same, except the strategy they create and the name. Can it be made into a single method, and fan_in()/fan_out()/one_to_one() just call that single method with a "strategy creator" function injected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought about that. I still wonder if number of publishers should not be equal number of subscribers. it may vary depending on strategy...

vadim-kovalyov
vadim-kovalyov previously approved these changes Apr 30, 2020
Copy link
Contributor

@vadim-kovalyov vadim-kovalyov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

ClientEvent::DropConnection
| ClientEvent::CloseSession
| ClientEvent::Disconnect(_) => {
stop = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: log(...); break;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it logged bellow

mqtt/mqtt-broker/src/broker.rs Show resolved Hide resolved
@kodiakhq kodiakhq bot merged commit d0f5fb8 into Azure:master May 1, 2020
@dmolokanov dmolokanov deleted the mqtt-dispatch-bench branch July 7, 2020 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants