5G Abstract–With the rise of mobile edge computing (MEC) in recent years, it is now possible to combine cloud computing and provide services directly at the edge of the network, allowing end users to access rich applications and services with a significant reduction in end-to-end delay and device energy consumption. However, in the face of an abundance of unloaded users, due to the limited resource capacity of a single MEC and the need for communication between the edge servers themselves, the optimization of task unloading and resource allocation has become a particularly critical problem. Therefore, this paper mainly focuses on the resource optimization problem in multi-user and multi-server systems, so as to maximize the usefulness of unloading on the system given constrained resources. This utility is measured by the weighted sum of the relative improvement values of user delay and energy consumption. We divide the optimization issue into two parts: unloading choice and resource allocation problem, and design a heuristic algorithm based on improved simulated annealing algorithm for optimization. On this basis, we apply the Karush Kuhn Tucker (KKT) condition to find the best server computing resource allocation method and the suboptimal solution in polynomial time. At the same time, the algorithm can optimize the system according to different users' preferences for delay or energy consumption, and can flexibly meet different needs. The algorithm's performance is near to the ideal solution, according to simulation findings, and it considerably increases the user's unloading feasibility.