Skip to content
On this page

Service

SRE practices can be reduced to their core subject - the abstract version of a software service.

To precisely and consistently express an abstract service or a service, its parts, and its derivatives, a service must first be defined using a standard computing model.

Below we reuse the finite-state machine (FSM) model to define a service because:

  1. Intuitively, a service can be fully expressed using FSM or automaton primitives and therefore there is no need to invent new abstract concepts.

  2. An FSM or automaton is a widely used and understood computing model even in practice.

Definition

A service S is an FSM of the following quintuple:

S = (ServiceStates, ServiceInputs, ServiceStart, ServiceEnd, ServiceTransitionFunction)

ServiceStates = A set of all service states that can happen in S's lifetime.

ServiceInputs = A set of actions that is generated by a service modifier and can be fed into a ServiceTransitionFunction.

ServiceTransitionFunction = A logic that takes a service state and a service input as inputs and in turn outputs a service state.

ServiceStart = The starting service state of S.

ServiceEnd = A set of service states that can happen last in S's lifetime.

Service Lifetime

A service S's lifetime is the duration that starts from when S's ServiceStart became active for the first time and ends when S's ServiceEnd became active for the last time.

To reinforce the knowledge of expressing a service using FSM primitives the following is provided to demonstrate how this expression can be applied to a naive cloud storage service.

Naive Cloud Storage Service Example

A software service that provides the following services to its clients:

  1. Upload a client's file data.
  2. Download a client's file data.
  3. Delete a client's file data.
  4. Update a client's file data.

Using FSM primitives this service can be expressed as the following:


Kind: Service
metadata:
  name: "Naive Cloud Storage"
spec:
  - ServiceStates:
      - name: UploadRequested
        description: Service is processing a client upload request.
        expect:
          - The user must be presented with an upload progress widget with text "Upload Requested"
          - At this point the upload progress widget progress must be 0%
      - name: UploadInProgress
        description: Service is uploading chunks of client file data.
        expect:
          - User must be presented with an upload progress widget updated with progress values from 0% to 100% in real-time
      - name: UploadFinalizing
        description: Service is finalizing a client's upload request.
        expect:
          - The user must be presented with  an upload progress widget with text "Upload Finalizing"
          - At this point upload progress widget progress must be 100%
      - name: UploadError
        description: Service has encountered an error while processing a client's upload request.
        expect:
          - The user must be presented with an error widget with text "An error was encountered while uploading file {user_file}, please try again"
      - name: UploadThroughputLow
        description: Service's upload throughput is currently lower than average upload througput
        expect:
          - The user must be presented with a text message stating "The upload is taking longer than expected, please be patient."
      - name: Starting
        description: Service is starting.
      - name: Finalizing
        description: Service is finalizing before it fully stops running.
  - ServiceInputs:
      - name: UploadAPIRequest
        description: A client requested a file data upload using the service's upload API.
  - ServiceTransitionFunction:
      - input: UploadAPIRequest
        state: UploadInProgress
        output: UploadRequested
        description: A service can do multiple upload request at the same time.
  - ServiceStart: Starting
  - ServiceEnd: Finalizing