Internally, messages in MapR Streams are stored as rows in a MapR-DB table. Most MapR Streams client traffic is like MapR-DB traffic with important server-side differences.
Internally, messages are grouped together into rows. Depending on size and client batching, each row is likely to hold lots of messages. Two important elements are the partitionid and the topic name. As with any table, rows are stored sorted together in ranges and grouped into tablets (which are also called regions). This approach allows data for the same partition to stay together when a given topic is sharded across partitions. Of course, the head of a given topic and partition is stored together because of the key range. These behaviors ensure sequential IO patterns.
A MapR Streams stream starts as two empty tablets (-infinity to p000 and p000 to +infinity); they hold no data. As soon as data is added, a third tablet is created to hold data for one partition. The range is p000 to p001. As more data is added, tablets split as expected based on size. 4GB is the default split size. Thus, as the total data stored across all topics grows, the stream naturally splits into more and more tablets. This increases potential system throughput as more and more file servers handle portions of the stream.
Of course, a single topic with one partition is “hot” in one tablet—the tablet holding the head of the topic queue. However, if one explicitly creates additional partitions using maprcli stream topic edit, new tablets will be created to hold the partitions, one tablet for each partition. The splitting occurs as soon as data is added to the stream ensuring that there is at least one tablet for each partition. At this point, the IO load for one single topic is spread across multiple partitions, and therefore, multiple tablets multiple containers, and finally multiple servers.
For example, if you create a single stream with one topic and 50 partitions and then put a fairly small amount of data in the topic (for example, 100+ MB), the tablet layout used by the stream is as follows:
maprcli table region list -path /streams/mystream -json |\grep primarynode |sort | uniq -c 11 "primarynode":"ip-172-16-2-167.ec2.internal", 11 "primarynode":"ip-172-16-2-168.ec2.internal", 10 "primarynode":"ip-172-16-2-169.ec2.internal", 10 "primarynode":"ip-172-16-2-170.ec2.internal", 11 "primarynode":"ip-172-16-2-171.ec2.internal",
Notice that the stream is held in fifty-three containers. The 5 file servers have approximately the same number of containers (10 or 11). The load was spread somewhat evenly among file servers.
See the MapR user documentation for more information about MapR Streams:
Retrieving data ...