Why You Should Avoid Scheduling Workflows to Process Records Created Within a Specific Period
When automating business processes, scheduling workflows that process records at regular intervals is common. However, scheduling workflows to process records created within a specific period can lead to missed and inefficiencies. Let’s dive into an example to understand why this happens and how to avoid it.
Example Scenario
Imagine you have a scheduled workflow set to run every 30 minutes, with saved search criteria targeting records created within the past 30 minutes.
1. First Cycle
- At 9:00 AM, the workflow starts and identifies 137 new orders created between 8:30 AM and 9:00 AM.
- The workflow takes 48 minutes to process all 137 orders.
2. Next Cycle
- At 9:30 AM, the system schedules the workflow to run again.
- However, the previous workflow (started at 9:00 AM) is still processing and hasn’t been completed.
- As a result, the 9:30 AM workflow cycle is skipped.
3. Consequences
- Between 9:00 AM and 9:30 AM, an additional 100 new orders are created.
- Because the 9:30 AM workflow cycle was skipped, these orders were not processed during that cycle.
4. Following Cycle
- At 10:00 AM, the workflow starts again, searching for new orders created between 9:30 AM and 10:00 AM.
- Only 44 of the 100 new orders created between 9:00 AM and 9:30 AM fall within the 9:30 AM to 10:00 AM time window.
- The remaining 56 orders, created between 9:00 AM and 9:30 AM, are now outside the 30-minute window and will not be processed by the workflow.
Extended Case: Larger Intervals
This issue isn’t limited to short intervals like 30 minutes. If you schedule a workflow to run once a day or every few hours to process records created that day, similar problems can occur. If the previous workflow cycle hasn’t been completed, the system may skip the next cycle, resulting in records not being processed. For example, if a workflow is scheduled to run every 4 hours, and the execution time exceeds 4 hours, the subsequent run might miss records because the saved search filter shifts to the next day.
The Solution: Effective Workflow Scheduling
To avoid missing records, do not schedule workflows to process records based on a specific period (e.g., today, past 30 minutes, past hour). Alternatively, ensure that the execution time of the workflow is always shorter than the interval between scheduled cycles. This approach guarantees that all records are processed efficiently without any being overlooked.
0 Comments