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

feat(mqttconn): employ ecpool instead of single worker #10754

Merged
merged 17 commits into from May 30, 2023

Conversation

keynslug
Copy link
Contributor

@keynslug keynslug commented May 19, 2023

Part of EEC-856
Fixes EMQX-10056

This PR adds a ecpool of workers to the MQTT connector. This should alleviate the current bottleneck of using single emqtt worker.

TODOs / Followups.

  • Missing ecpool related schema (e.g. pool_size / reconnect_interval).
  • Subscriptions are still handled only through a single worker in a ecpool, so that ingress messages won't be duplicated pool_size times.
  • Full-fledged performance evaluation.

Summary

🤖 Generated by Copilot at ae3ef14

Refactored the emqx_connector_mqtt module and its worker to improve code quality and consistency. Moved schema validation and parsing to a separate module. Deleted the unused emqx_connector_mqtt_msg module. Updated the test suite to reflect the changes.

PR Checklist

Please convert it to a draft if any of the following conditions are not met. Reviewers may skip over until all the items are checked:

  • Added tests for the changes
  • Changed lines covered in coverage report
  • Change log has been added to changes/{ce,ee}/(feat|perf|fix)-<PR-id>.en.md files
  • For internal contributor: there is a jira ticket to track this change
  • If there should be document changes, a PR to emqx-docs.git is sent, or a jira ticket is created to follow up
  • Schema changes are backward compatible

@keynslug keynslug requested review from a team and JimMoen as code owners May 19, 2023 13:36
thalesmg
thalesmg previously approved these changes May 22, 2023
Copy link
Contributor

@thalesmg thalesmg left a comment

Choose a reason for hiding this comment

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

🔥

@zmstone
Copy link
Member

zmstone commented May 23, 2023

Hi @keynslug
Thank you for the fix.
Could you share some test results?

@keynslug keynslug changed the title feat(mqttconn): stop using gproc in hot path feat(mqttconn): employ ecpool instead of single worker May 23, 2023
@keynslug
Copy link
Contributor Author

Hi @zmstone, not yet I'm afraid. Was invested into this ecpool based redesign, plan to get some perftest results tomorrow.

@keynslug keynslug force-pushed the fix/EEC-856/mqtt branch 7 times, most recently from 3dfc950 to 6cd0e38 Compare May 30, 2023 11:48
Also drop fiddling with `mountpoint` since this option seems not to be
used anywhere.
Inline `emqx_connector_mqtt_msg` module code into
`emqx_connector_mqtt_worker` module, since it's not really used
anywhere else and does not provide any reusable abstractions.
Also move this logic to the mqtt connector itself, in order to avoid
dealing with extra callback layer.
Also rename `subscriptions` -> `ingress` and `forwards` -> `egress` for
consistency with the config schema.
It adds no value: the only mode was `cluster_shareload` and we just as
well can decide to "share" the load across cluster just by looking if
the remote topic is shared subcription filter or not.
That currently tunes the number of MQTT clients employed both for
subscriptions (if shared subscription is used) and for publishing to
a remote broker.
Each with a more refined set of responsibilities, at the cost of slight
code duplication. Also provide two different config fields for each pool
size.
With fixed typings and empty pool handling.
* emqx_connector 0.1.25
* emqx_rule_engine 5.0.19
* emqx_ee_bridge 0.1.15
@zmstone
Copy link
Member

zmstone commented May 30, 2023

Need a changelog for this?

keynslug and others added 2 commits May 30, 2023 22:21
@keynslug keynslug merged commit a268832 into emqx:master May 30, 2023
160 of 163 checks passed
@keynslug keynslug deleted the fix/EEC-856/mqtt branch May 30, 2023 20:28
@yanzhiemq
Copy link
Collaborator

yanzhiemq commented Jun 13, 2023

Enhancements

  • The MQTT bridge has been enhanced to utilize connection pooling and leverage available parallelism, substantially improving throughput.

    As a consequence, single MQTT bridge now uses a pool of clientids to connect to the remote broker.

@yanzhiemq
Copy link
Collaborator

yanzhiemq commented Jun 13, 2023

增强

  • 对 MQTT 桥接进行了增强,利用连接池和可用的并行性,大大提高了吞吐量。
    因此,单个 MQTT 桥接现在使用一组 clientid 连接到远程代理。

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.

None yet

4 participants