Yes, setting FUNCTIONS_WORKER_PROCESS_COUNT = 1
ensures a single instance of MasterClass
per worker process, but not across multiple scaled-out instances of your function app. If scaling is a concern, consider Durable Functions or an external state management approach.
Recommended Approach
Ensure a Single Instance Per Worker Process:
- Setting
FUNCTIONS_WORKER_PROCESS_COUNT = 1
guarantees that only one instance ofMasterClass
exists per function worker process.
Handle Scale-Out with Durable Functions:
- Use Durable Functions Singleton Pattern to ensure a single orchestrator runs per function app.
- Assign a fixed Instance ID to the orchestrator to prevent multiple instances from executing at the same time.
Group Requests with Service Bus Sessions:
- If messages need to be processed in specific groups, enabling Service Bus Sessions ensures that all messages with the same Session ID go to the same function instance.
This approach balances scalability, state consistency, and efficient message grouping for high-performance processing in Azure Functions.
Let me know if you need further clarification!