The Internet of things (IoT) paradigm has emerged to connect the number of devices using the Internet resulting in the deployment of smart cities. Cloud computing has been applied to execute the computational demands of IoT devices by collecting data from the physical environment of a smart city. However, cloud computing could not become a proper choice for latency-sensitive applications because of remote cloud data centers. To overcome this challenge, fog computing has emerged to deal with the inherent limitations of cloud computing environment through provision of computing to the edge of a network. However, resource allocation of IoT service requests among fog nodes is considered as an NP-hard problem, which should be addressed in the fog computing environment. In this paper, an efficient optimization approach based on improved binary particle swarm optimization (IBPSO) algorithm has been provided for resource allocation of IoT requests in the hybrid fog–cloud computing environment. The proposed method aims to reduce the service request latency with ensuring load balancing among fog nodes. The performance of the proposed algorithm has been compared by the binary genetic algorithm (BGA), binary particle swarm optimization (BPSO), binary grey wolf optimization (BGWO)-based, and ranked-based resource allocation methods in terms of latency, missed deadline requests, run time, and load balancing. The results show that the proposed algorithm outperformed with an average of around 11%\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$11\%$$\end{document}, 22%\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$22\%$$\end{document}, 21%\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$21\%$$\end{document}, and 22%\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$22\%$$\end{document} percent in the IBPSO-based method rather than the BGA-based, BPSO-based, BGWO-based, and ranked-based resource allocation methods, respectively. Moreover, the resource allocation based on IBPSO achieved around 11%\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$11\%$$\end{document}, 28%\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$28\%$$\end{document}, 27%\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$27\%$$\end{document}, and 25%\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$25\%$$\end{document} decline in total latency compared to the BGA-based, BPSO-based, BGWO-based, and ranked-based resource allocation methods. Furthermore, the run time of the proposed algorithm could enhance by 45%\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$45\%$$\end{document}, 9%\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$9\%$$\end{document}, and 8%\documentclass[12pt]{minimal}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{mathrsfs}
\usepackage{upgreek}
\setlength{\oddsidemargin}{-69pt}
\begin{document}$$8\%$$\end{document} compared to the BGA-based, BPSO-based, and BGWO-based resource allocation methods.