In this correspondence, a novel framework is proposed for analyzing data offloading in a multi-access edge computing system. Specifically, a two-phase algorithm, is proposed, including two key phases: 1) user association phase and 2) task offloading phase . In the first phase, a ruin theory-based approach is developed to obtain the users association considering the users' transmission reliability and resource utilization efficiency. Meanwhile, in the second phase, an optimization-based algorithm is used to optimize the data offloading process. In particular, ruin theory is used to manage the user association phase, and a ruin probability-based preference profile is considered to control the priority of proposing users. Here, ruin probability is derived by the surplus buffer space of each edge node at each time slot. Giving the association results, an optimization problem is formulated to optimize the amount of offloaded data aiming at minimizing the energy consumption of users. Simulation results show that the developed solutions guarantee system reliability, association efficiency under a tolerable value of surplus buffer size, and minimize the total energy consumption of all users.