Fog computing is a distributed computing concept that brings cloud services out to the network's edge. Real-time user queries and data streams are processed by cloud nodes. Tasks should be evenly divided among fog nodes in order to maximize speed and efficiency, optimize resource efficiency, and reaction time. Real-time user requests and data flow processing are done by cloud nodes. Nodes in a network must share responsibilities in a balanced manner in order to maximize speed and efficiency, resource efficiency, and reaction time, hence in this article, a novel approach is presented. When it comes to fog computing, load balancing essential suggested to be improved. According to the suggested algorithm, a task submitted to the fog node via a mobile device would be processed by the fog node using reinforcement learning before being passed on to another fog node. Neighbor or let the cloud handle it. According to the simulation findings, the suggested algorithm has achieved a reduced execution time than other compared approaches by properly allocating the work among the nodes. Consequently, the suggested technique has reduced the chance of incorrect job assignment by 24.02% and the response time to the user by 31.60% when compared to similar methods.