Scale Agent Factory on a Single Host
Configure Oracle Advanced Queuing (AQ) and multiple ASGI workers to handle concurrent requests in a single-host Agent Factory production deployment.
Note: This feature is supported in Agent Factory release 26.7 and later.
Before You Begin
You need:
- Administrator access to the Agent Factory application database.
- The database user that owns the Agent Factory repository. This topic uses
<DB_USER>for that user. - Access to the host that runs the
oracle-applied-ai-labelcontainer.
Configure Oracle AQ
Run the following script as a database administrator in the Agent Factory application database. Replace <DB_USER> with the Agent Factory repository user.
GRANT EXECUTE ON SYS.DBMS_AQ TO <DB_USER>;
BEGIN
DBMS_AQADM.CREATE_QUEUE_TABLE(
queue_table => '<DB_USER>.AAI_SOCKETIO_QTAB',
queue_payload_type => 'SYS.AQ$_JMS_TEXT_MESSAGE',
multiple_consumers => TRUE
);
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -24001 THEN
RAISE;
END IF;
END;
/
BEGIN
DBMS_AQADM.CREATE_QUEUE(
queue_name => '<DB_USER>.AAI_SOCKETIO_QUEUE',
queue_table => '<DB_USER>.AAI_SOCKETIO_QTAB'
);
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -24006 THEN
RAISE;
END IF;
END;
/
BEGIN
DBMS_AQADM.START_QUEUE(
queue_name => '<DB_USER>.AAI_SOCKETIO_QUEUE'
);
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -25207 THEN
RAISE;
END IF;
END;
/
BEGIN
FOR slot_number IN 1..8 LOOP
DECLARE
subscriber SYS.AQ$_AGENT;
BEGIN
subscriber := SYS.AQ$_AGENT('AAI_SIO_' || slot_number, NULL, NULL);
DBMS_AQADM.ADD_SUBSCRIBER(
queue_name => '<DB_USER>.AAI_SOCKETIO_QUEUE',
subscriber => subscriber
);
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -24034 THEN
RAISE;
END IF;
END;
END LOOP;
END;
/
BEGIN
DBMS_AQADM.GRANT_QUEUE_PRIVILEGE(
privilege => 'ENQUEUE',
queue_name => '<DB_USER>.AAI_SOCKETIO_QUEUE',
grantee => '<DB_USER>',
grant_option => FALSE
);
DBMS_AQADM.GRANT_QUEUE_PRIVILEGE(
privilege => 'DEQUEUE',
queue_name => '<DB_USER>.AAI_SOCKETIO_QUEUE',
grantee => '<DB_USER>',
grant_option => FALSE
);
END;
/
Enable Concurrency During a Fresh Installation
Use this procedure for a new production installation:
- In the web installer, enter the database connection details and test the connection.
- Before you click Install, configure Oracle AQ.
- Return to the web installer and click Install.
The application container starts with multiple ASGI workers. By default, Agent Factory uses the number of available CPUs, up to eight workers.
Enable Concurrency for an Existing Installation
Use this procedure if Agent Factory is already installed in production mode:
- Configure Oracle AQ.
- Set the number of ASGI workers and restart Agent Factory.
- Verify the number of running workers.
Set the Number of ASGI Workers
Run the following command on the container host. This example configures four ASGI workers and restarts Agent Factory:
podman exec -u root oracle-applied-ai-label bash -c 'export AGENT_FACTORY_ASGI_WORKERS=4; /home/aaiuser/install/agent_factory/manage_app.sh restart all'
Verify the Number of ASGI Workers
Run the following command on the container host:
podman exec oracle-applied-ai-label bash -c '
master_pid=$(ps -eo pid=,ppid=,args= |
sed -n "\|gunicorn_config/uvicorn_config.py| {s/^[[:space:]]*\([0-9][0-9]*\)[[:space:]]*1[[:space:]].*/\1/p;q;}")
if [ -z "$master_pid" ]; then
echo "ASGI workers: 0 (ASGI Gunicorn master not running)"
else
worker_count=$(ps -eo ppid= | grep -c "^[[:space:]]*$master_pid[[:space:]]*$")
echo "ASGI workers: $worker_count"
fi
'