Architecture

The Fluid Framework can be broken into three broad parts: The Fluid loader, Fluid containers, and the Fluid service. While each of these is covered in more detail elsewhere, we’ll use this space to explain the areas at a high level, identify the important lower level concepts, and discuss some of our key design decisions.

Introduction

The Fluid loader connects to the Fluid service and loads a Fluid container.

- C D F l o a i c c e u t D n m o D t F e r - D S l n y F a u t l t o i u a r d S i e d S H L r t o o v R o s a i u r D t d c n e D ) e e t S - r i - m - e - - ( - C - o - n - t - a - i - C n - o e - d r - e ) - - - L - D - o - a - a - t - d - a D - e - D - r - S S - - t - - o - - r - - e - - - - - - - - - - - - - - - - - U - - S R - - c L - D - o - a - p R - t D - e e - a D - s s - S - o - S - l - t - v - o - e - r - r - e - - - - - - - - - - - - - F l u i d S e r v i c e

The Fluid architecture consists of a client and service. The client contains the Fluid loader and the Fluid container. The Fluid loader contains a document service factory, code loader, scopes, and a URL resolver. The Fluid runtime is encapsulated within a container, which is built using Shared objects and distributed data structures.

If you want to load a Fluid container on your app or website, you’ll load the container with the Fluid loader. If you want to create a new collaborative experience using the Fluid Framework, you’ll create a Fluid container.

A Fluid container includes state and app logic. It’s a serverless app model with data persistence. It has at least one shared object, which encapsulates app logic. Shared objects can have state, which is managed by distributed data structures (DDSes).

DDSes are used to distribute state to clients. Instead of centralizing merge logic in the server, the server passes changes (aka operations or ops) to clients and the clients perform the merge.

Design decisions

Keep the server simple

In existing production-quality collaborative algorithms, like Operational Transformations (OT), significant latency is introduced during server-side processing of merge logic.

We dramatically reduce latency by moving merge logic to the client. The more logic we push to the client, the fewer milliseconds the request spends in the datacenter.

Move logic to the client

Because merge logic is performed on the client, other app logic that’s connected to the distributed data should also be performed on the client.

All clients must load the same merge logic and app logic so that clients can compute an eventually consistent state.

Mimic (and embrace) the web

The Fluid Framework creates a distributed app model by distributing state and logic to the client. Because the web is already a system for accessing app logic and app state, we mimicked existing web protocols when possible in our model.

System overview

Most developers will use the Fluid Framework to create Fluid containers.

Based on our two design principles of “Keep the server simple” and “Move logic to the client”, the majority of the Fluid codebase is focused on building containers.

Fluid container

The Fluid container defines the application logic while containing persistent data. If the Fluid Framework is a serverless application model with persistent data, the container is the serverless application and data.

The Fluid container is the result of the principle “Move Logic to the Client.” The container includes the merge logic used to replicate state across connected clients, but the container also includes app logic. The merge logic is encapsulated in our lowest level objects, distributed data structures (DDS). App logic operating over this data is stored in shared objects.

Fluid service

The Fluid service is primarily a total-order broadcast: it takes in changes (called “operations” or “ops”) from each client, gives each op a sequential order number, and sends each ordered op back to each client. Distributed data structures use these ops to reconstruct state on each client. The Fluid service doesn’t parse any of these ops; in fact, the service knows nothing about the contents of any Fluid container.

F l u i d C L o o n a t d a R e i e r n s e o r l v L e o r o k u p & F l u i d S e r v i c e D r i v F e l r u i S d h a U C r R o e L n d r t C e a O o q i b n u n j t e e e a s r c i t t n o e r r C o d e L o a d e r o s p c t o i p o e n s s

Clients send operations to the Fluid service, which are assigned an order and then broadcast to the other connected clients. The client sending the operation also receives an acknowledgement from the service with the assigned order of the operation.

From the client perspective, this op flow is accessed through a DeltaConnection object.

The service also stores old operations, accessible to clients through a DeltaStorageService object, and stores summaries of the shared objects. It’s worth discussing summaries at length, but for now, consider that merging 1,000,000 changes could take some time, so we summarize the state of the objects and store it on the service for faster loading.