In the context of mobile edge computing (MEC), the delay-sensitive tasks can achieve real-time data processing and analysis by offloading to the MEC servers. The objective is maximizing social welfare in an auction-based model. However, the distances between mobile devices and access points lead to differences in energy consumption. Unfortunately, existing works have not considered both maximizing social welfare and minimizing energy consumption. Motivated by this, we address the problem of joint resource allocation and task offloading in MEC, with heterogeneous MEC servers providing multiple types of resources for mobile devices (MDs) to perform tasks remotely. We split the problem into two sub-problems: winner determination and offloading decision. The first sub-problem determines winners granted the ability to offload tasks to maximize social welfare. The second sub-problem determines how to offload tasks among the MEC servers to minimize energy consumption. In the winner determination problem, we propose a truthful algorithm that drives the system into equilibrium. We then show the approximate ratios for single and multiple MEC servers. In the offloading decision problem, we propose an approximation algorithm. We then show it is a polynomial-time approximation scheme for a single MEC server. Experiment results show that our proposed mechanism finds high-quality solutions in changing mobile environments.