diff --git a/src/main/docbkx/book.xml b/src/main/docbkx/book.xml index 6c4c9efd248..a1b799194da 100644 --- a/src/main/docbkx/book.xml +++ b/src/main/docbkx/book.xml @@ -2013,7 +2013,7 @@ rs.close(); again, it upgrades to this priority. It is thus part of the second group considered during evictions. - + In-memory access priority: If the block's family was configured to be "in-memory", it will be part of this priority disregarding the number of times it was accessed. Catalog tables are configured like this. This group is the last one @@ -2166,7 +2166,7 @@ rs.close(); Enable BucketCache To enable BucketCache, set the value of hbase.offheapcache.percentage to 0 in the RegionServer's - hbase-site.xml file. This disables SlabCache. + hbase-site.xml file. This disables SlabCache. Just as for SlabCache, the usual deploy of BucketCache is via a managing class that sets up two caching tiers: an L1 onheap cache @@ -2180,7 +2180,6 @@ rs.close(); setting cacheDataInL1 via (HColumnDescriptor.setCacheDataInL1(true) or in the shell, creating or amending column families setting CACHE_DATA_IN_L1 to true: e.g. hbase(main):003:0> create 't', {NAME => 't', CONFIGURATION => {CACHE_DATA_IN_L1 => 'true'}} - The BucketCache deploy can be onheap, offheap, or file based. You set which via the hbase.bucketcache.ioengine setting it to @@ -3205,7 +3204,7 @@ myHtd.setValue(HTableDescriptor.SPLIT_POLICY, MyCustomSplitPolicy.class.getName( - +
Parameters Used by Compaction Algorithm This table contains the main configuration parameters for compaction. This @@ -3698,32 +3697,52 @@ public enum Consistency { In case a read is performed with Consistency.TIMELINE, then the read RPC will be sent to the primary region server first. After a short interval (hbase.client.primaryCallTimeout.get, 10ms by default), parallel RPC for secondary region replicas will also be sent if the primary does not respond back. After this, the result is returned from whichever RPC is finished first. If the response came back from the primary region replica, we can always know that the data is latest. For this Result.isStale() API has been added to inspect the staleness. If the result is from a secondary region, then Result.isStale() will be set to true. The user can then inspect this field to possibly reason about the data. - In terms of semantics, TIMELINE consistency as implemented by HBase differs from pure eventual consistency in these respects: + In terms of semantics, TIMELINE consistency as implemented by HBase differs from pure eventual + consistency in these respects: - - Single homed and ordered updates: Region replication or not, on the write side, there is still only 1 defined replica (primary) which can accept writes. This replica is responsible for ordering the edits and preventing conflicts. This guarantees that two different writes are not committed at the same time by different replicas and the data diverges. With this, there is no need to do read-repair or last-timestamp-wins kind of conflict resolution. - - The secondaries also apply the edits in the order that the primary committed them. This way the secondaries will contain a snapshot of the primaries data at any point in time. This is similar to RDBMS replications and even HBase’s own multi-datacenter replication, however in a single cluster. - - On the read side, the client can detect whether the read is coming from up-to-date data or is stale data. Also, the client can issue reads with different consistency requirements on a per-operation basis to ensure its own semantic guarantees. - - The client can still observe edits out-of-order, and can go back in time, if it observes reads from one secondary replica first, then another secondary replica. There is no stickiness to region replicas or a transaction-id based guarantee. If required, this can be implemented later though. - - - - - - - - - HFile Version 1 - - - - + + Single homed and ordered updates: Region replication or not, on the write side, + there is still only 1 defined replica (primary) which can accept writes. This + replica is responsible for ordering the edits and preventing conflicts. This + guarantees that two different writes are not committed at the same time by different + replicas and the data diverges. With this, there is no need to do read-repair or + last-timestamp-wins kind of conflict resolution. + + + The secondaries also apply the edits in the order that the primary committed + them. This way the secondaries will contain a snapshot of the primaries data at any + point in time. This is similar to RDBMS replications and even HBase’s own + multi-datacenter replication, however in a single cluster. + + + On the read side, the client can detect whether the read is coming from + up-to-date data or is stale data. Also, the client can issue reads with different + consistency requirements on a per-operation basis to ensure its own semantic + guarantees. + + + The client can still observe edits out-of-order, and can go back in time, if it + observes reads from one secondary replica first, then another secondary replica. + There is no stickiness to region replicas or a transaction-id based guarantee. If + required, this can be implemented later though. + + + +
+ HFile Version 1 + + + + + + HFile Version 1 + + +
+ To better understand the TIMELINE semantics, lets look at the above diagram. Lets say that there are two clients, and the first one writes x=1 at first, then x=2 and x=3 later. As above, all writes are handled by the primary region replica. The writes are saved in the write ahead log (WAL), and replicated to the other replicas asynchronously. In the above diagram, notice that replica_id=1 received 2 updates, and it’s data shows that x=2, while the replica_id=2 only received a single update, and its data shows that x=1. @@ -3733,24 +3752,45 @@ public enum Consistency {
Tradeoffs - - Having secondary regions hosted for read availability comes with some tradeoffs which should be carefully evaluated per use case. The main advantages of this design are - - High availability for read-only tables. - High availability for stale reads - Ability to do very low latency reads with very high percentile (99.9%+) latencies for stale reads - - - The downsides for this feature are - - Double / Triple memstore usage (depending on region replication count) for tables with region replication > 1 - Increased block cache usage - Extra network traffic for log replication - Extra backup RPCs for replicas - - To serve the region data from multiple replicas, HBase opens the regions in secondary mode in the region servers. The regions opened in secondary mode will share the same data files with the primary region replica, however each secondary region replica will have its own memstore to keep the unflushed data (only primary region can do flushes). Also to serve reads from secondary regions, the blocks of data files may be also cached in the block caches for the secondary regions. - + Having secondary regions hosted for read availability comes with some tradeoffs which + should be carefully evaluated per use case. Following are advantages and + disadvantages. + + Advantages + + High availability for read-only tables. + + + High availability for stale reads + + + Ability to do very low latency reads with very high percentile (99.9%+) latencies + for stale reads + + + + Disadvantages + + Double / Triple memstore usage (depending on region replication count) for tables + with region replication > 1 + + + Increased block cache usage + + + Extra network traffic for log replication + + + Extra backup RPCs for replicas + + + To serve the region data from multiple replicas, HBase opens the regions in secondary + mode in the region servers. The regions opened in secondary mode will share the same data + files with the primary region replica, however each secondary region replica will have its + own memstore to keep the unflushed data (only primary region can do flushes). Also to + serve reads from secondary regions, the blocks of data files may be also cached in the + block caches for the secondary regions.
Configuration properties @@ -3769,13 +3809,17 @@ public enum Consistency { ]]> - One thing to keep in mind also is that, region replica placement policy is only enforced by the StochasticLoadBalancer which is the default balancer. If you are using a custom load balancer property in hbase-site.xml (hbase.master.loadbalancer.class) replicas of regions might end up being hosted in the same server. - + One thing to keep in mind also is that, region replica placement policy is only + enforced by the StochasticLoadBalancer which is the default balancer. If + you are using a custom load balancer property in hbase-site.xml + (hbase.master.loadbalancer.class) replicas of regions might end up being + hosted in the same server.
Client side properties - Ensure to set the following for all clients (and servers) that will use region replicas. - Ensure to set the following for all clients (and servers) that will use region + replicas. + hbase.ipc.client.allowsInterrupt true @@ -3833,46 +3877,57 @@ htd.setRegionReplication(2); admin.createTable(htd); ]]> - You can also use setRegionReplication() and alter table to increase, decrease the region replication for a table. + You can also use setRegionReplication() and alter table to increase, decrease the + region replication for a table.
Region splits and merges - Region splits and merges are not compatible with regions with replicas yet. So you have to pre-split the table, and disable the region splits. Also you should not execute region merges on tables with region replicas. To disable region splits you can use DisabledRegionSplitPolicy as the split policy. + Region splits and merges are not compatible with regions with replicas yet. So you + have to pre-split the table, and disable the region splits. Also you should not execute + region merges on tables with region replicas. To disable region splits you can use + DisabledRegionSplitPolicy as the split policy.
User Interface - In the masters user interface, the region replicas of a table are also shown together with the primary regions. You can notice that the replicas of a region will share the same start and end keys and the same region name prefix. The only difference would be the appended replica_id (which is encoded as hex), and the region encoded name will be different. You can also see the replica ids shown explicitly in the UI. + In the masters user interface, the region replicas of a table are also shown together + with the primary regions. You can notice that the replicas of a region will share the same + start and end keys and the same region name prefix. The only difference would be the + appended replica_id (which is encoded as hex), and the region encoded name will be + different. You can also see the replica ids shown explicitly in the UI.
API and Usage
Shell - You can do reads in shell using a the Consistency.TIMELINE semantics as follows - You can do reads in shell using a the Consistency.TIMELINE semantics as follows + + get 't1','r6', {CONSISTENCY => "TIMELINE"} ]]> - You can simulate a region server pausing or becoming unavailable and do a read from the secondary replica: - You can simulate a region server pausing or becoming unavailable and do a read from + the secondary replica: + hbase(main):001:0> get 't1','r6', {CONSISTENCY => "TIMELINE"} ]]> - Using scans is also similar - Using scans is also similar + scan 't1', {CONSISTENCY => 'TIMELINE'} ]]>
Java - You can set set the consistency for Gets and Scans and do requests as follows. + You can set set the consistency for Gets and Scans and do requests as + follows. - You can also pass multiple gets: + You can also pass multiple gets: - And Scans: + And Scans: - You can inspect whether the results are coming from primary region or not by calling the Result.isStale() method: + You can inspect whether the results are coming from primary region or not by calling + the Result.isStale() method: Resources - - More information about the design and implementation can be found at the jira issue: HBASE-10070 + + + More information about the design and implementation can be found at the jira + issue: HBASE-10070 + - HBaseCon 2014 talk also contains some details and slides. - + + HBaseCon 2014 talk also contains some + details and slides. + +
- HFile Version 1 - -