Emerging technologies, such as self-driving cars and 5G communications, are raising new mobility and transportation possibilities in smart and sustainable cities, bringing to a new echo-system often referred to as Internet of Vehicles (IoV). In order to efficiently operate, an IoV system should take into account more stringent requirements with respect to traditional IoT systems, e.g., ultra-broadband connections, high-speed mobility, high-energy efficiency and requires efficient real-time algorithms. This paper proposes an energy and communication driven model for IoV scenarios, where roadside units (RSUs) need to be frequently assigned and re-assigned to the operating vehicles. The problem has been formulated as an Uncapacitated Facility Location Problem (UFLP) for jointly solving the RSU-to-vehicle allocation problem while managing the RSUs switch-on and -off processes. Differently from traditional UFLP approaches, based on static solutions, we propose here a fast-heuristic approach, based on a dynamic multi-period time scale mapping: the proposed algorithm is able to efficiently manage in real-time the RSUs, selecting at each period those to be activated and those to be switched off. The resulting methodology is tested against a set of benchmark instances, which allows us to illustrate its potential. Results, in terms of overall cost–mapping both energy consumption and transmission delays–, number of active RSUs, and convergence speed, are compared with static approaches, showing the effectiveness of the proposed dynamic solution. It is noticeable a gain of up to 11% in terms of overall cost with respect to the static approaches, with a moderate additional delay for finding the solution, around 0.8 s, while the overall number of RSUs to be switched on is sensibly reduced up to a fraction of 15% of the overall number of deployed RSUs, in the most convenient scenario.