Configuring Quotas
Two types of HBase quotas are well established: throttle quota and number-of tables-quota. These two quotas can regulate users and tables.
In a multitenant HBase environment, ensuring that each tenant can use only its allotted portion of the system is key in meeting SLAs.
Quota Type | Resource Type | Purpose | Namespace applicable? | Table applicable? | User applicable? |
---|---|---|---|---|---|
Throttle | Network | Limit overall network throughput and number of RPC requests | Yes | Yes | Yes |
New space | Storage | Limit amount of storage used for table or namespaces | Yes | Yes | No |
Number of tables | Metadata | Limit number of tables for each namespace or user | Yes | No | Yes |
Numbr of regions | Metadata | Limit number of regions for each namespace | Yes | No | No |
Setting up quotas
HBase quotas are disabled by default. To enable quotas, the relevant hbase-site.xml property must be set to true and the limit of each quota specified on the command line.
General Quota Syntax
The general quota syntax are THROTTLE_TYPE, Request sizes and space limit, Number of requests, Time limits and Number of tables or regions.
- THROTTLE_TYPE
-
Can be expressed as READ-only, WRITE-only, or the default type (both READ and WRITE permissions)
- Timeframes
-
Can be expressed in the following units of time:
-
sec (second)
min (minute)
hour
day
-
- Request sizes and space limit
-
Can be expressed in the following units:
-
B: bytes
K: kilobytes
M: megabytes
G: gigabytes
P: petabytes
When no size units is included, the default value is bytes.
-
- Number of requests
-
Expressed as integer followed by the string request
- Time limits
-
Expressed as requests per unit-of-time or size per unit-of-time
Examples: 10req/day or 100P/hour
- Number of tables or regions
-
Expressed as integers
Throttle quotas
The throttle quota, also known as RPC limit quota, is commonly used to manage length of RPC queue as well as network bandwidth utilization. It is best used to prioritize time-sensitive applications to ensure latency SLAs are met.
Throttle quota examples
Following examples details the usage of adding throttle quotas commands, listing throttle quotas commands, and updating and deleting throttle quotas commands.
Examples of Adding Throttle Quotas Commands
Limit user u1 to 10 requests per second globally:
hbase> set_quota => TYPE => THROTTLE, USER => 'u1', LIMIT => '10req/sec'
Limit user u1 to up to 10MB of traffic per second globally:
hbase> set_quota => TYPE => THROTTLE, USER => 'u1', LIMIT => '10M/sec'
Limit user u1 to 10 requests/second globally for read operations. User u1 can still issue unlimited writes:
hbase> set_quota TYPE => THROTTLE, THROTTLE_TYPE => READ, USER => 'u1', LIMIT => '10req/sec'
Limit user u1 to 10 requests/second globally for read operations. User u1 can still issue unlimited reads:
hbase> set_quota TYPE => THROTTLE, THROTTLE_TYPE => WRITE, USER => 'u1', LIMIT => '10M/sec'
Limit user u1 to 5 KB/second for all operations on table t2. User u1 can still issue unlimited requests for other tables, regardless of type of operation:
hbase> set_quota TYPE => THROTTLE, USER => 'u1', TABLE => 't2', LIMIT => '5K/min'
Limit request to namespaces:
hbase> set_quota TYPE => THROTTLE, NAMESPACE => 'ns1', LIMIT => '10req/sec'
Limit request to tables:
hbase> set_quota TYPE => THROTTLE, TABLE => 't1', LIMIT => '10M/sec'
Limit requests based on type, regardless of users, namespaces, or tables:
hbase> set_quota TYPE => THROTTLE, THROTTLE_TYPE => WRITE, TABLE => 't1', LIMIT => '10M/sec'
Examples of Listing Throttle Quotas Commands
Show all quotas:
hbase> list_quotas
Show all quotas applied to user bob:
hbase> list_quotas USER => 'bob.*'
Show all quotas applied to user bob and filter by table or namespace:
hbase> list_quotas USER => 'bob.*', TABLE => 't1' hbase> list_quotas USER => 'bob.*', NAMESPACE => 'ns.*'
Show all quotas and filter by table or namespace:
hbase> list_quotas TABLE => 'myTable' hbase> list_quotas NAMESPACE => 'ns.*'
Examples of Updating and Deleting Throttle Quotas Commands
To update a quota, simply issue a new set_quota command. To remove a quota, you can set LIMIT to NONE. The actual quota entry will not be removed, but the policy will be disabled.
hbase> set_quota TYPE => THROTTLE, USER => 'u1', LIMIT => NONE
hbase> set_quota TYPE => THROTTLE, USER => 'u1', NAMESPACE => 'ns2', LIMIT => NONE
hbase> set_quota TYPE => THROTTLE, THROTTLE_TYPE => WRITE, USER => 'u1', LIMIT => NONE
hbase> set_quota USER => 'u1', GLOBAL_BYPASS => true
Space quotas
Space quotas, also known as filesystem space quotas, limit the amount of stored data. It can be applied at a table or namespace level where table-level quotas take priority over namespace-level quotas.
Space quotas are special in that they can trigger different policies when storage goes above thresholds. The following list describes the policies, and they are listed in order of least strict to most strict:
- NO_INSERTS
-
Prohibits new data from being ingested (for example, data from Put, Increment, and Append operations are not ingested).
- NO_WRITES
-
Performs the same function as NO_INSERTS but Delete operations are also prohibited.
- NO_WRITES_COMPACTIONS
-
Performs the same function as NO_INSERTS but compactions are also prohibited.
- DISABLE
-
Diables tables.
Examples of Adding Space Quotas
Add quota with the condition that Insert operations are rejected when table t1 reaches 1 GB of data:
hbase> set_quota TYPE => SPACE, TABLE => 't1', LIMIT => '1G', POLICY => NO_INSERTS
Add quota with the condition that table t2 is disabled when 50 GB of data is exceeded:
hbase> set_quota TYPE => SPACE, TABLE => 't2', LIMIT => '50G', POLICY => DISABLE
Add quota with the condition that Insert and Delete operations cannot be applied to namespace ns1 when it reaches 50 terabytes of data:
hbase> set_quota TYPE => SPACE, NAMESPACE => 'ns1', LIMIT => '50T', POLICY => NO_WRITES
Listing Space Quotas
See "Examples of Listing Throttle Quotas Commands" above for the supported syntax.
Examples of Updating and Deleting Space Quotas
A quota can be removed by setting LIMIT to NONE.
hbase> set_quota TYPE => SPACE, TABLE => 't1', LIMIT => NONE
hbase> set_quota TYPE => SPACE, NAMESPACE => 'ns1', LIMIT => NONE
Quota enforcement
When a quota limit is exceeded, the Master server instructs RegionServers to enable an enforcement policy for the namespace or table that violated the quota.
It is important to note the storage quota is not reported in real-time. There is a window when threshold is reached on RegionServers but the threshold accounted for on the Master server is not updated.
Quota violation policies
If quotas are set for the amount of space each HBase tenant can fill on HDFS, then a coherent quota violation policy should be planned and implemented on the system.
When a quota violation policy is enabled, the table owner should not be allowed to remove the policy. The expectation is that the Master automatically removes the policy. However, the HBase superuser should still have permission.
Automatic removal of the quota violation policy after the violation is resolved can be accomplished via the same mechanisms that it was originally enforced. But the system should not immediately disable the violation policy when the violation is resolved.
The following describes quota violation policies that you might consider.
Disabling Tables
This is the “brute-force” policy, disabling any tables that violated the quota. This policy removes the risk that tables over quota affect your system. For most users, this is likely not a good choice as most sites want READ operations to still succeed.
One hypothetical situation when a disabling tables policy might be advisable is when there are multiple active clusters hosting the same data and, because of a quota violation, it is discovered that one copy of the data does not have all of the data it should have. By disabling tables, you can prevent further discrepancies until the administrator can correct the problem.
Rejecting All WRITE Operations, Bulk Imports, and Compactions
This policy rejects all WRITEs and bulk imports to the region which the quota applies. Compactions for this region are also disabled to prevent the system from using more space because of the temporary space demand of a compaction. The only resolution in this case is administrator intervention to increase the quota that is being exceeded.
Rejecting All WRITE Operations and Bulk Imports
This is the same as the previous policy, except that compactions are still allowed. This allows users to set or alter a TTL on table and then perform a compaction to reduce the total used space. Inherently, using this violation policy means that you let used space to slightly rise before it is ultimately reduced.
Allowing DELETE Operations But Rejecting WRITE Operations and Bulk Imports
This is another variation of the two previously listed policies. This policy allows users to run processes to delete data in the system. Like the previous policy, using this violation policy means that you let used space slightly rises before it is ultimately reduced. In this case, the deletions are propagated to disk and a compaction actually removes data previously stored on disk. TTL configuration and compactions can also be used to remove data.
Impact of quota violation policy
Quota violation policies can impact live write access, bulk write access, and read access. You must understand what the quota violation policies mean for your deployment before you plan and implement it on your system.
Live Write Access
As one would expect, every violation policy outlined disables the ability to write new data into the system. This means that any Mutation implementation other than DELETE operations could be rejected by the system. Depending on the violation policy, DELETE operations still might be accepted.
Bulk Write Access
Bulk loading HFiles can be an extremely effective way to increase the overall throughput of ingest into HBase. Quota management is very relevant because large HFiles have the potential to quickly violate a quota.
Clients group HFiles by region boundaries and send the file for each column family to the RegionServer presently hosting that region. The RegionServer ultimately inspects each file, ensuring that it should be loaded into this region, and then, sequentially, load each file into the correct column family.
As a part of the precondition-check of the file's boundaries before loading it, the quota state should be inspected to determine if loading the next file will violate the quota. If the RegionServer determines that it will violate the quota, it should not load the file and inform the client that the file was not loaded because it would violate the quota.
Read Access
In most cases, quota violation policies can affect the ability to read the data stored in HBase. A goal of applying these HBase quotas is to ensure that HDFS remains healthy and sustains a higher level of availability to HBase users. Guaranteeing that there is always free space in HDFS can yield a higher level of health of the physical machines and the DataNodes. This leaves the HDFS-reserved space percentage as a fail-safe mechanism.
Metrics and Insight
Quotas should ideally be listed on the HBase Master UI. The list of defined quotas should be present as well as those quotas whose violation policy is being enforced. The list of tables/namespaces with enforced violation policies should also be presented via the JMX metrics exposed by the Master.
Examples of overlapping quota policies
With the ability to define a quota policy on namespaces and tables, you have to define how the policies are applied. A table quota should take precedence over a namespace quota.
Scenario 1
For example, consider Scenario 1, which is outlined in the following table. Namespace n has the following collection of tables: n1.t1, n1.t2, and n1.t3. The namespace quota is 100 GB. Because the total storage required for all tables is less than 100 GB, each table can accept new WRITEs.
Object | Quota | Storage Utilization |
---|---|---|
Namespace n1 | 100 GB | 80 GB |
Table n1.t1 | 10 GB | 5 GB |
Table n1.t2 | (not set) | 50 GB |
Table n1.t3 | (not set) | 25 GB |
Scenario 2
In Scenario 2, as shown in the following table, WRITEs to table n1.t1 are denied because the table quota is violated, but WRITEs to tablen1.t2 and table n1.t3 are still allowed because they are within the namespace quota. The violation policy for the table quota on table n1.t1 is enacted.
Object | Quota | Storage Utilization |
---|---|---|
Namespace n1 | 100 GB | 60 GB |
Table n1.t1 | 10 GB | 15 GB |
Table n1.t2 | (not set) | 30 GB |
Table n1.t3 | (not set) | 15 GB |
Scenario 3
In the Scenario 3 table below, WRITEs to all tables are not allowed because the storage utilization of all tables exceeds the namespace quota limit. The namespace quota violation policy is applied to all tables in the namespace.
Object | Quota | Storage Utilization |
---|---|---|
Namespace n1 | 100 GB | 108 GB |
Table n1.t1 | 10 GB | 8 GB |
Table n1.t2 | (not set) | 50 GB |
Table n1.t3 | (not set) | 50 GB |
Scenario 4
In the Scenario 4 table below, table n1.t1 violates the quota set at the table level. The table quota violation policy is enforced. In addition, the disk utilization of table n1t1 plus the sum of disk utilization for table n1t2 and table n1t3exceeds the 100 GB namespace quota. Therefore, the namespace quota violation policy is also applied.
Object | Quota | Storage Utilization |
---|---|---|
Namespace n1 | 100 GB | 115 GB |
Table n1.t1 | 10 GB | 15 GB |
Table n1.t2 | (not set) | 50 GB |
Table n1.t3 | (not set) | 50 GB |
Number-of-Tables Quotas
The number-of-tables quota is set as part of the namespace metadata and does not involve the set_quota command.
Examples of Commands Relevant to Setting and Administering Number-of-Tables Quotas
Create namespace ns1 with a maximum of 5 tables
hbase> create_namespace 'ns1', {'hbase.namespace.quota.maxtables'=>'5'}
Alter an existing namespace ns1 to set a maximum of 8 tables
hbase> alter_namespace 'ns1', {METHOD => 'set', 'hbase.namespace.quota.maxtables'=>'8'}
Show quota information for namespace ns1
hbase> describe_namespace 'ns1'
Alter existing namespace ns1 to remove a quota
hbase> alter_namespace 'ns1', {METHOD => 'unset', NAME=>'hbase.namespace.quota.maxtables'}
Number-of-Regions Quotas
The number-of-regions quota is similar to the number-of-tables quota. The number-of-regions quota is set as part of the namespace metadata and does not involve the set_quota command.
Examples of Commands Relevant to Setting and Administering Number-of-Regions Quotas
Create namespace ns1 with a maximum of 5 tables
hbase> create_namespace 'ns1', {'hbase.namespace.quota.maxregions'=>'5'}
Alter an existing namespace ns1 to set a maximum of 8 regions
hbase> alter_namespace 'ns1', {METHOD => 'set', 'hbase.namespace.quota.maxregions'=>'8'}
Show quota information for namespace ns1
hbase> describe_namespace 'ns1'
Alter existing namespace ns1 to remove a quota
hbase> alter_namespace 'ns1', {METHOD => 'unset', NAME=>'hbase.namespace.quota.maxregions'}