It sounds like running two identical background services is causing timeout issues. Could you share more about the environment they're running in and any specific error logs? Have you tried debugging to see if there's a bottleneck, like connection limits or resource contention? Checking with breakpoints or logging could help narrow down if it's related to API response times or server resources.
One possible issue could be that each BackgroundService is opening a new ServiceBusClient connection. Instead of separate connections, try using a shared ServiceBusClient by registering it as a singleton in Startup.cs. High concurrency settings with SemaphoreSlim (currently set to 10) may also cause contention; reducing this number or adding a retry mechanism could help. Additionally, avoid recreating HttpClient for each request, as this can lead to socket exhaustion—consider making HttpClient a singleton or using IHttpClientFactory. Lastly, check server resources like CPU and memory usage; running two services might be overloading the environment.
Let me know if that helps.