how to determine when to increase parallelism of a single worker or increase workers in storm?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
In the realm of real-time computation, Apache Storm stands out as a powerful open-source framework that enables the processing of data streams at unprecedented scales. One of the pivotal decisions in optimizing a Storm topology is determining the right balance between increasing the parallelism of individual workers and scaling out the number of workers. This decision impacts both the efficiency and the reliability of your data processing.
Understanding Storm Architecture
Before delving into considerations for scaling, it’s crucial to understand the key components of Storm:
- Spouts: These are sources of streams in a Storm topology. They read data from an external source and emit tuples into the topology.
- Bolts: These components process input streams to produce new outputs. A bolt can do anything from filtering, aggregations, joining, interacting with databases, etc.
A worker in Storm refers to a JVM process, and each worker can execute one or more executors (threads). Executors are the actual run-time instances of spouts and bolts, and each executor may process one or more tasks, which are the smallest unit of parallelism in Storm.
When to Increase Parallelism of a Single Worker
Increasing the parallelism of a single worker typically involves either adding more executors to this worker or adjusting the distribution of tasks among the existing executors. This approach is suitable if:
- Underutilization of Resources: If the CPU and memory usage metrics indicate that a worker is not fully utilized, increasing the parallelism within the worker can better leverage the underlying resources.
- Limited Worker Overhead: Fewer workers mean reduced overhead in terms of JVM maintenance and inter-process communication.
Technical Example:
Consider if a spout is bound by CPU capacity, and the current worker utilization is only at 50% CPU. You might decide to double the number of executors for this spout within the same worker, hoping to achieve closer to 100% CPU usage, improving throughput without extra resource costs.
When to Increase Number of Workers
Scaling by adding more workers is another approach. This strategy should be considered when:
- Resource Saturation: If the existing workers are close to their resource capacity (CPU, memory), additional workers might be necessary.
- Fault Tolerance: More workers mean that the failure of any single worker impacts a smaller part of the topology, potentially reducing the overall risk of downtime.
- Geographical Distribution: For closer proximity to data sources or to meet legal requirements, distributing workers across different regions or data centers can be advantageous.
Technical Example:
Imagine a topology processing time-sensitive data across multiple geographic locations. Adding more workers in respective locations reduces data travel time and complies with local data sovereignty laws, enhancing performance and legal compliance.
Decision Table
| Factor | Increase Parallelism Of Worker | Increase Worker Count |
| Resource Utilization | Low | High |
| Complexity & Overhead | Prefer simplicity | Can handle complexity |
| Fault Tolerance | Less critical | More critical |
| Geographical Needs | Low | High |
Additional Considerations
- Network Latency: Higher number of workers can increase the communication time between nodes, particularly in disparate geographic locations.
- Management Overhead: More workers can potentially complicate cluster management and monitoring efforts.
- Cost Implications: Scaling out workers generally increases cost more than scaling up due to additional VM or hardware expenses.
Conclusion
Deciding whether to increase the parallelism within workers or scale out to more workers depends on your specific use case requirements, resource availability, and fault tolerance needs. Careful monitoring and performance metrics are essential to guide these decisions, ensuring that your Storm topology scales effectively to meet demand without unnecessary expenditure.
Related reading
- How to distribute URL frontier and crawling workers in a distributed web crawler?
- how to efficiently cache large file in hadoop map reduce jobs?
- How to elaborate information flow in large scale distributed system by UML
- How to elect a master node among the nodes running in a cluster?
- How to enable HTTP response caching in Spring Boot
- How to enable streaming replication in PostgreSQL running in kubernetes pods?
- How to ensure data consistency in Cassandra on different tables?
- How to establish a consistent hash ring with 300 million virtual nodes within 10 seconds with C++

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.