Many domains of human life are more and moreimpacted by applications of the Internet of Things (i.e., IoT).The embedded devices produce masses of data day after dayrequiring a strong network infrastructure. The inclusion ofmessaging protocols like MQTT is important to ensure as fewerrors as possible in sending millions of IoT messages. Thisprotocol is a great component of the IoT universe due to itslightweight design and low power consumption. DistributedMQTT systems are typically needed in actual applicationenvironments because centralized MQTT methods cannotaccommodate a massive volume of data. Although beingscalable decentralized MQTT systems, they are not suited totraffic workload variability. IoT service providers may incurexpense because the computing resources are overestimated.This points to the need for a new approach to adapt workloadfluctuation. Through proposing a modular MQTT framework,this article provides such an elasticity approach. In order toguarantee elasticity of MQTT server cluster while maintainingintact IoT implementation, the MQTT framework used offthe-shelf components. The elasticity feature of our frameworkis verified by various experiments.