In the quest to delve deeper into the burgeoning realm of the service-oriented Internet of Things (IoT), the pressing challenge of smoothly integrating functionalities within smart objects emerges prominently. IoT devices, notorious for their resource constraints, often lean heavily on cloud infrastructures to function effectively. However, the emergence of fog computing offers a promising alternative, allowing the processing of IoT applications closer to the sensors and thereby slashing delays. This research develops a novel method for IoT service composition that leverages both fog and cloud computing, utilizing an enhanced version of the Artificial Bee Colony (ABC) algorithm to refine its convergence rate. The approach introduces a Dynamic Reduction (DR) mechanism designed to perturb dimensions innovatively. Traditionally, the ABC algorithm generates new solutions that closely mimic their parent solutions, which unfortunately slows down convergence. By initiating the process with significant dimension disparities among solutions and gradually reducing these disparities over successive iterations, this method strikes an optimal balance between exploration and exploitation through dynamic adjustment of dimension perturbation counts. Comparative analyses against contemporary methodologies reveal significant improvements: a 17% decrease in average energy consumption, a 10% boost in availability, an 8% enhancement in reliability, and a remarkable 23% reduction in average cost. Combining the strengths of fog and cloud computing with the refined ABC algorithm through the Dynamic Reduction mechanism significantly advances the efficiency and effectiveness of IoT service compositions.