Nowadays, 5G networks are emerged and designed to integrate all the achievements of mobile and fixed communication networks, in which it can provide ultra-high data speeds and enable a broad range of new services with new cloud computing structures such as fog and edge. In spite of this, the complex nature of the system, especially with the varying network conditions, variety of possible mechanisms, hardware, and protocols, makes communication between these technologies challenging. To this end, in this paper, we proposed a new distributed and fog (DD-fog) framework for software development, in which fog and mobile edge computing (MEC) technologies and microservices approach are jointly considered. More specifically, based on the computational and network capabilities, this framework provides a microservices migration between fog structures and elements, in which user query statistics in each of the fog structures are considered. In addition, a new modern solution was proposed for IoT-based application development and deployment, which provides new time constraint services like a tactile internet, autonomous vehicles, etc. Moreover, to maintain quality service delivery services, two different algorithms have been developed to pick load points in the search mechanism for congestion of users and find the fog migration node. Finally, simulation results proved that the proposed framework could reduce the execution time of the microservice function by up to 70% by deploying the rational allocation of resources reasonably. © 2021 by the authors. Licensee MDPI, Basel, Switzerland.