One of the most important practical and timely operational problem associated with the performance of data centers for cloud computing is energy consumption. The fundamental approach for saving energy in a data center is right-sizing the number of servers; i.e., the determination of the minimum required number of servers to meet the load demand, allowing unnecessary servers to be turned off, so that energy usage can be minimized. The main challenge in designing such right-sizing algorithms is the fact that servers cannot be turned on instantaneously, so typically some estimation of the futuristic load is needed. Of course, the more uncorrelated the load arrival, the less accurate is such estimation. As the problem of right-sizing is NP-complete, a heuristic algorithm is required for practical deployment. In this paper, we first develop an efficient offline right-sizing heuristic, and we demonstrate that its performance is close to optimal. Rather than classifying jobs into a fixed number of types as prior works do, every arriving job is characterized with its own latency tolerance profile. Our offline heuristic, taking advantage of this latency tolerance, attempts to rearranges the jobs' processing times, so that the overall servers' demand is "smoothed". Then, based on the offline algorithm, we design an online algorithm that computes the real-time servers' right-sizing according to the arriving workload. As the key result of this paper, we show that the performance of the online algorithm closely approximates the performance of the offline algorithm, and that both closely approximate the optimal solution. We also demonstrate that the use of our algorithm corresponds to an over 50% operational cost reduction of a data center.