hbase set quota

Hbase Quotas

hbase quotas allow you to throttle requests based on the following limits:node

  • The number or size of requests(read, write, or read+write) in a given timeframeexpress

  • The number of tables allowed in a namespacebash

  • These limits can be enforced for a specified user, table, or namespace.app

First : Enabling Quotas

Quotas are disabled by default. To enable the feature, set the hbase.quota.enabled property to true in hbase-site.xml file for all cluster nodes.spa

General Quota Syntax

  • THROTTLE_TYPE can be expressed as READ, WRITE, or the default type(read + write).code

  • Timeframes can be expressed in the following units: sec, min, hour, dayorm

  • Request sizes can be expressed in the following units: B (bytes), K (kilobytes), M (megabytes), G (gigabytes), T (terabytes), P (petabytes)xml

  • Numbers of requests are expressed as an integer followed by the string reqci

  • Limits relating to time are expressed as req/time or size/time. For instance 10req/day or 100P/hour.rem

  • Numbers of tables or regions are expressed as integers.

Setting Request Quotas

You can set quota rules ahead of time, or you can change the throttle at runtime. The change will propagate after the quota refresh period has expired. This expiration period defaults to 5 minutes. To change it, modify the hbase.quota.refresh.period property in hbase-site.xml. This property is expressed in milliseconds and defaults to 300000.

# Limit user u1 to 10 requests per second
hbase> set_quota TYPE => THROTTLE, USER => 'u1', LIMIT => '10req/sec'

# Limit user u1 to 10 read requests per second
hbase> set_quota TYPE => THROTTLE, THROTTLE_TYPE => READ, USER => 'u1', LIMIT => '10req/sec'

# Limit user u1 to 10 M per day everywhere
hbase> set_quota TYPE => THROTTLE, USER => 'u1', LIMIT => '10M/day'

# Limit user u1 to 10 M write size per sec
hbase> set_quota TYPE => THROTTLE, THROTTLE_TYPE => WRITE, USER => 'u1', LIMIT => '10M/sec'

# Limit user u1 to 5k per minute on table t2
hbase> set_quota TYPE => THROTTLE, USER => 'u1', TABLE => 't2', LIMIT => '5K/min'

# Limit user u1 to 10 read requests per sec on table t2
hbase> set_quota TYPE => THROTTLE, THROTTLE_TYPE => READ, USER => 'u1', TABLE => 't2', LIMIT => '10req/sec'

# Remove an existing limit from user u1 on namespace ns2
hbase> set_quota TYPE => THROTTLE, USER => 'u1', NAMESPACE => 'ns2', LIMIT => NONE

# Limit all users to 10 requests per hour on namespace ns1
hbase> set_quota TYPE => THROTTLE, NAMESPACE => 'ns1', LIMIT => '10req/hour'

# Limit all users to 10 T per hour on table t1
hbase> set_quota TYPE => THROTTLE, TABLE => 't1', LIMIT => '10T/hour'

# Remove all existing limits from user u1
hbase> set_quota TYPE => THROTTLE, USER => 'u1', LIMIT => NONE

# List all quotas for user u1 in namespace ns2
hbase> list_quotas USER => 'u1, NAMESPACE => 'ns2' # List all quotas for namespace ns2 hbase> list_quotas NAMESPACE => 'ns2' # List all quotas for table t1 hbase> list_quotas TABLE => 't1' # list all quotas hbase> list_quotas 複製代碼

WhiteList

You can also place a global limit and exclude a user or a table from the limit by applying the GLOBAL_BYPASS property.

hbase> set_quota NAMESPACE => 'ns1', LIMIT => '100req/min'               # a per-namespace request limit
hbase> set_quota USER => 'u1', GLOBAL_BYPASS => true                     # user u1 is not affected by the limit
複製代碼

Setting Namespace Quotas

You can specify the maximum number of tables or regions allowed in a given namespace, either when you create the namespace or by altering an existing namespace, by setting the hbase.namespace.quota.maxtables property on the namespace.

Limiting Tables Per Namespace

# Create a namespace with a max of 5 tables
hbase> create_namespace 'ns1', {'hbase.namespace.quota.maxtables'=>'5'}

# Alter an existing namespace to have a max of 8 tables
hbase> alter_namespace 'ns2', {METHOD => 'set', 'hbase.namespace.quota.maxtables'=>'8'}

# Show quota information for a namespace
hbase> describe_namespace 'ns2'

# Alter an existing namespace to remove a quota
hbase> alter_namespace 'ns2', {METHOD => 'unset', NAME=>'hbase.namespace.quota.maxtables'}
Limiting Regions Per Namespace
# Create a namespace with a max of 10 regions
hbase> create_namespace 'ns1', {'hbase.namespace.quota.maxregions'=>'10'

# Show quota information for a namespace
hbase> describe_namespace 'ns1'

# Alter an existing namespace to have a max of 20 tables
hbase> alter_namespace 'ns2', {METHOD => 'set', 'hbase.namespace.quota.maxregions'=>'20'}

# Alter an existing namespace to remove a quota
hbase> alter_namespace 'ns2', {METHOD => 'unset', NAME=> 'hbase.namespace.quota.maxregions'}
複製代碼
相關文章
相關標籤/搜索