How asi-uniovi/fcma works
Project Type and Purpose
• FCMA is essentially an algorithmic framework that solves allocation problems for Container as a Service (CaaS) running on Infrastructure as a Service (IaaS) clouds.
• The core goal is to optimize the cloud customer’s cost by computing efficient allocations of application containers to virtual machines (VMs), using a model where instance classes are arranged in families.
• The project uses a two-phase (pre-allocation and allocation) process to derive solutions and integrates an ILP solver (via PuLP) to manage optimization trade-offs under different speed and cost-performance levels.
Breakdown of the File Structure and Its Implications for Architecture
• Top-Level Organization:
• The main library is in the "fcma" directory which contains several essential modules:
• fcma.py – Likely the entry point for the main FCMA logic.
• helper.py – Contains supporting functions.
• model.py – Defines core data structures (VMs, container groups, allocation models, etc.).
• serialization.py – Manages input/output or persistence of problem definitions or solutions.
• visualization.py – Contains the SolutionPrinter and possibly other tools to render the output.
• "examples" folder shows practical usage cases (e.g., aws_eu_west_1.py provides instance class families and example problems).
• "perf" holds performance test cases and sample JSON inputs for benchmarking scenarios.
• "tests" directory encompasses unit tests, integration tests, and expected outputs to ensure correctness.
• Setup-related files (e.g., setup.py, requirements.txt) show standard package configuration and dependency management.
Core Architectural Components and Their Relationships
a. Input and Configuration:
• Input Definitions: Applications, workloads, and instance class families are defined in user code and examples (e.g., examples/example1.py). They form the core “problem definition” where each application has specific computational and performance requirements.
• System Configuration: A “System” object is built by mapping tuples of (application, instance class family) to their performance and resource requirements. This drives the core optimization model.
b. Solver and Allocation Engine:
• FCMA Solver: The “Fcma” class (in fcma/fcma.py) takes the system configuration and workloads and orchestrates the solution process.
• Pre-allocation Phase: Uses an ILP (e.g., via PuLP solvers) to compute a preliminary allocation. This phase (detailed in README) may ignore memory constraints initially.
• Allocation Phase: Post-processes the pre-allocation output. If needed, it promotes VMs (scaling up instance classes) or adds new VMs to meet resource bounds such as memory and performance.
• The solver is parameterized by a “speed_level” (1, 2, or 3) which affects the trade-off between cost accuracy and run time.
c. Output and Visualization:
• The solution produced includes detailed VM allocations, container grouping, resource utilization, and statistical metrics (costs before and after allocation, solution quality, etc.).
• The “visualization” module (SolutionPrinter in visualization.py) is used to render and output the solution. Its design is modular, enabling both terminal output and possibly graphical visualizations.
d. Supporting Components:
• Testing Suite: The tests folder contains unit and integration tests that validate individual modules (serialization, allocation logic, etc.) and system-wide behaviors.
• Performance Benchmarks: The “perf” directory contains sample problem data JSON files, which can be used to benchmark run times and allocation results.
Incorporating Architectural Patterns and Design Principles
• Modularity: The separation into distinct modules (core logic, visualization, serialization) makes the system easier to maintain and extend.
• Dependency Injection: The solver’s integration with an external ILP engine suggests a design that promotes pluggable solver components.
• Separation of Concerns: Differentiating between problem formulation, solution (model objects), and post-solution validation/visualization.
Elements
• Clear labels for each component, such as:
• Configuration/Input Definitions (Applications, Workloads, Instance Class Families)
• Problem Constructor (System object)
• Optimization Engine (with two sub-components: Pre-allocation Phase and Allocation Phase)
• ILP Solver Integration (PuLP, gapRel parameter, and speed_level variation)
• Output/Result Compiler (VM allocations, container groups, statistics)
• Visualization/Reporting Component (SolutionPrinter)
• Testing and Benchmarking Modules (Tests, Perf inputs)
• From input definitions to the problem constructor.
• From the constructed problem to the optimization engine.
• From optimization engine phases to the Compilation of results.
• From compiled results to the visualization module.
• Annotations to indicate architectural decisions such as the two-phase allocation process, the separation between application domain logic and optimization, and the use of encapsulated modules for extensibility.
Putting It All Together
• The Input Layer: shows definitions of applications, workloads, and instance class families (with a reference to examples, like aws_eu_west_1.py).
• The System Setup Layer: where these inputs are mapped into the System object using classes from fcma/model.py.
• The Optimization Engine Layer: representing both phases of the solver. Illustrate the entry point in Fcma class (fcma.py) and branch it into pre-allocation (partial ILP and node aggregation) and then the allocation phase (VM promotion/addition).
• The Output and Post-Processing Layer: depicting the solution structure (VM allocations, container groups, performance statistics) along with the visualization tool (SolutionPrinter).
• Peripheral Components: include test modules and performance files as verification and benchmarking pieces.