Skip to content

Commit f9fa94c

Browse files
authored
Merge pull request #102572 from erikadoyle/sfrequestdrain
RequestDrain (preview) feature for SF app upgrade
2 parents f3eaf68 + 3dbaa3a commit f9fa94c

File tree

1 file changed

+71
-4
lines changed

1 file changed

+71
-4
lines changed

articles/service-fabric/service-fabric-application-upgrade-advanced.md

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,81 @@ title: Advanced Application Upgrade Topics
33
description: This article covers some advanced topics pertaining to upgrading a Service Fabric application.
44

55
ms.topic: conceptual
6-
ms.date: 2/23/2018
6+
ms.date: 1/28/2020
77
---
8-
# Service Fabric application upgrade: advanced topics
9-
## Adding or removing service types during an application upgrade
8+
# Service Fabric application upgrade: Advanced topics
9+
10+
## Add or remove service types during an application upgrade
11+
1012
If a new service type is added to a published application as part of an upgrade, then the new service type is added to the deployed application. Such an upgrade does not affect any of the service instances that were already part of the application, but an instance of the service type that was added must be created for the new service type to be active (see [New-ServiceFabricService](https://docs.microsoft.com/powershell/module/servicefabric/new-servicefabricservice?view=azureservicefabricps)).
1113

1214
Similarly, service types can be removed from an application as part of an upgrade. However, all service instances of the to-be-removed service type must be removed before proceeding with the upgrade (see [Remove-ServiceFabricService](https://docs.microsoft.com/powershell/module/servicefabric/remove-servicefabricservice?view=azureservicefabricps)).
1315

16+
## Avoid connection drops during stateless service planned downtime (preview)
17+
18+
For planned stateless instance downtimes, such as application/cluster upgrade or node deactivation, connections can get dropped due to the exposed endpoint being removed after it goes down.
19+
20+
To avoid this, configure the *RequestDrain* (preview) feature by adding a replica *instance close delay duration* in the service configuration. This ensures the endpoint advertised by the stateless instance is removed *before* the delay timer starts for closing the instance. This delay enables existing requests to drain gracefully before the instance actually goes down. Clients are notified of the endpoint change by callback function, so they can re-resolve the endpoint and avoid sending new requests to the instance going down.
21+
22+
### Service configuration
23+
24+
There are several ways to configure the delay on the service side.
25+
26+
* **When creating a new service**, specify a `-InstanceCloseDelayDuration`:
27+
28+
```powershell
29+
New-ServiceFabricService -Stateless [-ServiceName] <Uri> -InstanceCloseDelayDuration <TimeSpan>`
30+
```
31+
32+
* **While defining the service in the defaults section in the application manifest**, assign the `InstanceCloseDelayDurationSeconds` property:
33+
34+
```xml
35+
<StatelessService ServiceTypeName="Web1Type" InstanceCount="[Web1_InstanceCount]" InstanceCloseDelayDurationSeconds="15">
36+
<SingletonPartition />
37+
</StatelessService>
38+
```
39+
40+
* **When updating an existing service**, specify a `-InstanceCloseDelayDuration`:
41+
42+
```powershell
43+
Update-ServiceFabricService [-Stateless] [-ServiceName] <Uri> [-InstanceCloseDelayDuration <TimeSpan>]`
44+
```
45+
46+
### Client configuration
47+
48+
To receive notification when an endpoint has changed, clients can register a callback (`ServiceManager_ServiceNotificationFilterMatched`) like this:
49+
50+
```csharp
51+
var filterDescription = new ServiceNotificationFilterDescription
52+
{
53+
Name = new Uri(serviceName),
54+
MatchNamePrefix = true
55+
};
56+
fbClient.ServiceManager.ServiceNotificationFilterMatched += ServiceManager_ServiceNotificationFilterMatched;
57+
await fbClient.ServiceManager.RegisterServiceNotificationFilterAsync(filterDescription);
58+
59+
private static void ServiceManager_ServiceNotificationFilterMatched(object sender, EventArgs e)
60+
{
61+
// Resolve service to get a new endpoint list
62+
}
63+
```
64+
65+
The change notification is an indication that the endpoints have changed, the client should re-resolve the endpoints, and not use the endpoints which are not advertised anymore as they will go down soon.
66+
67+
### Optional upgrade overrides
68+
69+
In addition to setting default delay durations per service, you can also override the delay during application/cluster upgrade using the same (`InstanceCloseDelayDurationSec`) option:
70+
71+
```powershell
72+
Start-ServiceFabricApplicationUpgrade [-ApplicationName] <Uri> [-ApplicationTypeVersion] <String> [-InstanceCloseDelayDurationSec <UInt32>]
73+
74+
Start-ServiceFabricClusterUpgrade [-CodePackageVersion] <String> [-ClusterManifestVersion] <String> [-InstanceCloseDelayDurationSec <UInt32>]
75+
```
76+
77+
The delay duration only applies to the invoked upgrade instance and does not otherwise change individual service delay configurations. For example, you can use this to specify a delay of `0` in order to skip any preconfigured upgrade delays.
78+
1479
## Manual upgrade mode
80+
1581
> [!NOTE]
1682
> The *Monitored* upgrade mode is recommended for all Service Fabric upgrades.
1783
> The *UnmonitoredManual* upgrade mode should only be considered for failed or suspended upgrades.
@@ -25,6 +91,7 @@ In *UnmonitoredManual* mode, the application administrator has total control ove
2591
Finally, the *UnmonitoredAuto* mode is useful for performing fast upgrade iterations during service development or testing since no user input is required and no application health policies are evaluated.
2692

2793
## Upgrade with a diff package
94+
2895
Instead of provisioning a complete application package, upgrades can also be performed by provisioning diff packages that contain only the updated code/config/data packages along with the complete application manifest and complete service manifests. Complete application packages are only required for the initial installation of an application to the cluster. Subsequent upgrades can either be from complete application packages or diff packages.
2996

3097
Any reference in the application manifest or service manifests of a diff package that can't be found in the application package is automatically replaced with the currently provisioned version.
@@ -108,7 +175,7 @@ HealthState : Ok
108175
ApplicationParameters : { "ImportantParameter" = "2"; "NewParameter" = "testAfter" }
109176
```
110177

111-
## Rolling back application upgrades
178+
## Roll back application upgrades
112179

113180
While upgrades can be rolled forward in one of three modes (*Monitored*, *UnmonitoredAuto*, or *UnmonitoredManual*), they can only be rolled back in either *UnmonitoredAuto* or *UnmonitoredManual* mode. Rolling back in *UnmonitoredAuto* mode works the same way as rolling forward with the exception that the default value of *UpgradeReplicaSetCheckTimeout* is different - see [Application Upgrade Parameters](service-fabric-application-upgrade-parameters.md). Rolling back in *UnmonitoredManual* mode works the same way as rolling forward - the rollback will suspend itself after completing each UD and must be explicitly resumed using [Resume-ServiceFabricApplicationUpgrade](https://docs.microsoft.com/powershell/module/servicefabric/resume-servicefabricapplicationupgrade?view=azureservicefabricps) to continue with the rollback.
114181

0 commit comments

Comments
 (0)