Numerous web services with the same function but different service qualities are constantly emerging on the network. Optimizing web service composition based on multiple candidate services sets an urgent problem in the service composition neighborhood. This paper modifies the traditional Firefly algorithm and adds exchange and mutation mechanisms to optimize the Web service composition efficiently in multiple candidate service sets. Meanwhile, it discretizes the continuous space of its solution set and better adapts to the service composition optimization problem. Experimental results show that compared with the GA, IA, SA, ACO, FACO, and EFACO algorithms, this algorithm has better optimization performance, faster speed, and higher energy efficiency for solving service composition optimization problems in the case of large-scale data. The higher the combined complexity of the solution, the stronger the performance compared to other algorithms. It can better deal with the increasingly complex situation of Web service composition problems.