Fog networks are a proposed solution to allow the generalization of endpoint devices. Previous efforts have been dedicated to the optimization of fog resource initial installations, but no solution has been proposed to optimize the real-time resource allocation of a fog network in operation. An exact model was developed to compute the upper bound for profit generation with a processing time exponentially related to the network size. A real-time heuristic was also developed to allow for the network to perform operations. Its performance remained constant through a variety of tested networks at a profit result between 78 to 88% of the exact model and a far reduced processing time. The heuristic model uses a statistical approach to predict the requirements of future tasks. The results of this thesis demonstrate that the use of the heuristic model is essential to the efficient operation of a long term fog computing network.