Skip to content

Issue: Config File Storage is Not Scalable in Multi-Instance Setup #86

@pavanputhra

Description

@pavanputhra

The current approach of saving configuration directly to a file is not scalable when running multiple API instances.

Problem:

  • Only the instance receiving the update request writes to its own local file.
  • Other instances do not get the updated config, leading to out-of-sync configurations.

Why it seems fine now:

Currently, all containers mount the same file on a single machine, so updates are shared.

When it breaks:

In a multi-host setup (containers on different machines), each instance has its own local copy of the config file. Updates on one instance will not propagate to others.

Even worse:

The API server and backend pipeline might be reading from different copies of the config file, causing inconsistent behavior.

Current implementation (redacted)

@api_router.post("/config", ...)
async def post_config(config: Dict) -> None:
    with open(os.getenv("CONSERVER_CONFIG_FILE"), "w") as f:
        yaml.dump(config, f)
Current (Problematic) Approach:

                          ┌─────────────────┐
                          │  Load Balancer  │
                          └─────────┬───────┘
                                    │
                               POST /config
                                    │
                                    ▼
┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   API Server 1  │    │   API Server 2  │    │   API Server 3  │
│                 │    │                 │    │                 │
│ ┌─────────────┐ │    │ ┌─────────────┐ │    │ ┌─────────────┐ │
│ │config.yaml  │ │    │ │config.yaml  │ │    │ │config.yaml  │ │
│ │(updated)    │ │    │ │(stale)      │ │    │ │(stale)      │ │
│ └─────────────┘ │    │ └─────────────┘ │    │ └─────────────┘ │
└─────────────────┘    └─────────────────┘    └─────────────────┘
         ▲                                                      
         │                                                      
         │ Request routed to                                    
         │ only one instance



Proposed Solution

Store the YAML config in Redis, since Redis is already part of our architecture and is accessible by all instances.

                          ┌─────────────────┐
                          │  Load Balancer  │
                          └─────────┬───────┘
                                    │
                               POST /config
                                    │
                                    ▼
┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   API Server 1  │    │   API Server 2  │    │   API Server 3  │
└────────┬────────┘    └────────┬────────┘    └────────┬────────┘
         │                      │                      │
         ▼                      ▼                      ▼
                      ┌─────────────────┐
                      │  Redis (Shared) │
                      │  Config Store   │
                      └─────────────────┘

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions