As Salesforce developers, we sometimes prefer to build flows rather than write code since flows are easier to deploy and maintain. However, sometimes you will have to write apex classes or triggers to get your work done. So, here is an important consideration while building a flow: a flow can execute only up to 2,000 components. This means that the maximum number of nodes that a flow can pass through in a single context is 2,000. You might think this is a big number, but, unfortunately, you will sometimes need more!
Imagine you have a bunch of records to iterate on and run some logic for each of them. For a collection of 500 records, you can have at most four components in each iteration. Thus, you have to call an apex class to do logic with mass data.