The rapid advancement in the Internet of things applications generates a considerable amount of data and requires additional computing power. These are serious challenges that directly impact the performance, latency, and network breakdown of cloud computing. Fog Computing can be depended on as an excellent solution to overcome some related problems in cloud computing. Fog computing supports cloud computing to become nearer to the Internet of Things. The fog's main task is to access the data generated by the IoT devices near the edge. The data storage and data processing are performed locally at the fog nodes instead of achieving that at cloud servers. Fog computing presents high-quality services and fast response time. Therefore, Fog computing can be the best solution for the Internet of things to present a practical and secure service for various clients. Fog computing enables sufficient management for the services and resources by keeping the devices closer to the network edge. In this paper, we review various computing paradigms, features of fog computing, an in-depth reference architecture of fog with its various levels, a detailed analysis of fog with different applications, various fog system algorithms, and also systematically examines the challenges in Fog Computing which act as a middle layer between IoT sensors or devices and data centers of the cloud.