Topic strategy

For example I have 100k IoT devices. I need to send telemetry from them.
I can create one topic like devicetype/telemetry and use it for all devices and I can create topic for each device like devicetype/deviceID/telemetry.
What is the best topic strategy for Emqx for performance reasons?

I use a scheme like this:


telemetry would be a kind.

Each device subscribes to it’s recv topic for control messages and sends it’s data on it’s send topics.

It’s a bit hard to tell without benchmark or measurements, but my initial guess would be that devicetype/deviceID/telemetry will be faster. EMQX handles different topics in parallel, so having more topics will better utilize the backplane network.
On the other hand, it depends on the subscriber patterns. The worst case scenario is when a lot of clients (10s of thousands) each subscribe to a different wildcard topic filter, e.g. application/device1234123/send/#. Inserting a new wildcard subscription into the routing table is a little more expensive than subscribing to a topic without wildcards.
On the other hand, if all your subscribers will listen to something like application/+/send/+, it will create just a single routing table entry, and you’re fine.