Skip to content

cloudfoundry/app-autoscaler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Application Autoscaler

The Application Autoscaler provides the capability to adjust the computation resources for Cloud Foundry applications through:

  • Dynamic scaling based on application performance metrics
  • Dynamic scaling based on custom metrics
  • Scheduled scaling based on time

This repository contains the core Application Autoscaler source code, extracted and refactored from app-autoscaler-release.

Architecture

The Application Autoscaler consists of several microservices and are deployed as CF Applications

Component Description
api Public-facing API server for policy management and scaling history
servicebroker Cloud Foundry service broker implementation
scheduler Manages scheduled scaling policies and triggers scaling actions
eventgenerator Evaluates scaling rules and generates scaling events based on metrics
scalingengine Executes scaling decisions by adjusting application instances
metricsforwarder Forwards custom application metrics to the autoscaler
operator Manages autoscaler operations and instance synchronization

API Specifications

OpenAPI specifications are available in the openapi/ directory:

  • application-metric-api.openapi.yaml - Application metrics API
  • custom-metrics-api.openapi.yaml - Custom metrics submission API
  • policy-api.openapi.yaml - Scaling policy management API
  • scaling-history-api.openapi.yaml - Scaling history query API
  • internal-scaling-history-api.openapi.yaml - Internal scaling history API

Local Development

Prerequisites

  • Go 1.24.3 or later
  • Docker to spin up required databases
  • devbox (optional but recommended) - starts a shell with all required tools
  • Maven for building the Java-based scheduler component
  • direnv (optional) to automatically configure the development environment

Make Targets

Target Description
make generate-fakes Generate test mocks/fakes
make test Run unit tests against PostgreSQL
make integration Run integration tests against PostgreSQL
make acceptance-tests Run acceptance tests (see acceptance/README.md)
make lint Check code style
OPTS=--fix make lint Check code style and apply auto-fixes
make fmt Format Go code
make clean Remove build artifacts and generated code
make mta-build Build MTA archive for deployment
make mta-deploy Deploy to Cloud Foundry using MTA

Use Application Autoscaler Service

Refer to user guide for the details of how to use the Auto-Scaler service, including policy definition, supported metrics, public API specification and command line tool.

Monitor Microservices

The app-autoscaler provides a number of health endpoints that are available externally that can be used to check the state of each component. Each health endpoint is protected with basic auth (apart from the api server), the usernames are listed in the table below, but the passwords are available in credhub.

Component Health URL Username Password Key
eventgenerator https://autoscaler-eventgenerator.((system_domain))/health eventgenerator /autoscaler_eventgenerator_health_password
metricsforwarder https://autoscaler-metricsforwarder.((system_domain))/health metricsforwarder /autoscaler_metricsforwarder_health_password
scalingengine https://autoscaler-scalingengine.((system_domain))/health scalingengine /autoscaler_scalingengine_health_password
operator https://autoscaler-operator.((system_domain))/health operator /autoscaler_operator_health_password
scheduler https://autoscaler-scheduler.((system_domain))/health scheduler /autoscaler_scheduler_health_password

Running Tests

# Run all unit tests
make test

# Run integration tests
make integration

# Run acceptance tests (requires deployed autoscaler)
make acceptance-tests

Note: Running tests will automatically spin up the PostgreSQL database via Docker.

Database Setup

The autoscaler supports PostgreSQL.

To manually start a local database for development:

make start-db                    # Start PostgreSQL

To stop the database:

make stop-db                     # Stop PostgreSQL

Documentation

Related Repositories

License

This project is released under version 2.0 of the Apache License.

About

Auto Scaling for CF Applications

Resources

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 33