Cloud service providers transfer some of their resources to the proximity of their users in order to increase the quality of services provided to them. Proper placement of servers, considering the number of service demands in different parts of the network, not only plays an important role in providing better services to users but also causes more effective use of resources and reduces their energy consumption. Some related research has been done in this context. However, designing a model that can meet the needs of both the users and the service providers has received less attention. On the other hand, most researchers use discrete models to select a number of candidate locations for resource deployment, while the proposed method explores the entire search area to find optimal locations for server placement. The proposed method (ESPB) using butterfly optimization algorithm(BOA), DVFS technic, and coral reefs optimization algorithm(CRO) seeks to find the best locations for edge servers. In the first step, BOA is used to find the best locations for resource deployment. Then the CRO algorithm is used to map between the optimal locations and the servers. The experiments show that the proposed method can effectively save energy and reduces network latency.