Based on the information provided in the context, the issue you are facing might be due to container OOM, which occurs when the available app memory has run out. This issue causes app restart events, which are reported in the Resource Health section of the Azure portal. Normally, container OOM is caused by incorrect memory size configurations. You can try increasing the memory size configuration for the container to see if it resolves the issue. If the issue persists, you can try checking the CPU usage on the host where the app is running. If CPU usage is 50 percent or more, run your app on a host with a higher configuration. Or you can distribute the load on more machines.
Another possibility is that the issue might be due to connection throttling, which can happen because of either a connection limit on a host machine or Azure SNAT (PAT) port exhaustion. Some Linux systems, such as Red Hat, have an upper limit on the total number of open files, which limits the total number of connections. The number of max allowed open files, which are identified as "nofile," needs to be at least double your connection pool size. If your app is deployed on Azure Virtual Machines without a public IP address, by default Azure SNAT ports establish connections to any endpoint outside of your VM. The number of connections allowed from the VM to the Azure Cosmos DB endpoint is limited by the Azure SNAT configuration. You can add your Azure Cosmos DB service endpoint to the subnet of your Azure Virtual Machines virtual network to avoid Azure SNAT limitation.
In summary, you can try increasing the memory size configuration for the container and checking the CPU usage on the host where the app is running. You can also check if the issue is due to connection throttling by verifying the connection limit on a host machine or Azure SNAT (PAT) port exhaustion.
References:
- App restart issues caused by out-of-memory issues
- Troubleshoot issues when you use Azure Cosmos DB Java SDK v4 with API for NoSQL accounts
- Dataflows considerations and limitations
- Troubleshoot issues when you use the Azure Cosmos DB Async Java SDK v2 with API for NoSQL accounts
- Performance tips for Azure Cosmos DB Java SDK v4