Does each MQTT trigger has its own connection or do they share one?

I’m having around 30 automations that uses MQTT event as trigger. I’m a little bit concerned about the performance issue that may come alone. So just wonder if each MQTT trigger creates a connection to the broker, or do all the MQTT triggers shared one connection, but just listen to different topics?

Thanks

There are no permanent connections in MQTT.

Home assistant will subscribe to a topic for each of your event triggers by informing the broker of the subscriptions. Then the connection is closed after an idle time.

The broker will push an update for each subscription to Home Assistant when a change occurs on any of the subscribed topics. Then the connection will close after an idle time. If there are multiple changes occurring in a short period of time, from looking at the logs in the past, I am reasonably sure these are buffered and sent one after the other on the single connection to Home Assistant.

Either way I make extensive use of MQTT and neither the broker nor Home Assistant has an issue keeping up with message storms produced by events like power outages.

I didn’t realise it was possible that the MQTT broker could instantiate a connection … I assumed HA would keep one permanent client socket connection open to the broker and updates would come in over that…

Yeah you’re right I got that wrong. The client is always responsible for making the connection:

https://www.hivemq.com/blog/mqtt-essentials-part-3-client-broker-connection-establishment/

So they are persistent connections and there is only one connection between home assistant and the broker.

Thanks for the demystifying.