azure-sdk-for-net
azure-sdk-for-net copied to clipboard
[FEATURE REQ]
Library name
Microsoft.Azure.WebJobs.Extensions.EventHubs
Please describe the feature.
Add a configuration option to set a timeout for the output binding. The output binding should throw an error when the operation takes longer than the configured timeout to complete.
Background: We have an azure function that uses a cosmosDBTrigger input binding and an Event Hubs output binding. The output binding typically executes within milliseconds, but sometimes it takes a couple of seconds. A couple of days ago, it took 57 seconds. The Azure Function does not complete until the output binding completes, which means that the function execution just hangs. For some functions that might not be a big issue, but some triggers (including CosmosDBTrigger) do not retrigger the function until the previous execution has completed. This means our (quite critical) function did nothing for almost a minute.
I am not mad about the 57 second delay. Weird network hickups happen sometimes. But it really should be possible to set a timeout.
Thank you for your feedback. Tagging and routing to the team member best able to assist.
Hi @JoostLambregts. Thanks for reaching out and for your suggestion. The clientRetryOptions/tryTimeout setting governs the total time that a service operation attempt can run. In the case of transient failures, each implicit retry is given this amount of time to complete. It is important to note that any service operation may incur the cost of creating a connection, creating an AMQP link, and authorization in addition to the send that you're attempting to do. As a result, we do not recommend lowering the TryTimeout from the default without thorough testing, as you may find yourself unable to recover from any network failures or idle timeouts.
For your scenario, we'd recommend using the EventHubProducerClient directly in your Function body rather than using the output binding. This allows more explicit control over the time allowed for a given send operation using the cancellation token passed to SendAsync. It also allows you to fall back to allowing more time if you're seeing frequent timeouts due to the cost of creating/authorizing the connection.
Because you're looking to minimize send latency, you'll probably also want to increase the default IdleTimeout in the options used to create your producer. It may also be helpful to implement a timer in the background that periodically creates and discards a batch, which will serve as a forcing function for the connection and link, reducing the potential for idle timeouts and reducing the likelihood that you'll need to pay the connection task when sending.
Hi @JoostLambregts. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation.
@jsquire Thanks for the detailed explanation and advice. This is everything I need.
Hi @JoostLambregts, since you haven’t asked that we /unresolve the issue, we’ll close this out. If you believe further discussion is needed, please add a comment /unresolve to reopen the issue.