# cos-in/iluvatar-faas architecture

> Architecture diagram of the GitHub repository cos-in/iluvatar-faas, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cos-in/iluvatar-faas
- Repository: https://github.com/cos-in/iluvatar-faas

## Overview

##### Main Components and Architecture

The system should be represented with these key components:

a) Core Components:
- Controller (iluvatar_controller)
- Worker Nodes (iluvatar_worker)
- Load Generator (iluvatar_load_gen)
- Energy Monitor (iluvatar_energy_mon)

b) Supporting Services:
- Container Runtime (containerd/docker)
- Network Management
- Resource Management (CPU/GPU/Memory)
- Monitoring & Metrics (InfluxDB)

##### Component Relationships

a) Control Flow:
- Controller → Workers (load balancing, registration)
- Load Generator → Controller (workload distribution)
- Workers → Container Runtime (function execution)
- Energy Monitor → Workers (resource monitoring)

b) Data Flow:
- Function invocation path
- Metrics collection path
- Resource allocation flow

##### Detailed Component Breakdown

For each major component, include:

Worker Node:
- Container Pool
- Invocation Queue
- Resource Managers (CPU/GPU)
- Network Namespace Manager
- Health Monitor

Controller:
- Load Balancer
- Registration Service
- Health Check Service
- Async Invoke Handler

##### Implementation Details to Highlight

Key architectural features:
- Support for both simulation and live execution
- Load generation capabilities
- Energy monitoring integration
- Container runtime abstraction
- Queue management systems
- Resource isolation mechanisms

##### Load balancing and scaling mechanisms

This will create a comprehensive yet clear representation of Ilúvatar's architecture that highlights its research-focused design while showing all essential components and their interactions.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Core Components
    subgraph Core["Core Components"]
        Controller["Controller"]:::core
        Worker["Worker Node"]:::core
        LoadGen["Load Generator"]:::core
        EnergyMon["Energy Monitor"]:::core
    end

    %% Worker Components
    subgraph WorkerComponents["Worker Node Components"]
        ContainerPool["Container Pool"]:::resource
        InvokeQueue["Invocation Queue"]:::resource
        ResourceMgr["Resource Managers"]:::resource
        NetworkMgr["Network Namespace Manager"]:::resource
        HealthMon["Health Monitor"]:::resource
    end

    %% Controller Components
    subgraph ControllerComponents["Controller Components"]
        LoadBalancer["Load Balancer"]:::control
        RegService["Registration Service"]:::control
        HealthCheck["Health Check Service"]:::control
        AsyncInvoke["Async Invoke Handler"]:::control
    end

    %% Supporting Services
    subgraph Support["Supporting Services"]
        ContainerRT["Container Runtime"]:::support
        InfluxDB[(InfluxDB)]:::database
    end

    %% Relationships
    Controller --> Worker
    LoadGen --> Controller
    EnergyMon --> Worker
    Worker --> ContainerRT
    
    %% Worker Internal Relations
    Worker --> ContainerPool
    Worker --> InvokeQueue
    Worker --> ResourceMgr
    Worker --> NetworkMgr
    Worker --> HealthMon

    %% Controller Internal Relations
    Controller --> LoadBalancer
    Controller --> RegService
    Controller --> HealthCheck
    Controller --> AsyncInvoke

    %% Monitoring Flow
    Worker --> InfluxDB
    Controller --> InfluxDB
    EnergyMon --> InfluxDB

    %% Click Events
    click Controller "https://github.com/COS-IN/iluvatar-faas/blob/master/src/Ilúvatar/iluvatar_controller_library/src/server/controller.rs"
    click Worker "https://github.com/COS-IN/iluvatar-faas/blob/master/src/Ilúvatar/iluvatar_worker_library/src/worker_api/iluvatar_worker.rs"
    click LoadGen "https://github.com/COS-IN/iluvatar-faas/blob/master/src/Ilúvatar/iluvatar_load_gen/src/main.rs"
    click EnergyMon "https://github.com/COS-IN/iluvatar-faas/blob/master/src/Ilúvatar/iluvatar_energy_mon/src/main.rs"
    click ContainerPool "https://github.com/COS-IN/iluvatar-faas/tree/master/src/Ilúvatar/iluvatar_worker_library/src/services/containers/"
    click NetworkMgr "https://github.com/COS-IN/iluvatar-faas/blob/master/src/Ilúvatar/iluvatar_worker_library/src/services/network/namespace_manager.rs"
    click ResourceMgr "https://github.com/COS-IN/iluvatar-faas/tree/master/src/Ilúvatar/iluvatar_worker_library/src/services/resources/"
    click LoadBalancer "https://github.com/COS-IN/iluvatar-faas/tree/master/src/Ilúvatar/iluvatar_controller_library/src/services/load_balance/"
    click InvokeQueue "https://github.com/COS-IN/iluvatar-faas/tree/master/src/Ilúvatar/iluvatar_worker_library/src/services/invocation/"
    click HealthMon "https://github.com/COS-IN/iluvatar-faas/blob/master/src/Ilúvatar/iluvatar_worker_library/src/services/worker_health.rs"
    click InfluxDB "https://github.com/COS-IN/iluvatar-faas/blob/master/src/Ilúvatar/iluvatar_library/src/influx.rs"
    click RegService "https://github.com/COS-IN/iluvatar-faas/blob/master/src/Ilúvatar/iluvatar_controller_library/src/services/registration.rs"

    %% Styles
    classDef core fill:#2374ab,stroke:#000,stroke-width:2px,color:#fff
    classDef resource fill:#57a773,stroke:#000,stroke-width:1px,color:#fff
    classDef control fill:#4392f1,stroke:#000,stroke-width:1px,color:#fff
    classDef support fill:#a8a8a8,stroke:#000,stroke-width:1px,color:#fff
    classDef database fill:#ffd23f,stroke:#000,stroke-width:1px,color:#000

    %% Legend
    subgraph Legend
        CoreL["Core Service"]:::core
        ResourceL["Resource Component"]:::resource
        ControlL["Control Component"]:::control
        SupportL["Support Service"]:::support
        DatabaseL[(Database)]:::database
    end
```
