Cloud computing have attracted a lot of attention recently due to increasing demand for high performance computing and storage. Resource allocation is one of the most important challenges in the cloud computing system especially when the clients have some Service Level Agreements (SLAs) and the total profit depends on how the system can meet these SLAs. Moreover, a data center typically hosts and manages a suite of application environments and a fixed number of servers that are allocated to these application environments in a way that maximizes a certain utility function. In this paper, we consider the problem of SLA-based joint optimization of application environment assignment, request dispatching from the clients to the servers, as well as resource allocation in a data center comprised of heterogeneous servers. The objective is to maximize the total profit, which is the total price gained from serving the clients subtracted by the operation cost of the data center. The total price depends on the average service request response time for each client as defined in their utility functions, while the operating cost is related to the total energy consumption. We propose a near-optimal solution of the joint optimization problem based on the Hungarian algorithm for the assignment problem, as well as convex optimization techniques, in a way that is similar to the constructive partitioning algorithm in VLSI computer-aided design (CAD). Experimental results demonstrate that the proposed near-optimal joint application environment assignment and resource allocation algorithm outperforms baseline algorithms by up to 65.7%.