With the increasing advancement in the applications of the Internet of Things (IoT), integrated Cloud Computing (CC) faces numerous threats such as performance, security, latency, and network breakdown.In this paper, we put forward various computing paradigms, features of fog computing, an in-depth reference architecture of fog with its various levels, a detailed analysis of fog with IoT, various fog system algorithms, and also systematically examine the challenges in Fog Computing which act as a middle layer between IoT sensors or devices and data centers of the cloud.It allows the administration of the services and resource provisioning outside CC, nearer to devices, at the network edge, or ultimately at places specified by Service Level Agreements (SLAs).Fog Computing is not a replacement for CC, but a prevailing component.