This topic describes how the multi-tenant threads of OceanBase Database work.
OceanBase Database is a distributed database that supports the multi-tenant architecture. When an OBServer node receives requests from different tenants, the OBServer node uses tenant-specific threads to process the requests and returns the results to a client, such as the OBClient. The results can also be returned by an application through an ODP. During this process, the background system threads of OceanBase Database handle both 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 section describes how OceanBase Database processes three basic types of tenant requests received by OBServer nodes in the multi-tenant thread architecture.
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 1014, a tenant thread locally executes the request. The request is executed in the following manner:
A client sends Request 1 to an OBServer node.
Request 1 enters the request queue of the tenant. In the OBServer node, such SQL requests enter Queue 4.
Multi-tenant worker threads inspect request queues. When the TNT_1014 thread of Tenant
1014identifies Request 1, the thread obtains Request 1.The TNT_1014 thread executes Request 1.
The TNT_1014 thread returns the execution results and the return value to the client.
Scenario 2
When an OBServer node receives a remote procedure call (RPC) request, such as a distributed OLTP SQL request, from another OBServer node in Tenant B (with an ID of 1011), a thread of Tenant B 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 (Request 1) to the current OBServer node.
Request 1 returns an OLTP SQL request and enters the tenant request queue (queue2) on the OBServer node.
Multi-tenant worker threads inspect request queues. When the TNT_1011 thread of Tenant
1011identifies Request, the thread obtains Request 1.The TNT_1011 thread executes Request 1.
The TNT_1011 thread returns the execution results and return value to the remote OBServer node.
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 queries are locally executed. The request is executed in the following manner:
A client sends Request 1 to an OBServer node.
Request 1 enters the request queue of the tenant. In OceanBase Database, regular SQL requests enter Queue 4.
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 Request 1 is executed, the thread returns the execution results and the return value to the client.
Related parameters
cpu_quota_concurrency
The min_cpu parameter (a resource unit parameter) and the cpu_quota_concurrency parameter (a system parameter) determine the number of active threads of a tenant.
Number of active threads of a tenant = min_cpu × cpu_quota_concurrency
Default value: 4. Value range: [1, 10]. This parameter takes effect immediately after it is modified.
If you deploy and use OceanBase Database in a standard environment, we recommend that you use the default value.
workers_per_cpu_quota
The max_cpu parameter (a resource unit parameter) and the workers_per_cpu_quota parameter (a system parameter) determine the maximum number of threads of a tenant.
Maximum number of threads of a tenant = max_cpu × workers_per_cpu_quota
Default value: 10. Value: [2, 20]. This parameter takes effect immediately after it is modified.
If you deploy and use OceanBase Database in a standard environment, we recommend that you use the default value.
Related views or tables
| View or table | Description |
|---|---|
| __all_virtual_dump_tenant_info | Stores information about queues and quotas of multi-tenant threads in OceanBase Database. |