In the context of a smart city with a 5G mobile technology network and beyond, we propose a model using Unmanned Aerial Vehicles (UAVs) to carry Virtual Network Functions (VNFs).These UAVs support the network along with the existing fixed network infrastructure. To maximize the lifetime of the UAVs and consider resource constraints, we propose a Mixed Integer Linear Programming (MILP) model. In addition, we consider the network traffic generated by crowds at specific locations in the city. In this study, we address the issue of UAV deployment and evaluate our solution using a practical scenario, such as a Distributed Denial of Service (DDoS) detection system. Through experiments, we analyze the performance of our proposed solution and its impact on improving the system's ability to handle input streams in different use cases. The results demonstrate the effectiveness of our approach in improving the overall computational capability.