Comment to 'Slowing down video processing'
  • If you’re using Docker, it’s much easier to handle.

    Just create a dedicated container for video processing and limit its CPU and RAM. For example:

    # ----------------------------------------------------------------------------------#
    #                                                                                   #
    #   Copyright (C) 2009 - 2025 Coozila! Licensed under the MIT License.              #
    #   Coozila! Team    lab@coozila.com                                                #
    #                                                                                   #
    # ----------------------------------------------------------------------------------#
    
    # ----------------------------------------------------------------------------------#
    
    
    #   STACK NETWORK    ---------------------------------------------------------------#
    
    
    networks:
    
    
        #   Private network for application services    --------------------------------#
    
    
        una_private_network:
            #
            #   SSH command to create the Docker network: 
            #   docker network create --driver bridge una_private_network --subnet=172.16.0.0/16
            #
            external: true
    
    
        # ------------------------------------------------------------------------------#
    
    
        #   Private network for application services    --------------------------------#
    
    
        una_private_proxy_network:
            #
            #   SSH command to create the Docker network: 
            #   docker network create --driver bridge una_private_proxy_network --subnet=172.16.0.0/16
            #
            external: true
    
    #   UNA APPS    --------------------------------------------------------------------#
    caddy-reverse-proxy:
    # ----------------------------------------------------------------------------------#
    nginx-una-proxy:
    # ----------------------------------------------------------------------------------#
    
    nginx-video-proxy:
    # ----------------------------------------------------------------------------------#
    
    una:
    # ----------------------------------------------------------------------------------#
    
    una-db:
    # ----------------------------------------------------------------------------------#
    
    una-cron:
    # ----------------------------------------------------------------------------------#
    
    una-meet
    # ----------------------------------------------------------------------------------#
    
    una-messenger:
    # ----------------------------------------------------------------------------------#
    
    memcached-cluster:
    # ----------------------------------------------------------------------------------#
    
    elasticsearch-cluster
    # ----------------------------------------------------------------------------------#
    
    una-video:
      image: una/una-video:${UNA_VERSION}-${PHP_VERSION}
      container_name: una.video.${UNA_VERSION}-${PHP_VERSION}
      restart: always
      hostname: localhost
      env_file:
        - ../../.env 
      build:
        context: ../../apps/${UNA_VERSION}
        dockerfile: ../../compose/una-video/${PHP_VERSION}/Dockerfile
    
      deploy:
        resources:
          #
          #   Add limit for resource usage (CPU / RAM)
          #
          limits:
            cpus: '2'
            memory: 8G
    
      volumes:
        - ../../compose/una-video/${PHP_VERSION}/php.ini:/usr/local/etc/php/php.ini
        - ../../compose/una-video/${PHP_VERSION}/docker.conf:/usr/local/etc/php-fpm.d/docker.conf
        - ../../compose/una-video/${PHP_VERSION}/www.conf.default:/usr/local/etc/php-fpm.d/www.conf.default
        - ../../compose/una-video/${PHP_VERSION}/zz-docker.conf:/usr/local/etc/php-fpm.d/zz-docker.conf
        - ../../compose/una-video/${PHP_VERSION}/www.conf:/usr/local/etc/php-fpm.d/www.conf
        - ../../apps/${APP_VERSION}:/opt/una:Z
        - /etc/localtime:/etc/localtime:ro
        #
        #   Add custom header.inc.php to your container
        #   This will overwrite the main una/inc/header.inc.php inside the video container
        #
        - ../../compose/una-video/inc/header.inc.php:/opt/una/inc/header.inc.php:Z
        #
        #   You can also overwrite other files here as needed, depending on your requirements
        #
        #- ../../compose/una-video/custom_file.php:/opt/una/custom_file.php:Z
    
      networks:
        - una_private_network
        - una_private_proxy_network
    
      extra_hosts:
        #
        #   Add extra host entries for internal resolution
        #
        - "host.docker.internal:host-gateway"
        - "${LOCAL_LISTEN_ADDR:-127.0.0.1}:host-gateway"
    
        #
        #   Add extra service entries for internal resolution
        #
        - "${LOCAL_LISTEN_ADDR:-127.0.0.1}:${UNA_VIDEO_HOSTNAME:-www.video.com}"
        - "${NETWORK_LISTEN_ADDR:-172.16.0.1}:${UNA_VIDEO_HOSTNAME:-www.video.com}"
    # ----------------------------------------------------------------------------------#
    

    This way, all heavy video processing tasks run in an isolated UNA Video Container, without affecting the main UNA instance. It also ensures that your primary container remains fast and responsive, without being slowed down by video processing workloads.

    Note:

    This is just an example.

    To make it fully functional, you need to configure all required files separately, set up a proper .env file, and update your inc/header.inc.php to route all video processing tasks exclusively to this container.

    In practice, you will have a clone of your main site container with a few files modified specifically for video processing, running on the same main una folder on disk.

    /main-una/                       <-- Project root, where docker-compose.yml is located
    ├── docker-compose.yml                <-- Docker Compose file
    ├── .env                              <-- ENV file
    ├── apps/
    │   └── una/                          <-- Main UNA application code
    │       ├── inc/
    │       │   └── header.inc.php        <-- Original header (untouched)
    │       └── ...                       <-- Other UNA files
    ├── compose/
    │   └── una-video/
    │       └── php8.3/
    │           ├── php.ini               <-- Custom PHP config for video container
    │           ├── docker.conf           <-- PHP-FPM config for video container
    │           ├── www.conf.default      <-- Default config for video container
    │           ├── zz-docker.conf        <-- Additional config for video container
    │           └── www.conf              <-- Overwrite default www.conf
    │       └── inc/
    │           └── header.inc.php        <-- Modified header for video container
    └── ...
    
    
    
    This instance should not be accessible from the internet; set up a proxy only within your private network.
    By running docker compose up -d --build, a customized image for this container will be created, and the container will then run in the background together with your other containers.

    ⚠️ IMPORTANT NOTICE

    🚨 These commands and configuration changes are for informational or development purposes only.

    💾 They DO NOT represent an official production setup guide.

    ⚙️ Run them ONLY if you fully understand what they do.

    ❗ Use at your own risk – adjust values and configuration to your environment.

    👉 This example is intended for advanced users only.

    💬 Need Help?

    For inquiries or assistance, contact us via private message to order the Professional UNA CMS Installation & Server Setup for self-hosted sites. 🔗  https://unacms.com/view-product/coozila-small-business-una-cms