Grid balancing (keeping equal generation and consumption levels) is an essential requirement for power grid systems. This requirement has traditionally been fulfilled by existing flexibility mechanisms that provide voltage and frequency regulation. However, the recent interest in greening the energy supply by using more renewable energy sources presents new grid balancing challenges. Such volatile energy sources introduce generation-side uncertainty and cause the existing flexibility mechanisms to fall short more often on providing enough balancing capacity. It is thus essential to increase the system flexibility in order to safely accommodate larger shares of renewable input.To that end, we propose in this thesis new market-based approaches that allow cloud datacenters to be used as managed loads to provide the needed system flexibility. Datacenters are suitable to act as managed loads because they consume large amounts of energy and have flexible energy demands. However, the existing datacenter-based grid balancing approaches have only considered owner-operated datacenters and only focused on providing downward flexibility to reduce energy consumption at times of generation shortage. The work presented in this thesis introduces new demand-side management approaches that can provide upward flexibility (to combat the rising frequency of overgeneration events associated with the use of renewable sources) and is compatible with public cloud datacenters (to allow a wider range of datacenters to participate in grid balancing). The proposed systems rely on the idea of migrating the cloud workloads of large-scale cloud customers (cloud brokers, that aggregate the workloads of end-customers) between datacenters to correct energy imbalances. We start with systems that target the overgeneration problem by selling the excess energy at a reduced cost (sold as "energy credits" to differentiate it from energy sold at the regular price) to allow for its quick consumption. The proposed systems start by selling the energy credits at a fixed reduced cost, then using an auction to determine the sale price, and later using a combined auctioning-scheduling optimization formulation to ensure available capacity for the migrated cloud workloads. We then generalize I would also like to thank all my TA and lab colleagues that I met and had the opportunity to work with in Carleton during my program.Last but not least, I like to thank my family for their continued encouragement and support that made going through this long journey easier to do. v