Skip to content

Commit 0083174

Browse files
authored
Merge pull request #167055 from spelluru/egriddelivery0727
batching behavior and other updates
2 parents 1e6723e + 2fc79fc commit 0083174

File tree

2 files changed

+64
-46
lines changed

2 files changed

+64
-46
lines changed

articles/event-grid/delivery-and-retry.md

Lines changed: 62 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,16 @@
22
title: Azure Event Grid delivery and retry
33
description: Describes how Azure Event Grid delivers events and how it handles undelivered messages.
44
ms.topic: conceptual
5-
ms.date: 10/29/2020
5+
ms.date: 07/27/2021
66
---
77

88
# Event Grid message delivery and retry
9-
10-
This article describes how Azure Event Grid handles events when delivery isn't acknowledged.
11-
12-
Event Grid provides durable delivery. It delivers each message **at least once** for each subscription. Events are sent to the registered endpoint of each subscription immediately. If an endpoint doesn't acknowledge receipt of an event, Event Grid retries delivery of the event.
9+
Event Grid provides durable delivery. It tries to deliver each message **at least once** for each matching subscription immediately. If a subscriber's endpoint doesn't acknowledge receipt of an event or if there is a failure, Event Grid retries delivery based on a fixed [retry schedule](#retry-schedule) and [retry policy](#retry-policy). By default, the Event Grid module delivers one event at a time to the subscriber. The payload is however an array with a single event.
1310

1411
> [!NOTE]
1512
> Event Grid doesn't guarantee order for event delivery, so subscribers may receive them out of order.
1613
17-
## Batched event delivery
18-
19-
Event Grid defaults to sending each event individually to subscribers. The subscriber receives an array with a single event. You can configure Event Grid to batch events for delivery for improved HTTP performance in high-throughput scenarios.
20-
21-
Batched delivery has two settings:
22-
23-
* **Max events per batch** - Maximum number of events Event Grid will deliver per batch. This number will never be exceeded, however fewer events may be delivered if no other events are available at the time of publish. Event Grid doesn't delay events to create a batch if fewer events are available. Must be between 1 and 5,000.
24-
* **Preferred batch size in kilobytes** - Target ceiling for batch size in kilobytes. Similar to max events, the batch size may be smaller if more events aren't available at the time of publish. It's possible that a batch is larger than the preferred batch size *if* a single event is larger than the preferred size. For example, if the preferred size is 4 KB and a 10-KB event is pushed to Event Grid, the 10-KB event will still be delivered in its own batch rather than being dropped.
25-
26-
Batched delivery in configured on a per-event subscription basis via the portal, CLI, PowerShell, or SDKs.
27-
28-
### Azure portal:
29-
![Batch delivery settings](./media/delivery-and-retry/batch-settings.png)
30-
31-
### Azure CLI
32-
When creating an event subscription, use the following parameters:
33-
34-
- **max-events-per-batch** - Maximum number of events in a batch. Must be a number between 1 and 5000.
35-
- **preferred-batch-size-in-kilobytes** - Preferred batch size in kilobytes. Must be a number between 1 and 1024.
36-
37-
```azurecli
38-
storageid=$(az storage account show --name <storage_account_name> --resource-group <resource_group_name> --query id --output tsv)
39-
endpoint=https://$sitename.azurewebsites.net/api/updates
40-
41-
az eventgrid event-subscription create \
42-
--resource-id $storageid \
43-
--name <event_subscription_name> \
44-
--endpoint $endpoint \
45-
--max-events-per-batch 1000 \
46-
--preferred-batch-size-in-kilobytes 512
47-
```
48-
49-
For more information on using Azure CLI with Event Grid, see [Route storage events to web endpoint with Azure CLI](../storage/blobs/storage-blob-event-quickstart.md).
50-
51-
## Retry schedule and duration
52-
14+
## Retry schedule
5315
When EventGrid receives an error for an event delivery attempt, EventGrid decides whether it should retry the delivery, dead-letter the event, or drop the event based on the type of the error.
5416

5517
If the error returned by the subscribed endpoint is a configuration-related error that can't be fixed with retries (for example, if the endpoint is deleted), EventGrid will either perform dead-lettering on the event or drop the event if dead-letter isn't configured.
@@ -84,12 +46,68 @@ If the endpoint responds within 3 minutes, Event Grid will attempt to remove the
8446

8547
Event Grid adds a small randomization to all retry steps and may opportunistically skip certain retries if an endpoint is consistently unhealthy, down for a long period, or appears to be overwhelmed.
8648

87-
For deterministic behavior, set the event time-to-live and max delivery attempts in the [subscription retry policies](manage-event-delivery.md).
49+
## Retry policy
50+
You can customize the retry policy when creating an event subscription by using the following two configurations. An event will be dropped if either of the limits of the retry policy is reached.
8851

89-
By default, Event Grid expires all events that aren't delivered within 24 hours. You can [customize the retry policy](manage-event-delivery.md) when creating an event subscription. You provide the maximum number of delivery attempts (default is 30) and the event time-to-live (default is 1440 minutes).
52+
- **Maximum number of attempts** - The value must be an integer between 1 and 30. The default value is 30.
53+
- **Event time-to-live (TTL)** - The value must be an integer between 1 and 1440. The default value is 1440 minutes
9054

91-
## Delayed Delivery
55+
For sample CLI and PowerShell command to configure these settings, see [Set retry policy](manage-event-delivery.md#set-retry-policy).
56+
57+
## Output batching
58+
Event Grid defaults to sending each event individually to subscribers. The subscriber receives an array with a single event. You can configure Event Grid to batch events for delivery for improved HTTP performance in high-throughput scenarios. Batching is turned off by default and can be turned on per-subscription.
59+
60+
### Batching policy
61+
Batched delivery has two settings:
9262

63+
* **Max events per batch** - Maximum number of events Event Grid will deliver per batch. This number will never be exceeded, however fewer events may be delivered if no other events are available at the time of publish. Event Grid doesn't delay events to create a batch if fewer events are available. Must be between 1 and 5,000.
64+
* **Preferred batch size in kilobytes** - Target ceiling for batch size in kilobytes. Similar to max events, the batch size may be smaller if more events aren't available at the time of publish. It's possible that a batch is larger than the preferred batch size *if* a single event is larger than the preferred size. For example, if the preferred size is 4 KB and a 10-KB event is pushed to Event Grid, the 10-KB event will still be delivered in its own batch rather than being dropped.
65+
66+
Batched delivery in configured on a per-event subscription basis via the portal, CLI, PowerShell, or SDKs.
67+
68+
### Batching behavior
69+
70+
* All or none
71+
72+
Event Grid operates with all-or-none semantics. It doesn't support partial success of a batch delivery. Subscribers should be careful to only ask for as many events per batch as they can reasonably handle in 60 seconds.
73+
74+
* Optimistic batching
75+
76+
The batching policy settings aren't strict bounds on the batching behavior, and are respected on a best-effort basis. At low event rates, you'll often observe the batch size being less than the requested maximum events per batch.
77+
78+
* Default is set to OFF
79+
80+
By default, Event Grid only adds one event to each delivery request. The way to turn on batching is to set either one of the settings mentioned earlier in the article in the event subscription JSON.
81+
82+
* Default values
83+
84+
It isn't necessary to specify both the settings (Maximum events per batch and Approximate batch size in kilo bytes) when creating an event subscription. If only one setting is set, Event Grid uses (configurable) default values. See the following sections for the default values, and how to override them.
85+
86+
### Azure portal:
87+
![Batch delivery settings](./media/delivery-and-retry/batch-settings.png)
88+
89+
### Azure CLI
90+
When creating an event subscription, use the following parameters:
91+
92+
- **max-events-per-batch** - Maximum number of events in a batch. Must be a number between 1 and 5000.
93+
- **preferred-batch-size-in-kilobytes** - Preferred batch size in kilobytes. Must be a number between 1 and 1024.
94+
95+
```azurecli
96+
storageid=$(az storage account show --name <storage_account_name> --resource-group <resource_group_name> --query id --output tsv)
97+
endpoint=https://$sitename.azurewebsites.net/api/updates
98+
99+
az eventgrid event-subscription create \
100+
--resource-id $storageid \
101+
--name <event_subscription_name> \
102+
--endpoint $endpoint \
103+
--max-events-per-batch 1000 \
104+
--preferred-batch-size-in-kilobytes 512
105+
```
106+
107+
For more information on using Azure CLI with Event Grid, see [Route storage events to web endpoint with Azure CLI](../storage/blobs/storage-blob-event-quickstart.md).
108+
109+
110+
## Delayed Delivery
93111
As an endpoint experiences delivery failures, Event Grid will begin to delay the delivery and retry of events to that endpoint. For example, if the first 10 events published to an endpoint fail, Event Grid will assume that the endpoint is experiencing issues and will delay all subsequent retries *and new* deliveries for some time - in some cases up to several hours.
94112

95113
The functional purpose of delayed delivery is to protect unhealthy endpoints and the Event Grid system. Without back-off and delay of delivery to unhealthy endpoints, Event Grid's retry policy and volume capabilities can easily overwhelm a system.

articles/event-grid/manage-event-delivery.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Dead letter and retry policies - Azure Event Grid
33
description: Describes how to customize event delivery options for Event Grid. Set a dead-letter destination, and specify how long to retry delivery.
44
ms.topic: conceptual
5-
ms.date: 07/20/2020
5+
ms.date: 07/27/2021
66
ms.custom: devx-track-azurepowershell
77
---
88

@@ -68,7 +68,7 @@ To turn off dead-lettering, rerun the command to create the event subscription b
6868

6969
When creating an Event Grid subscription, you can set values for how long Event Grid should try to deliver the event. By default, Event Grid tries for 24 hours (1440 minutes), or 30 times. You can set either of these values for your event grid subscription. The value for event time-to-live must be an integer from 1 to 1440. The value for max retries must be an integer from 1 to 30.
7070

71-
You can't configure the [retry schedule](delivery-and-retry.md#retry-schedule-and-duration).
71+
You can't configure the [retry schedule](delivery-and-retry.md#retry-schedule).
7272

7373
### Azure CLI
7474

0 commit comments

Comments
 (0)