Power consumption imposes a significant cost for data centers. Thus, it is not surprising that optimizing energy cost in data center is receiving increasing attention. In this thesis, we focus on the algorithmic issues at three levels of energy optimization for data centers: server level, local data center level and global data center level. At the server level, we analyze the common speed scaling algorithms in both worst-case model and stochastic model to answer some fundamental issues in the design of speed scaling algorithms. At the local data center level, we develop an online algorithm to make data center more power-proportional by dynamically adapting the number of active servers to match the current workload. At the global data center level, we propose a framework to explore the diversity of power prices and the diversity of propagation delays given geographically distributed data centers.