  The significant carbon footprint of the ICT sector calls for methodologies to
contain carbon emissions of running software. This article proposes a novel
framework for implementing, configuring and assessing carbon-aware interactive
software services. First, we propose a methodology to implement carbon-aware
services leveraging the Strategy design pattern to feature alternative service
versions with different energy consumption. Then, we devise a bilevel
optimisation scheme to configure which version to use at different times of the
day, based on forecasts of carbon intensity and service requests, pursuing the
two-fold goal of minimising carbon emissions and maintaining average output
quality above a desired set-point. Last, an open-source prototype of such
optimisation scheme is used to configure a software service implemented as per
our methodology and assessed against traditional non-adaptive implementations
of the same service. Results show the capability of our framework to control
the average quality of output results of carbon-aware services and to reduce
carbon emissions from 8% to 50%.
