Due to the proliferation of requests in heterogeneous resources in edge computing, the existence of a large number of tasks and workloads in virtual machines in the edge computing environment is inevitable. Thus, load balancing strives to facilitate an even distribution of workload across available resources. Its purpose is to provide continuous service and to ensure fair load distribution among resources. Load balancing, with the aim of minimizing response time for tasks and improving resource efficiency, tries to do the proper mapping of tasks among virtual machines at a lower cost. Flow scheduling, on the other hand, assigns a task (group of tasks) to computational resources by prioritizing tasks, so that the relationship between them is maintained. Therefore, in this research, a hierarchical control framework for load balancing and assignment of tasks in edge computing services is presented in order to create load balancing. In the proposed method, in the first level, the genetic algorithm receives a set of tasks in a workflow. Genetic algorithm prioritizes and assigns tasks to resources according to time constraints, resource processing power, resource availability, and task cost. For this purpose, the integer linear programming optimization in the evaluation function of the genetic algorithm will be utilized. In the second level, considering the past load distribution in edge resources, we estimate the probability of load distribution among sources according to hidden Markov model (HMM). Finally, in order to optimally map tasks to the virtual machines in each host, we will use game theory with service quality factors as an evaluation function. Previous methods have provided a hierarchical control framework that aims to achieve conflicting goals within a data center, but does not use linear programming. Considering the use of service quality criteria as evaluation function parameters in heuristic and optimization methods in this research, it is expected that the results of this research will improve compared to previous methods.