Documentation

Server Architecture - Workers

Guide to dynamic worker configuration in the Coreiix system based on deployment environments.

The system architecture in Coreiix regarding Workers relies primarily on the core configuration file (app/config.py and .env) and the startup script (start.py). The number of workers is determined dynamically and intelligently based on the DEPLOYMENT_PROFILE.

The system utilizes the Uvicorn server to run the FastAPI application. Worker management and structure vary depending on the operating environment as follows:


1. Development Environment (dev Profile)

  • Number of Workers: 1 (Single worker).
  • Behavior: The server runs with automatic reload enabled (reload=True), making it ideal for developers. The server restarts instantly upon any code modification without requiring manual intervention.

2. Small Business Environment (small Profile)

  • Number of Workers: 2 (Two workers).
  • Target Usage: Dedicated to companies with fewer than 10 users. This environment provides excellent stability by running multiple processes to handle simple concurrent requests without consuming excessive server resources.

3. Enterprise Production Environment (enterprise Profile)

  • Number of Workers: Calculated dynamically based on server capabilities.
  • Formula Used: (CPU Cores × 2) + 1
  • Target Usage: Designed for large companies with high traffic and over 100 users. This standard formula ensures maximum utilization of server architecture (Multi-processing) and load distribution to process thousands of concurrent requests with the highest efficiency.

System Flexibility and Overrides

The system provides complete flexibility for system administrators to manually define the number of workers, overriding the default profiles mentioned above, through two methods:

  • Via the .env file: By directly adding the WORKERS variable.
  • Via Command Line Interface (CLI): When starting the system, the number of workers can be passed as follows:
python start.py --workers 4

This architecture ensures that the system is scalable and smoothly accommodates businesses of all sizes.