Skip to content

Commit 6225c8b

Browse files
authored
Merge pull request #103201 from erikadoyle/reviewedits
Service Fabric content portfolio review (batch 4)
2 parents 040ed2d + 88f3dbb commit 6225c8b

File tree

6 files changed

+50
-38
lines changed

6 files changed

+50
-38
lines changed
-3.59 KB
Loading
-46 KB
Loading
-44.2 KB
Loading

articles/service-fabric/service-fabric-package-apps.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ For more information on how to configure the **SetupEntryPoint**, see [Configure
5151

5252
### Build a package by using Visual Studio
5353

54-
If you use Visual Studio 2015 to create your application, you can use the Package command to automatically create a package that matches the layout described above.
54+
If you used Visual Studio to create your application, you can use the *Package* command to automatically create a package that matches the layout described above.
5555

56-
To create a package, right-click the application project in Solution Explorer and choose the Package command, as shown below:
56+
To create a package, right-click the application project in *Solution Explorer* and choose the **Package** command:
5757

5858
![Packaging an application with Visual Studio][vs-package-command]
5959

articles/service-fabric/service-fabric-reliable-services-introduction.md

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,63 @@
22
title: Overview of the Reliable Service programming model
33
description: Learn about Service Fabric's Reliable Service programming model, and get started writing your own services.
44
author: masnider
5-
65
ms.topic: conceptual
76
ms.date: 3/9/2018
87
ms.author: masnider
8+
ms.custom: sfrev
99
---
1010
# Reliable Services overview
11-
Azure Service Fabric simplifies writing and managing stateless and stateful Reliable Services. This topic covers:
11+
12+
Azure Service Fabric simplifies writing and managing stateless and stateful services. This topic covers:
1213

1314
* The Reliable Services programming model for stateless and stateful services.
1415
* The choices you have to make when writing a Reliable Service.
1516
* Some scenarios and examples of when to use Reliable Services and how they are written.
1617

17-
Reliable Services is one of the programming models available on Service Fabric. The other is the Reliable Actor programming model, which provides a virtual Actor programming model on top of the Reliable Services model. For more information on the Reliable Actors programming model, see [Introduction to Service Fabric Reliable Actors](service-fabric-reliable-actors-introduction.md).
18+
*Reliable Services* is one of the programming models available on Service Fabric. Another is the *Reliable Actor* programming model, which provides a [Virtual Actor](https://research.microsoft.com/en-us/projects/orleans/) application framework on top of the Reliable Services model. For more information on Reliable Actors, see [Introduction to Service Fabric Reliable Actors](service-fabric-reliable-actors-introduction.md).
1819

1920
Service Fabric manages the lifetime of services, from provisioning and deployment through upgrade and deletion, via [Service Fabric application management](service-fabric-deploy-remove-applications.md).
2021

21-
## What are Reliable Services?
22+
## What are Reliable Services
23+
2224
Reliable Services gives you a simple, powerful, top-level programming model to help you express what is important to your application. With the Reliable Services programming model, you get:
2325

24-
* Access to the rest of the Service Fabric programming APIs. Unlike Service Fabric Services modeled as [Guest Executables](service-fabric-guest-executables-introduction.md), Reliable Services get to use the rest of the Service Fabric APIs directly. This allows services to:
25-
* query the system
26-
* report health about entities in the cluster
27-
* receive notifications about configuration and code changes
28-
* find and communicate with other services,
29-
* (optionally) use the [Reliable Collections](service-fabric-reliable-services-reliable-collections.md)
30-
* ...and giving them access to many other capabilities, all from a first class programming model in several programming languages.
31-
* A simple model for running your own code that looks like programming models you are used to. Your code has a well-defined entry point and easily managed lifecycle.
26+
* Access to Service Fabric APIs. Unlike Service Fabric services modeled as [Guest Executables](service-fabric-guest-executables-introduction.md), Reliable Services can use Service Fabric APIs directly. This allows services to:
27+
* Query the system
28+
* Report health about entities in the cluster
29+
* Receive notifications about configuration and code changes
30+
* Find and communicate with other services,
31+
* Use the [Reliable Collections](service-fabric-reliable-services-reliable-collections.md)
32+
* Access many other capabilities, all from a first-class programming model in several programming languages.
33+
* A simple model for running your own code that feels like other familiar programming models. Your code has a well-defined entry point and easily managed lifecycle.
3234
* A pluggable communication model. Use the transport of your choice, such as HTTP with [Web API](service-fabric-reliable-services-communication-webapi.md), WebSockets, custom TCP protocols, or anything else. Reliable Services provide some great out-of-the-box options you can use, or you can provide your own.
3335
* For stateful services, the Reliable Services programming model allows you to consistently and reliably store your state right inside your service by using [Reliable Collections](service-fabric-reliable-services-reliable-collections.md). Reliable Collections are a simple set of highly available and reliable collection classes that will be familiar to anyone who has used C# collections. Traditionally, services needed external systems for Reliable state management. With Reliable Collections, you can store your state next to your compute with the same high availability and reliability you've come to expect from highly available external stores. This model also improves latency because you are co-locating the compute and state it needs to function.
3436

35-
## What makes Reliable Services different?
36-
Reliable Services in Service Fabric are different from services you may have written before. Service Fabric provides reliability, availability, consistency, and scalability.
37+
## What makes Reliable Services different
38+
39+
Reliable Services are different from services you may have written before, because Service Fabric provides:
3740

3841
* **Reliability** - Your service stays up even in unreliable environments where your machines fail or hit network issues, or in cases where the services themselves encounter errors and crash or fail. For stateful services, your state is preserved even in the presence of network or other failures.
3942
* **Availability** - Your service is reachable and responsive. Service Fabric maintains your desired number of running copies.
40-
* **Scalability** - Services are decoupled from specific hardware, and they can grow or shrink as necessary through the addition or removal of hardware or other resources. Services are easily partitioned (especially in the stateful case) to ensure that the service can scale and handle partial failures. Services can be created and deleted dynamically via code, enabling more instances to be spun up as necessary, say in response to customer requests. Finally, Service Fabric encourages services to be lightweight. Service Fabric allows thousands of services to be provisioned within a single process, rather than requiring or dedicating entire OS instances or processes to a single instance of a service.
41-
* **Consistency** - Any information stored in this service can be guaranteed to be consistent. This is true even across multiple reliable collections within a service. Changes across collections within a service can be made in a transactionally atomic manner.
43+
* **Scalability** - Services are decoupled from specific hardware, and they can grow or shrink as necessary through the addition or removal of hardware or other resources. Services are easily partitioned (especially in the stateful case) to ensure that the service can scale and handle partial failures. Services can be created and deleted dynamically via code, enabling more instances to be spun up as necessary, for example in response to customer requests. Finally, Service Fabric encourages services to be lightweight. Service Fabric allows thousands of services to be provisioned within a single process, rather than requiring or dedicating entire OS instances or processes to a single instance of a service.
44+
* **Consistency** - Any information stored in a Reliable Service can be guaranteed to be consistent. This is true even across multiple Reliable Collections within a service. Changes across collections within a service can be made in a transactionally atomic manner.
4245

4346
## Service lifecycle
44-
Whether your service is stateful or stateless, Reliable Services provide a simple lifecycle that lets you quickly plug in your code and get started. There are just one or two methods that you need to implement to get your service up and running.
47+
48+
Whether your service is stateful or stateless, Reliable Services provide a simple lifecycle that lets you quickly plug in your code and get started. Getting a new service up and running requires you to implement two methods:
4549

4650
* **CreateServiceReplicaListeners/CreateServiceInstanceListeners** - This method is where the service defines the communication stack(s) that it wants to use. The communication stack, such as [Web API](service-fabric-reliable-services-communication-webapi.md), is what defines the listening endpoint or endpoints for the service (how clients reach the service). It also defines how the messages that appear interact with the rest of the service code.
4751
* **RunAsync** - This method is where your service runs its business logic, and where it would kick off any background tasks that should run for the lifetime of the service. The cancellation token that is provided is a signal for when that work should stop. For example, if the service needs to pull messages out of a Reliable Queue and process them, this is where that work happens.
4852

49-
If you're learning about reliable services for the first time, read on! If you're looking for a detailed walkthrough of the lifecycle of reliable services, you can head over to [this article](service-fabric-reliable-services-lifecycle.md).
53+
If you're learning about reliable services for the first time, read on! If you're looking for a detailed walkthrough of the lifecycle of reliable services, check out [Reliable Services lifecycle overview](service-fabric-reliable-services-lifecycle.md).
5054

5155
## Example services
52-
Knowing this programming model, let's take a quick look at two different services to see how these pieces fit together.
56+
57+
Let's take a closer look how the Reliable Services model works with both stateless and stateful services.
5358

5459
### Stateless Reliable Services
55-
A stateless service is one where there is no state maintained within the service across calls. Any state that is present is entirely disposable and doesn't require synchronization, replication, persistence, or high availability.
60+
61+
A *stateless service* is one where there is no state maintained within the service across calls. Any state that is present is entirely disposable and doesn't require synchronization, replication, persistence, or high availability.
5662

5763
For example, consider a calculator that has no memory and receives all terms and operations to perform at once.
5864

@@ -62,23 +68,25 @@ When a call is made from a client, the appropriate method is invoked, and the ca
6268

6369
Not storing any internal state makes this example calculator simple. But most services aren't truly stateless. Instead, they externalize their state to some other store. (For example, any web app that relies on keeping session state in a backing store or cache is not stateless.)
6470

65-
A common example of how stateless services are used in Service Fabric is as a front-end that exposes the public-facing API for a web application. The front-end service then talks to stateful services to complete a user request. In this case, calls from clients are directed to a known port, such as 80, where the stateless service is listening. This stateless service receives the call and determines whether the call is from a trusted party and which service it's destined for. Then, the stateless service forwards the call to the correct partition of the stateful service and waits for a response. When the stateless service receives a response, it replies to the original client. An example of such a service is in our samples [C#](https://github.com/Azure-Samples/service-fabric-dotnet-getting-started) / [Java](https://github.com/Azure-Samples/service-fabric-java-getting-started). This is only one example of this pattern in the samples, there are others in other samples as well.
71+
A common example of how stateless services are used in Service Fabric is as a front-end that exposes the public-facing API for a web application. The front-end service then talks to stateful services to complete a user request. In this case, calls from clients are directed to a known port, such as 80, where the stateless service is listening. This stateless service receives the call and determines whether the call is from a trusted party and which service it's destined for. Then, the stateless service forwards the call to the correct partition of the stateful service and waits for a response. When the stateless service receives a response, it replies to the original client. An example of such a service is the *Service Fabric Getting Started* sample ([C#](https://github.com/Azure-Samples/service-fabric-dotnet-getting-started) / [Java](https://github.com/Azure-Samples/service-fabric-java-getting-started)), among other Service Fabric samples in that repo.
6672

6773
### Stateful Reliable Services
68-
A stateful service is one that must have some portion of state kept consistent and present in order for the service to function. Consider a service that constantly computes a rolling average of some value based on updates it receives. To do this, it must have the current set of incoming requests it needs to process and the current average. Any service that retrieves, processes, and stores information in an external store (such as an Azure blob or table store today) is stateful. It just keeps its state in the external state store.
74+
75+
A *stateful service* is one that must have some portion of state kept consistent and present in order for the service to function. Consider a service that constantly computes a rolling average of some value based on updates it receives. To do this, it must have the current set of incoming requests it needs to process and the current average. Any service that retrieves, processes, and stores information in an external store (such as an Azure blob or table store today) is stateful. It just keeps its state in the external state store.
6976

7077
Most services today store their state externally, since the external store is what provides reliability, availability, scalability, and consistency for that state. In Service Fabric, services aren't required to store their state externally. Service Fabric takes care of these requirements for both the service code and the service state.
7178

72-
Let's say we want to write a service that processes images. To do this, the service takes in an image and the series of conversions to perform on that image. This service returns a communication listener (let's suppose it's a WebAPI) that exposes an API like `ConvertImage(Image i, IList<Conversion> conversions)`. When it receives a request, the service stores it in a `IReliableQueue`, and returns some id to the client so it can track the request.
79+
Let's say we want to write a service that processes images. To do this, the service takes in an image and the series of conversions to perform on that image. This service returns a communication listener (let's suppose it's a WebAPI) that exposes an API like `ConvertImage(Image i, IList<Conversion> conversions)`. When it receives a request, the service stores it in a `IReliableQueue`, and returns some ID to the client so it can track the request.
7380

7481
In this service, `RunAsync()` could be more complex. The service has a loop inside its `RunAsync()` that pulls requests out of `IReliableQueue` and performs the conversions requested. The results get stored in an `IReliableDictionary` so that when the client comes back they can get their converted images. To ensure that even if something fails the image isn't lost, this Reliable Service would pull out of the queue, perform the conversions, and store the result all in a single transaction. In this case, the message is removed from the queue and the results are stored in the result dictionary only when the conversions are complete. Alternatively, the service could pull the image out of the queue and immediately store it in a remote store. This reduces the amount of state the service has to manage, but increases complexity since the service has to keep the necessary metadata to manage the remote store. With either approach, if something failed in the middle the request remains in the queue waiting to be processed.
7582

76-
One thing to note about this service is that it sounds like a normal .NET service! The only difference is that the data structures being used (`IReliableQueue` and `IReliableDictionary`) are provided by Service Fabric, and are highly reliable, available, and consistent.
83+
Although this service sounds like a typical .NET service, the difference is that the data structures being used (`IReliableQueue` and `IReliableDictionary`) are provided by Service Fabric, and are highly reliable, available, and consistent.
7784

7885
## When to use Reliable Services APIs
79-
If any of the following characterize your application service needs, then you should consider Reliable Services APIs:
8086

81-
* You want your service's code (and optionally state) to be highly available and reliable
87+
Consider Reliable Services APIs if:
88+
89+
* You want your service's code (and optionally state) to be highly available and reliable.
8290
* You need transactional guarantees across multiple units of state (for example, orders and order line items).
8391
* Your application’s state can be naturally modeled as Reliable Dictionaries and Queues.
8492
* Your applications code or state needs to be highly available with low latency reads and writes.
@@ -91,6 +99,7 @@ If any of the following characterize your application service needs, then you sh
9199
* You want to develop or consume third-party-developed, custom state providers.
92100

93101
## Next steps
94-
* [Reliable Services quick start](service-fabric-reliable-services-quick-start.md)
102+
103+
* [Reliable Services quickstart](service-fabric-reliable-services-quick-start.md)
95104
* [Reliable collections](service-fabric-reliable-services-reliable-collections.md)
96105
* [The Reliable Actors programming model](service-fabric-reliable-actors-introduction.md)

0 commit comments

Comments
 (0)