This topic describes how multi-tenant threads work in OceanBase AI Database.
OceanBase AI Database is a distributed database that supports the multi-tenant architecture. When an OBServer node receives requests from different tenants, it uses tenant-specific threads to handle the requests and returns the results to the client, such as OBClient, or to an application through OceanBase Database Proxy (ODP). During this process, the background system threads of OceanBase AI Database handle system tasks and tasks that are shared by multiple tenants. The healthy running of all threads supports the stable running of OBServer nodes and ensures reliable and highly available data services. The following sections describe how OceanBase AI Database handles three basic types of tenant requests received by OBServer nodes in the multi-tenant thread architecture.
Application scenarios
Scenario 1
When an OBServer node receives an SQL request of the online transaction processing (OLTP) type, which is sent from a client to tenant A (with an ID of 1014), a tenant thread locally executes the request. The request is executed in the following manner:
A client sends the request req1 to an OBServer node.
req1 enters a tenant request queue. On the OBServer node, such SQL requests enter queue4 of the tenant request queue.
Multi-tenant worker threads inspect request queues. When the TNT_1014 thread of tenant
1014identifies req1, the thread obtains req1.The TNT_1014 thread executes req1.
The TNT_1014 thread returns the execution result and the return value to the client.
The following figure shows how the multi-tenant threads of OceanBase AI Database process a local OLTP SQL request.
Scenario 2
When an OBServer node receives a remote procedure call (RPC) request, such as a distributed OLTP SQL request that is sent from another OBServer node in tenant B (with an ID of 1011), a tenant thread executes the request. The RPC request is executed in the following manner:
An OBServer node in a tenant serves as an RPC client and sends an RPC request req1 to the current OBServer node.
req1 is an OLTP SQL request and enters queue2 of the tenant request queue.
Multi-tenant worker threads inspect request queues. When the TNT_1011 thread of tenant
1011identifies req1, the thread obtains req1.The TNT_1011 thread executes req1.
The TNT_1011 thread returns the execution result and the return value to the remote OBServer node.
The following figure shows how the multi-tenant threads of OceanBase AI Database process a distributed SQL RPC request.
Scenario 3
When an OBServer node receives a PX SQL request that is sent from a client to tenant C (with an ID of 1013), all SQL requests are locally executed. The request is executed in the following manner:
A client sends the request req1 to an OBServer node.
req1 enters the request queue of the tenant. In OceanBase AI Database, regular SQL requests enter queue4.
Multi-tenant worker threads inspect request queues. When the TNT_1013 thread of tenant C (with an ID of
1013) identifies req1 that needs to be processed, the thread retrieves req1 from the queue.The tenant thread serves as the local scheduler and drives the PX thread to execute the request.
After req1 is executed, the thread returns the execution result and the return value to the client.
The following figure shows how a multi-tenant thread of OceanBase AI Database processes a local PX SQL request.
Related parameters
cpu_quota_concurrency
The resource unit parameter min_cpu and the system parameter cpu_quota_concurrency determine the number of active threads of a tenant.
Number of active threads of a tenant = min_cpu × cpu_quota_concurrency
The default value is 4, and the value range is [1,20]. This parameter takes effect immediately after it is modified.
For standard production deployment, we recommend that you keep the default value.
workers_per_cpu_quota
The resource unit parameter max_cpu and the system parameter workers_per_cpu_quota determine the maximum number of threads of a tenant.
Maximum number of threads of a tenant = max_cpu × workers_per_cpu_quota
The default value is 10, and the value range is [2, 20]. This parameter takes effect immediately after it is modified.
For standard production deployment, we recommend that you keep the default value.
Related views
View or table |
Description |
|---|---|
| GV$OB_TENANT_RUNTIME_INFO | Stores the information about queues and quotas of multi-tenant threads in OceanBase AI Database. |