What is the difference between an Azure IoT Hub and an Azure Event Hub?
Well, an Azure IoT Hub contains an Event Hub and hence essentially is an Event Hub plus additional features. An important additional feature is that an Event Hub can only receive messages, whereas an IoT Hub additionally can also send messages to individual devices. Further, an Event Hub has access security on hub level, whereas an IoT Hub is aware of the individual devices and can grand and revoke access on device level.
There is a good overview article (Comparison of IoT Hub and Event Hubs) by Microsoft that points out the differences. Obviously, if you want to use features like cloud-to-device communication or per-device security and performance management, you should consider an IoT Hub, rather than implement a custom solution. What the article does not explain is the difference in terms of costs.
For both types of hubs, the price depends on the number of messages being processed and the processed data volume per time, the so called throughput. But a throughput unit means different things for the different hubs.
The smallest possible (standard) Event Hub with one throughput unit can process per second up to 1000 events with a total size of up to 1 MB and costs about US$ 22 per month. Additionally, per million messages 2.8 US Cents have to be paid (Event Hub Pricing). If you want to process n times that number of events or data volume per second, then you have to purchase n throughput units, each at $ 22 per month (the actual billing is per hour). So, if you go to the limits of an Event Hub with one throughput unit, you can send 86.4 million events with 86,4 GB per day, i.e. about 2.6 billion events and 2.6 TB per month at a cost of $ 22 + $ 73 = $ 95 per month.
If you wanted to achieve the same with an IoT Hub, you would need a size S3 IoT Hub, which costs $ 5000 per month (IoT Hub Pricing).
For an IoT Hub the limits are on a per-day basis and for an Event Hub per-second. Hence, an Event Hub has to be sized for its peak throughput, whereas an IoT Hub can be sized for its daily average, allowing for a significantly higher peak performance.
The number of messages per day of an IoT Hub is metered in blocks of 4 K. Hence a 10 K message counts as 3 messages towards the daily maximum. If your individual messages are much smaller than 4 K, then the „waste“ can be significant.
If you go to the limits of an S3 IoT Hub with one throughput unit (i.e. 300 million events per day with 4 K per event at a cost of $ 5000 per month), then in terms of Event Hub pricing you would need an Event Hub with 14 throughput units (MB/s) at a cost of 14 * $ 22 + 300 * 30 * $ 0.028 = $ 308 + $ 252 = $ 560 per month.
Hence, depending on your message sizes and throughput needs, an IoT Hub is 9 to 53 times more expensive than an Event Hub. So you might want to think carefully, if and for what you use an IoT Hub. As pointed out in (Comparison of IoT Hub and Event Hubs), it is not uncommon to use both, an IoT Hub and an Event Hub, each for the features it is best suited for.