  Power consumption is a dominant and still growing cost factor in data
centers. In time periods with low load, the energy consumption can be reduced
by powering down unused servers. We resort to a model introduced by Lin,
Wierman, Andrew and Thereska that considers data centers with identical
machines, and generalize it to heterogeneous data centers with $d$ different
server types. The operating cost of a server depends on its load and is modeled
by an increasing, convex function for each server type. In contrast to earlier
work, we consider the discrete setting, where the number of active servers must
be integral. Thereby, we seek truly feasible solutions. For homogeneous data
centers ($d=1$), both the offline and the online problem were solved optimally
by Albers and Quedenfeld (2018).
  In this paper, we study heterogeneous data centers with general
time-dependent operating cost functions. We develop an online algorithm based
on a work function approach which achieves a competitive ratio of $2d + 1 +
\epsilon$ for any $\epsilon > 0$. For time-independent operating cost
functions, the competitive ratio can be reduced to $2d + 1$. There is a lower
bound of $2d$ shown by Albers and Quedenfeld (2021), so our algorithm is nearly
optimal. For the offline version, we give a graph-based
$(1+\epsilon)$-approximation algorithm. Additionally, our offline algorithm is
able to handle time-variable data-center sizes.
