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 handle the requests and returns the results to a client, such as the OBClient. The results can also be returned by an application through an OceanBase Database Proxy (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 handles 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 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 req1 request to an OBServer node.
req1 enters a tenant request queue. On the OBServer node, such SQL requests enter the tenant request queue queue4.
Multi-tenant worker threads inspect request queues. When the tenant thread (TNT_1014) of Tenant
1014finds a new request in the queue that needs to be processed, it retrieves req1 from the queue.The TNT_1014 thread executes req1.
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 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 the tenant request queue queue2.
Multi-tenant worker threads inspect request queues. When the tenant thread (TNT_1011) of Tenant
1011finds a new request in the queue that needs to be processed, it retrieves req1 from the queue.The TNT_1011 thread executes req1.
The TNT_1011 thread returns the execution results and the 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 requests are locally executed. The request is executed in the following manner:
A client sends the req1 request to an OBServer node.
req1 enters the tenant request queue. In OceanBase Database, regular SQL requests enter the tenant request queue queue4.
Multi-tenant worker threads inspect request queues. When the tenant thread (TNT_1013) of Tenant
1013finds a new request in the queue that needs to be processed, it 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 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
The default value is 4, and the value range is [1,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.
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
The default value is 10, and the value range is [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
| View or table name | Description |
|---|---|
| GV$OB_TENANT_RUNTIME_INFO | Information about queues and thread quotas in OceanBase Database multi-tenant threads. |