A wide variety of novel services have been envisioned lately due to wearable gadgets, autonomous vehicles, and IoT applications. These services cannot directly be implemented using centralized cloud computing infrastructure due to large Wide Area Network (WAN) delays. Recently, edge computing is proposed to comply with the requirements of these services, where resilient local servers are accessed through fast wireless links. With this approach, real-time service access can be achieved by handling the user requests at the edge computing infrastructure. Since edge and cloud servers may potentially cooperate, operators can maximize their revenues by optimally deploying the computational resources, distributing the services within the network, and assigning the tasks generated by the end-users. These decisions, each of which is a difficult task on its own, are integrated in this study and formulated as a mixed-integer linear programming (MILP) model to optimally design a multi-tier computation structure. Because of the scalability issue, a heuristic algorithm based on the Lagrangian relaxation of the MILP formulation is proposed to solve larger instances. Additionally, in order to provide an opportunity for the operators to find a feasible solution in a very short time, a greedy heuristic approach is presented. To evaluate the performance of the proposed methods, computational experiments are conducted on a broad suite of randomly generated topologies. The results indicate that the proposed approaches can obtain high-quality solutions within the given time limit.