The combination of MEC and federated learning is a promising research direction in network intelligence. However, the performance and efficiency of federated learning cannot be guaranteed in MEC systems. In this paper, in order to balance the model accuracy and resource consumption of federated learning in MEC systems, a framework for deploying federated learning in MEC systems is proposed. Based on this framework, the model accuracy performance of federated learning is analyzed, and a tractable upper bound of accuracy loss is given. In addition, an optimization problem is proposed to balance the accuracy loss and resource consumption of the training model, and a joint optimization algorithm with high computational efficiency is designed to approach the optimal solution. Finally, numerical simulation and experimental results show that the joint optimization algorithm can not only improve the model accuracy of federated learning, but also significantly reduce the resource consumption.