  Microservices architecture offers various benefits, including granularity,
flexibility, and scalability. A crucial feature of this architecture is the
ability to autoscale microservices, i.e., adjust the number of replicas and/or
manage resources. Several autoscaling solutions already exist. Nonetheless,
when employed for diverse microservices compositions, current solutions may
exhibit suboptimal resource allocations, either exceeding the actual
requirements or falling short. This can in turn lead to unbalanced
environments, downtime, and undesirable infrastructure costs. We propose MS-RA,
a self-adaptive, requirements-driven solution for microservices autoscaling.
MS-RA utilizes service-level objectives (SLOs) for real-time decision making.
Our solution, which is customizable to specific needs and costs, facilitates a
more efficient allocation of resources by precisely using the right amount to
meet the defined requirements. We have developed MS-RA based on the MAPE-K
self-adaptive loop, and have evaluated it using an open-source
microservice-based application. Our results indicate that MS-RA considerably
outperforms the horizontal pod autoscaler (HPA), the industry-standard
Kubernetes autoscaling mechanism. It achieves this by using fewer resources
while still ensuring the satisfaction of the SLOs of interest. Specifically,
MS-RA meets the SLO requirements of our case-study system, requiring at least
50% less CPU time, 87% less memory, and 90% fewer replicas compared to the HPA.
