This paper analyzes the performance of Internet of Things (IoT) protocols, specifically MQTT and HTTP, in fog and cloud computing environments amidst high data traffic. It presents a proposed architecture designed to reduce latency by processing data closer to edge devices, demonstrating that MQTT outperforms HTTP in terms of response time, throughput, and packet loss. The findings indicate that fog computing significantly enhances performance compared to traditional cloud computing configurations.