concept partition in category storm

This is an excerpt from Manning's book Storm Applied: Strategies for real-time event processing.
The higher the number of partitions, the higher the number of resources needed. Each bolt will require a number of executors and tasks and a queue in front for all the incoming tuples.
Within a Trident topology, natural points of partition will exist. Points where partitioning has to change are based on the operations being applied. At these points, you can adjust the parallelism of each of the resulting partitions. The groupBy operations that we use in our topology result in repartitioning. Each of our groupBy operations resulted in a repartitioning that we could supply a parallelism hint to, as shown in the following listing.
Listing 9.20. Specifying parallelism at the points of repartition
public static StormTopology build() { TridentTopology topology = new TridentTopology(); Stream playStream = topology.newStream("play-spout", buildSpout()) .each(new Fields("play-log"), new LogDeserializer(), new Fields("artist", "title", "tags")) .each(new Fields("artist", "title"), new Sanitizer(new Fields("artist", "title"))) .name("LogDeserializerSanitizer"); TridentState countByArtist = playStream .project(new Fields("artist")) .groupBy(new Fields("artist")) .name("ArtistCounts") .persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("artist-count")) .parallelismHint(4); TridentState countsByTitle = playStream .project(new Fields("title")) .groupBy(new Fields("title")) .name("TitleCounts") .persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("title-count")) .parallelismHint(4); TridentState countsByTag = playStream .each(new Fields("tags"), new ListSplitter(), new Fields("tag")) .project(new Fields("tag")) .groupBy(new Fields("tag")) .name("TagCounts") .persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("tag-count")) .parallelismHint(4); topology.newDRPCStream("count-request-by-tag") .name("RequestForTagCounts") .each(new Fields("args"), new SplitOnDelimiter(","), new Fields("tag")) .groupBy(new Fields("tag")) .name("QueryForRequest") .stateQuery(countsByTag, new Fields("tag"), new MapGet(), new Fields("count")); return topology.build(); }Here we’ve given each of our final three bolts a parallelism of four. That means they each operate with four partitions. We were able to specify a level of parallelism for those because there’s natural repartitioning happening between them and bolts that came before them due to groupBy and persistentAggregate operations. We didn’t specify any parallelism hint to our first two bolts because they don’t have any inherent repartitioning going on between them and the spouts that came before them. Therefore, they operate at the same number of partitions as the spouts. Figure 9.18 shows what this configuration looks like in the Storm UI.
When a message producer writes to a Kafka topic, it writes a given message to a particular partition of that topic. A partition is an ordered, immutable sequence of messages that’s continually being appended to. A topic can have multiple partitions, and these partitions can be distributed across multiple Kafka brokers. A message consumer will read from each partition in order to see the entire topic. Figure 9.2 illustrates a single topic distributed across multiple partitions.
By partitioning a topic, Kafka gains the ability to scale a single topic beyond a single broker (node) for both reads and writes. Each of the partitions can additionally be replicated to provide resiliency. This means that if you have n replicas for a partition, you can lose up to n – 1 replicas without suffering any data loss.