Information technology is increasingly evolving towards a model of standardized services provided in a way similar to traditional public utilities such as water, electricity and gas. Within this paradigm, a considerable number of users access services according to their needs, regardless of where they are hosted or how they are delivered. Consequently, effective resource management becomes crucial. Despite the number of virtual machine management algorithms, the proposal of new techniques is required in order to tackle issues related to the optimal use of resources. Our proposal is based on the dynamic allocation of virtual machines (VMs) to meet the needs of users. In this work, we propose an algorithm for creating, adjusting and removing VMs based on requests, while ensuring optimal use of data center resources. Our reel-time algorithm adjusts resources leading to cost reduction and therefore performance improvement.