SlideShare a Scribd company logo
1 of 45
Offline-first
application data and synchronization
18 February 2016
⌘
Maksym Barbul
2
Maksym Barbul
Senior Software
Engineermaxbarbul [at] gmail.com
Introduction
3
Problem statement
4
So, why is it a problem?
● user is blocked in offline
● connection (blink, detection delay, unstable)
● data is always changing
It may bring user to loose data
5
What is different?
6
● Client UX (non-blocking, responsive, reliable)
● Client has smart caching
● Client partially duplicates server’s logic
● Controlled connectivity
● Smart synchronization
Offline-first is a Paradigm
is a distinct set of concepts or thought
patterns, including theories, research
methods, postulates, and standards for
what constitutes legitimate contributions
to a field
7
§
Who needs these super-smart apps?
● Field workers
● Store observation
● Technical audit
● Medical observation
BUSINESS
EFFICIENCY
8
Who needs these super-smart apps?
● Instant messengers
● Social networks
● Document editors
● Media organizers
ALLUSERS
LOYALTY
9
Offline Application
10
Components of an offline-first app
11
Troubleshooting
Offline
First
How is an offline-first app built?
12
Offline data
Synchronization
Connectivity
User Experience
Trouble-
shooting
Offline Data
13
Data slices
14
Application
Static Meta-
Data
Business
Data
System
Runtime Data
Data slices: Application
15
Application
Static Meta-
Data
Business
Data
System
Runtime Data
Core (scripts)
Modules (scripts)
Styles & Views (scripts, CSS)
Media resources
Data slices: Static Meta-Data
16
Application
Static Meta-
Data
Business
Data
System
Runtime Data
Configuration & Settings
Layout Declaration
Permissions
Translations
Data slices: Business Data
17
Application
Static Meta-
Data
Business
Data
System
Runtime Data
Dictionaries
Fetched Data (Read only)
Entered Data (User Data)
Data slices: System Runtime Data
18
Application
Static Meta-
Data
Business
Data
System
Runtime Data
Logs (action, error,
profiling)
Session Data
Transaction States (Sync)
Data Synchronization
19
Data Synchronization Types
20
Data Synchronization Types
21
Replication
Synchronization (replication) Strategies
22
● Pessimistic - no inconsistency
● Optimistic - eventual consistency
Eventual Consistency
means that replicas eventually reach the same
value if clients stop submitting updates
23
§
Optimistic replication algorithm
24
1. Operation submission (user submission)
2. Propagation to other replicas
3. Scheduling of operations to apply by each
replica
4. Conflict resolution (syntactic, semantic)
5. Commitment on a final schedule and
Strong Eventual Consistency (SEC)
is a property of some eventually-consistent
systems: replicas that have received and
applied the same set of updates must
immediately have equivalent state
25
§
Conflict-free replicated data type (CRDT)
26
is a type of specially-designed data structure
used to achieve strong eventual consistency
(SEC) and monotonicity (absence of rollbacks)
● operation-based
● state-based
Operation-based CRDTs (CmRDT)
27
commutative replicated data types
The operations are commutative, so can
be received and applied in any order;
however, they are not idempotent, and
additional network protocol guarantees are
required to ensure unique delivery
a * b = b * a
O(a) ≠ O(O(a))
State-based CRDTs (CvRDT)
28
convergent replicated data types
CvRDTs send their full local state to
other replicas
State-based CRDTs (CvRDT): Interface
29
➔ query - reads the state of the replica, with no side
effects
➔ update - writes to the replica state in accordance with
certain restrictions (monotonically increase)
➔ merge - merges local state with the state of some
remote replica (commutative, associative, and
idempotent)
a * b = b * a
O(a, b) = O(O(a, b), b)
a*(b*c) = (a*b)*c
CvRDT: increment only
30
is an element of
for each i
CvRDT: grow-only set (add)
31
add {e} to set A
S.A is a subset of T.A
unite sets
CvRDT: 2P-set (add, remove)
32
Operational transformation (OT)
33
is a technology for supporting a range of
collaboration functionalities in advanced
collaborative software systems. OT was
originally invented for consistency
maintenance and concurrency control in
collaborative editing of plain text documents
Apache
Wave
Google
Docs
Operational transformation (OT)
34
➔O1 = Insert[0, "x"] // “xabc”
(to insert character "x" at position "0")
➔O2 = Delete[2, "c"] // “xabc” ???
(to delete the character "c" at position "2")
“abc”
➔* O2 = Delete[3, "c"] // “xab”
Operational transformation (OT)
35
Unfortunately, implementing OT sucks. There's a million
algorithms with different tradeoffs, mostly trapped in
academic papers. The algorithms are really hard and time
consuming to implement correctly. ... Wave took 2 years to
write and if we rewrote it today, it would take almost as
long to write a second time.
Joseph Gentle
who is an ex Google Wave engineer and an author of the Share.JS
Example: Chat
36
{String} title
{Object} participants
{Array} messages
CvRDT increment-only
(LWW)
CvRDT set
CmRDT or CvRDT
Example: Booking
37
{Date} date_from, date_to
{String} user_id
{String} room_id
{String} booking_status
CvRDT (LWW)
NONE (not editable)
CvRDT (LWW)
CvRDT
Example: Collaborative field editing
38
{String} text
Operational
transformation
Don’t forget about AUDIT
39
● Why do we have this value?
● Who did this change?
● When?
● What was the previous value?
References: read theory
● Offline First manifesto http://offlinefirst.org/
● Links to articles, events, samples https://github.com/offlinefirst
● Designing Offline-First Web Apps http://alistapart.com/article/offline-first
● SAY HELLO TO OFFLINE FIRST http://hood.ie/blog/say-hello-to-offline-first.html
● Optimistic replication https://www.wikiwand.com/en/Optimistic_replication
● CRDT http://www.wikiwand.com/en/Conflict-free_replicated_data_type
● OT http://www.wikiwand.com/en/Operational_transformation
● appSync.org: open-source patterns & code for data synchronization in mobile apps
http://confluence.tapcrowd.com/pages/viewpage.action;jsessionid=3F4D2C44DBFC46644A7955F82
A416DC2?pageId=2262404
● * Free Book “Distributed Systems” by Mikito Takada http://book.mixu.net/distsys/index.html
● Roshi CRDT explanation https://developers.soundcloud.com/blog/roshi-a-crdt-system-for-
timestamped-events
● A comprehensive study of CRDTs by Marc Shapiro
https://hal.inria.fr/file/index/docid/555588/filename/techreport.pdf
40
References: source code
● appSync source https://bitbucket.org/nikonelissen/appsync/src
● CRDT Roshi by SoundCloud with great expanation https://github.com/soundcloud/roshi
● CRDT Riak by Basho (League of Legends) https://github.com/basho/
● ShareJS https://github.com/share/ShareJS
● Hoodie https://github.com/hoodiehq/hoodie
41
References: borrowed resources
● Sync types diagram http://confluence.tapcrowd.com/pages/viewpage.action?pageId=2262404
● Free icons found here http://findicons.com/
42
Summary: how to build offline-first apps
43
● Know the Paradigm
● Plan data structure and synchronization
approaches before development
● Be paranoid about user’s data
● Develop offline-first applications
The End?
44
Thank you.
eager to use your great Offline apps
😉
Questions...
45
🙋

More Related Content

What's hot (6)

WEB DESIGN
WEB DESIGNWEB DESIGN
WEB DESIGN
 
Silk Performer Presentation v1
Silk Performer Presentation v1Silk Performer Presentation v1
Silk Performer Presentation v1
 
Introduction to White box testing
Introduction to White box testingIntroduction to White box testing
Introduction to White box testing
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven Development
 
Exploratory Testing in Practice
Exploratory Testing in PracticeExploratory Testing in Practice
Exploratory Testing in Practice
 
Wzorce projektowe w automatyzacji testów aplikacji webowych
Wzorce projektowe w automatyzacji testów aplikacji webowychWzorce projektowe w automatyzacji testów aplikacji webowych
Wzorce projektowe w automatyzacji testów aplikacji webowych
 

Viewers also liked

Implementing Server Side Data Synchronization for Mobile Apps
Implementing Server Side Data Synchronization for Mobile AppsImplementing Server Side Data Synchronization for Mobile Apps
Implementing Server Side Data Synchronization for Mobile AppsMichele Orselli
 
Sync is hard: building offline-first Android apps from the ground up
Sync is hard: building offline-first Android apps from the ground up	Sync is hard: building offline-first Android apps from the ground up
Sync is hard: building offline-first Android apps from the ground up droidcon Dubai
 
Влияние UX на исходный код приложения. Валерий Сорокобатько
Влияние UX на исходный код приложения. Валерий СорокобатькоВлияние UX на исходный код приложения. Валерий Сорокобатько
Влияние UX на исходный код приложения. Валерий СорокобатькоEatDog
 
Data flow layer. Захарченко Артем
Data flow layer. Захарченко АртемData flow layer. Захарченко Артем
Data flow layer. Захарченко АртемEatDog
 
View models for component driven
View models for component drivenView models for component driven
View models for component drivenEatDog
 
Offline Application Cache
Offline Application CacheOffline Application Cache
Offline Application CacheJonathan Stark
 
AppliFire Blue Print Design Guidelines
AppliFire Blue Print Design GuidelinesAppliFire Blue Print Design Guidelines
AppliFire Blue Print Design GuidelinesAppliFire Platform
 
Implementing Data Caching and Data Synching Using Oracle MAF
Implementing Data Caching and Data Synching Using Oracle MAFImplementing Data Caching and Data Synching Using Oracle MAF
Implementing Data Caching and Data Synching Using Oracle MAFSteven Davelaar
 
Offnet- Offline Mobile Application
Offnet- Offline Mobile ApplicationOffnet- Offline Mobile Application
Offnet- Offline Mobile ApplicationSudip Adhikari
 
Offline Strategy for an Online World
Offline Strategy for an Online WorldOffline Strategy for an Online World
Offline Strategy for an Online WorldSoCal UX Camp
 

Viewers also liked (13)

Implementing Server Side Data Synchronization for Mobile Apps
Implementing Server Side Data Synchronization for Mobile AppsImplementing Server Side Data Synchronization for Mobile Apps
Implementing Server Side Data Synchronization for Mobile Apps
 
Offline First Applications
Offline First ApplicationsOffline First Applications
Offline First Applications
 
Sync is hard: building offline-first Android apps from the ground up
Sync is hard: building offline-first Android apps from the ground up	Sync is hard: building offline-first Android apps from the ground up
Sync is hard: building offline-first Android apps from the ground up
 
Влияние UX на исходный код приложения. Валерий Сорокобатько
Влияние UX на исходный код приложения. Валерий СорокобатькоВлияние UX на исходный код приложения. Валерий Сорокобатько
Влияние UX на исходный код приложения. Валерий Сорокобатько
 
Data flow layer. Захарченко Артем
Data flow layer. Захарченко АртемData flow layer. Захарченко Артем
Data flow layer. Захарченко Артем
 
View models for component driven
View models for component drivenView models for component driven
View models for component driven
 
Offline Application Cache
Offline Application CacheOffline Application Cache
Offline Application Cache
 
AppliFire Blue Print Design Guidelines
AppliFire Blue Print Design GuidelinesAppliFire Blue Print Design Guidelines
AppliFire Blue Print Design Guidelines
 
Implementing Data Caching and Data Synching Using Oracle MAF
Implementing Data Caching and Data Synching Using Oracle MAFImplementing Data Caching and Data Synching Using Oracle MAF
Implementing Data Caching and Data Synching Using Oracle MAF
 
Timestamp protocols
Timestamp protocolsTimestamp protocols
Timestamp protocols
 
Offnet- Offline Mobile Application
Offnet- Offline Mobile ApplicationOffnet- Offline Mobile Application
Offnet- Offline Mobile Application
 
Offline Strategy for an Online World
Offline Strategy for an Online WorldOffline Strategy for an Online World
Offline Strategy for an Online World
 
Designing For Offline
Designing For OfflineDesigning For Offline
Designing For Offline
 

Similar to Offline first: application data and synchronization

Exploiting the Data / Code Duality with Dali
Exploiting the Data / Code Duality with DaliExploiting the Data / Code Duality with Dali
Exploiting the Data / Code Duality with DaliCarl Steinbach
 
Object oriented design patterns for distributed systems
Object oriented design patterns for distributed systemsObject oriented design patterns for distributed systems
Object oriented design patterns for distributed systemsJordan McBain
 
JavaScript for Enterprise Applications
JavaScript for Enterprise ApplicationsJavaScript for Enterprise Applications
JavaScript for Enterprise ApplicationsPiyush Katariya
 
Apache Calcite: One Frontend to Rule Them All
Apache Calcite: One Frontend to Rule Them AllApache Calcite: One Frontend to Rule Them All
Apache Calcite: One Frontend to Rule Them AllMichael Mior
 
Building Conclave: a decentralized, real-time collaborative text editor
Building Conclave: a decentralized, real-time collaborative text editorBuilding Conclave: a decentralized, real-time collaborative text editor
Building Conclave: a decentralized, real-time collaborative text editorSun-Li Beatteay
 
OpenTelemetry For Architects
OpenTelemetry For ArchitectsOpenTelemetry For Architects
OpenTelemetry For ArchitectsKevin Brockhoff
 
Migrate to Microservices Judiciously!
Migrate to Microservices Judiciously!Migrate to Microservices Judiciously!
Migrate to Microservices Judiciously!pflueras
 
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)Codit
 
Considerations for Abstracting Complexities of a Real-Time ML Platform, Zhenz...
Considerations for Abstracting Complexities of a Real-Time ML Platform, Zhenz...Considerations for Abstracting Complexities of a Real-Time ML Platform, Zhenz...
Considerations for Abstracting Complexities of a Real-Time ML Platform, Zhenz...HostedbyConfluent
 
Data platform architecture principles - ieee infrastructure 2020
Data platform architecture principles - ieee infrastructure 2020Data platform architecture principles - ieee infrastructure 2020
Data platform architecture principles - ieee infrastructure 2020Julien Le Dem
 
Databases through out and beyond Big Data hype
Databases through out and beyond Big Data hypeDatabases through out and beyond Big Data hype
Databases through out and beyond Big Data hypeParinaz Ameri
 
Flux architecture and Redux - theory, context and practice
Flux architecture and Redux - theory, context and practiceFlux architecture and Redux - theory, context and practice
Flux architecture and Redux - theory, context and practiceJakub Kocikowski
 
Advanced web application architecture - PHP Barcelona
Advanced web application architecture  - PHP BarcelonaAdvanced web application architecture  - PHP Barcelona
Advanced web application architecture - PHP BarcelonaMatthias Noback
 
5G-USA-Telemetry
5G-USA-Telemetry5G-USA-Telemetry
5G-USA-Telemetrysnrism
 
Data Discovery and Metadata
Data Discovery and MetadataData Discovery and Metadata
Data Discovery and Metadatamarkgrover
 
Disadvantages Of Robotium
Disadvantages Of RobotiumDisadvantages Of Robotium
Disadvantages Of RobotiumSusan Tullis
 
Foundational Design Patterns for Multi-Purpose Applications
Foundational Design Patterns for Multi-Purpose ApplicationsFoundational Design Patterns for Multi-Purpose Applications
Foundational Design Patterns for Multi-Purpose ApplicationsChing-Hwa Yu
 
Apache Kafka® and the Data Mesh
Apache Kafka® and the Data MeshApache Kafka® and the Data Mesh
Apache Kafka® and the Data MeshConfluentInc1
 
Unit-III(Design).pptx
Unit-III(Design).pptxUnit-III(Design).pptx
Unit-III(Design).pptxFajar Baskoro
 

Similar to Offline first: application data and synchronization (20)

Exploiting the Data / Code Duality with Dali
Exploiting the Data / Code Duality with DaliExploiting the Data / Code Duality with Dali
Exploiting the Data / Code Duality with Dali
 
Object oriented design patterns for distributed systems
Object oriented design patterns for distributed systemsObject oriented design patterns for distributed systems
Object oriented design patterns for distributed systems
 
JavaScript for Enterprise Applications
JavaScript for Enterprise ApplicationsJavaScript for Enterprise Applications
JavaScript for Enterprise Applications
 
Apache Calcite: One Frontend to Rule Them All
Apache Calcite: One Frontend to Rule Them AllApache Calcite: One Frontend to Rule Them All
Apache Calcite: One Frontend to Rule Them All
 
Building Conclave: a decentralized, real-time collaborative text editor
Building Conclave: a decentralized, real-time collaborative text editorBuilding Conclave: a decentralized, real-time collaborative text editor
Building Conclave: a decentralized, real-time collaborative text editor
 
Intro to Databases
Intro to DatabasesIntro to Databases
Intro to Databases
 
OpenTelemetry For Architects
OpenTelemetry For ArchitectsOpenTelemetry For Architects
OpenTelemetry For Architects
 
Migrate to Microservices Judiciously!
Migrate to Microservices Judiciously!Migrate to Microservices Judiciously!
Migrate to Microservices Judiciously!
 
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)
 
Considerations for Abstracting Complexities of a Real-Time ML Platform, Zhenz...
Considerations for Abstracting Complexities of a Real-Time ML Platform, Zhenz...Considerations for Abstracting Complexities of a Real-Time ML Platform, Zhenz...
Considerations for Abstracting Complexities of a Real-Time ML Platform, Zhenz...
 
Data platform architecture principles - ieee infrastructure 2020
Data platform architecture principles - ieee infrastructure 2020Data platform architecture principles - ieee infrastructure 2020
Data platform architecture principles - ieee infrastructure 2020
 
Databases through out and beyond Big Data hype
Databases through out and beyond Big Data hypeDatabases through out and beyond Big Data hype
Databases through out and beyond Big Data hype
 
Flux architecture and Redux - theory, context and practice
Flux architecture and Redux - theory, context and practiceFlux architecture and Redux - theory, context and practice
Flux architecture and Redux - theory, context and practice
 
Advanced web application architecture - PHP Barcelona
Advanced web application architecture  - PHP BarcelonaAdvanced web application architecture  - PHP Barcelona
Advanced web application architecture - PHP Barcelona
 
5G-USA-Telemetry
5G-USA-Telemetry5G-USA-Telemetry
5G-USA-Telemetry
 
Data Discovery and Metadata
Data Discovery and MetadataData Discovery and Metadata
Data Discovery and Metadata
 
Disadvantages Of Robotium
Disadvantages Of RobotiumDisadvantages Of Robotium
Disadvantages Of Robotium
 
Foundational Design Patterns for Multi-Purpose Applications
Foundational Design Patterns for Multi-Purpose ApplicationsFoundational Design Patterns for Multi-Purpose Applications
Foundational Design Patterns for Multi-Purpose Applications
 
Apache Kafka® and the Data Mesh
Apache Kafka® and the Data MeshApache Kafka® and the Data Mesh
Apache Kafka® and the Data Mesh
 
Unit-III(Design).pptx
Unit-III(Design).pptxUnit-III(Design).pptx
Unit-III(Design).pptx
 

More from EatDog

Классифицируем текст в iOS без CoreML: как и зачем?
Классифицируем текст в iOS без CoreML: как и зачем? Классифицируем текст в iOS без CoreML: как и зачем?
Классифицируем текст в iOS без CoreML: как и зачем? EatDog
 
macOS app development for iOS devs: expand your horizons
macOS app development for iOS devs: expand your horizonsmacOS app development for iOS devs: expand your horizons
macOS app development for iOS devs: expand your horizonsEatDog
 
Dependency Injections in Kotlin
Dependency Injections in KotlinDependency Injections in Kotlin
Dependency Injections in KotlinEatDog
 
Быстрый в имплементации и в работе мониторинг с использованием ELK
Быстрый в имплементации и в работе мониторинг с использованием ELKБыстрый в имплементации и в работе мониторинг с использованием ELK
Быстрый в имплементации и в работе мониторинг с использованием ELKEatDog
 
Continuous integration / continuous delivery
Continuous integration / continuous deliveryContinuous integration / continuous delivery
Continuous integration / continuous deliveryEatDog
 
Как мы экспериментируем в больших микросервисных системах
Как мы экспериментируем в больших микросервисных системахКак мы экспериментируем в больших микросервисных системах
Как мы экспериментируем в больших микросервисных системахEatDog
 
Отказоустойчивый Redis кластер
Отказоустойчивый Redis кластерОтказоустойчивый Redis кластер
Отказоустойчивый Redis кластерEatDog
 
Кодстайл и насилие.
Кодстайл и насилие. Кодстайл и насилие.
Кодстайл и насилие. EatDog
 
Refactor to Reactive With Spring 5 and Project Reactor
Refactor to Reactive With Spring 5 and Project ReactorRefactor to Reactive With Spring 5 and Project Reactor
Refactor to Reactive With Spring 5 and Project ReactorEatDog
 
GraphQL: APIs the New Way.
GraphQL: APIs the New Way.GraphQL: APIs the New Way.
GraphQL: APIs the New Way.EatDog
 
Большие проекты, архитектура и фреймворки.
Большие проекты, архитектура и фреймворки.Большие проекты, архитектура и фреймворки.
Большие проекты, архитектура и фреймворки.EatDog
 
Microservices in a Wild.
Microservices in a Wild.Microservices in a Wild.
Microservices in a Wild.EatDog
 
Dependency Rejection and TDD without Mocks
Dependency Rejection and TDD without MocksDependency Rejection and TDD without Mocks
Dependency Rejection and TDD without MocksEatDog
 
Стероиды для Дотнетчика
Стероиды для ДотнетчикаСтероиды для Дотнетчика
Стероиды для ДотнетчикаEatDog
 
Domain Driven Design – просто о сложном.
Domain Driven Design – просто о сложном.Domain Driven Design – просто о сложном.
Domain Driven Design – просто о сложном.EatDog
 
OWASP: безопасное программирование на PHP.
OWASP: безопасное программирование на PHP.OWASP: безопасное программирование на PHP.
OWASP: безопасное программирование на PHP.EatDog
 
Принципы Solid на практике
Принципы Solid на практикеПринципы Solid на практике
Принципы Solid на практикеEatDog
 
Mapbox GL: как работают современные векторные карты
Mapbox GL: как работают современные векторные картыMapbox GL: как работают современные векторные карты
Mapbox GL: как работают современные векторные картыEatDog
 
Нельзя просто так взять и сделать версионирование API
Нельзя просто так взять и сделать версионирование APIНельзя просто так взять и сделать версионирование API
Нельзя просто так взять и сделать версионирование APIEatDog
 
API в SAAS, с облаком и без: ресурсы, SLA, балансировка, расширяемость
API в SAAS, с облаком и без: ресурсы, SLA, балансировка, расширяемостьAPI в SAAS, с облаком и без: ресурсы, SLA, балансировка, расширяемость
API в SAAS, с облаком и без: ресурсы, SLA, балансировка, расширяемостьEatDog
 

More from EatDog (20)

Классифицируем текст в iOS без CoreML: как и зачем?
Классифицируем текст в iOS без CoreML: как и зачем? Классифицируем текст в iOS без CoreML: как и зачем?
Классифицируем текст в iOS без CoreML: как и зачем?
 
macOS app development for iOS devs: expand your horizons
macOS app development for iOS devs: expand your horizonsmacOS app development for iOS devs: expand your horizons
macOS app development for iOS devs: expand your horizons
 
Dependency Injections in Kotlin
Dependency Injections in KotlinDependency Injections in Kotlin
Dependency Injections in Kotlin
 
Быстрый в имплементации и в работе мониторинг с использованием ELK
Быстрый в имплементации и в работе мониторинг с использованием ELKБыстрый в имплементации и в работе мониторинг с использованием ELK
Быстрый в имплементации и в работе мониторинг с использованием ELK
 
Continuous integration / continuous delivery
Continuous integration / continuous deliveryContinuous integration / continuous delivery
Continuous integration / continuous delivery
 
Как мы экспериментируем в больших микросервисных системах
Как мы экспериментируем в больших микросервисных системахКак мы экспериментируем в больших микросервисных системах
Как мы экспериментируем в больших микросервисных системах
 
Отказоустойчивый Redis кластер
Отказоустойчивый Redis кластерОтказоустойчивый Redis кластер
Отказоустойчивый Redis кластер
 
Кодстайл и насилие.
Кодстайл и насилие. Кодстайл и насилие.
Кодстайл и насилие.
 
Refactor to Reactive With Spring 5 and Project Reactor
Refactor to Reactive With Spring 5 and Project ReactorRefactor to Reactive With Spring 5 and Project Reactor
Refactor to Reactive With Spring 5 and Project Reactor
 
GraphQL: APIs the New Way.
GraphQL: APIs the New Way.GraphQL: APIs the New Way.
GraphQL: APIs the New Way.
 
Большие проекты, архитектура и фреймворки.
Большие проекты, архитектура и фреймворки.Большие проекты, архитектура и фреймворки.
Большие проекты, архитектура и фреймворки.
 
Microservices in a Wild.
Microservices in a Wild.Microservices in a Wild.
Microservices in a Wild.
 
Dependency Rejection and TDD without Mocks
Dependency Rejection and TDD without MocksDependency Rejection and TDD without Mocks
Dependency Rejection and TDD without Mocks
 
Стероиды для Дотнетчика
Стероиды для ДотнетчикаСтероиды для Дотнетчика
Стероиды для Дотнетчика
 
Domain Driven Design – просто о сложном.
Domain Driven Design – просто о сложном.Domain Driven Design – просто о сложном.
Domain Driven Design – просто о сложном.
 
OWASP: безопасное программирование на PHP.
OWASP: безопасное программирование на PHP.OWASP: безопасное программирование на PHP.
OWASP: безопасное программирование на PHP.
 
Принципы Solid на практике
Принципы Solid на практикеПринципы Solid на практике
Принципы Solid на практике
 
Mapbox GL: как работают современные векторные карты
Mapbox GL: как работают современные векторные картыMapbox GL: как работают современные векторные карты
Mapbox GL: как работают современные векторные карты
 
Нельзя просто так взять и сделать версионирование API
Нельзя просто так взять и сделать версионирование APIНельзя просто так взять и сделать версионирование API
Нельзя просто так взять и сделать версионирование API
 
API в SAAS, с облаком и без: ресурсы, SLA, балансировка, расширяемость
API в SAAS, с облаком и без: ресурсы, SLA, балансировка, расширяемостьAPI в SAAS, с облаком и без: ресурсы, SLA, балансировка, расширяемость
API в SAAS, с облаком и без: ресурсы, SLA, балансировка, расширяемость
 

Recently uploaded

WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 

Recently uploaded (20)

WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 

Offline first: application data and synchronization

  • 1. Offline-first application data and synchronization 18 February 2016 ⌘ Maksym Barbul
  • 5. So, why is it a problem? ● user is blocked in offline ● connection (blink, detection delay, unstable) ● data is always changing It may bring user to loose data 5
  • 6. What is different? 6 ● Client UX (non-blocking, responsive, reliable) ● Client has smart caching ● Client partially duplicates server’s logic ● Controlled connectivity ● Smart synchronization
  • 7. Offline-first is a Paradigm is a distinct set of concepts or thought patterns, including theories, research methods, postulates, and standards for what constitutes legitimate contributions to a field 7 §
  • 8. Who needs these super-smart apps? ● Field workers ● Store observation ● Technical audit ● Medical observation BUSINESS EFFICIENCY 8
  • 9. Who needs these super-smart apps? ● Instant messengers ● Social networks ● Document editors ● Media organizers ALLUSERS LOYALTY 9
  • 11. Components of an offline-first app 11 Troubleshooting Offline First
  • 12. How is an offline-first app built? 12 Offline data Synchronization Connectivity User Experience Trouble- shooting
  • 15. Data slices: Application 15 Application Static Meta- Data Business Data System Runtime Data Core (scripts) Modules (scripts) Styles & Views (scripts, CSS) Media resources
  • 16. Data slices: Static Meta-Data 16 Application Static Meta- Data Business Data System Runtime Data Configuration & Settings Layout Declaration Permissions Translations
  • 17. Data slices: Business Data 17 Application Static Meta- Data Business Data System Runtime Data Dictionaries Fetched Data (Read only) Entered Data (User Data)
  • 18. Data slices: System Runtime Data 18 Application Static Meta- Data Business Data System Runtime Data Logs (action, error, profiling) Session Data Transaction States (Sync)
  • 22. Synchronization (replication) Strategies 22 ● Pessimistic - no inconsistency ● Optimistic - eventual consistency
  • 23. Eventual Consistency means that replicas eventually reach the same value if clients stop submitting updates 23 §
  • 24. Optimistic replication algorithm 24 1. Operation submission (user submission) 2. Propagation to other replicas 3. Scheduling of operations to apply by each replica 4. Conflict resolution (syntactic, semantic) 5. Commitment on a final schedule and
  • 25. Strong Eventual Consistency (SEC) is a property of some eventually-consistent systems: replicas that have received and applied the same set of updates must immediately have equivalent state 25 §
  • 26. Conflict-free replicated data type (CRDT) 26 is a type of specially-designed data structure used to achieve strong eventual consistency (SEC) and monotonicity (absence of rollbacks) ● operation-based ● state-based
  • 27. Operation-based CRDTs (CmRDT) 27 commutative replicated data types The operations are commutative, so can be received and applied in any order; however, they are not idempotent, and additional network protocol guarantees are required to ensure unique delivery a * b = b * a O(a) ≠ O(O(a))
  • 28. State-based CRDTs (CvRDT) 28 convergent replicated data types CvRDTs send their full local state to other replicas
  • 29. State-based CRDTs (CvRDT): Interface 29 ➔ query - reads the state of the replica, with no side effects ➔ update - writes to the replica state in accordance with certain restrictions (monotonically increase) ➔ merge - merges local state with the state of some remote replica (commutative, associative, and idempotent) a * b = b * a O(a, b) = O(O(a, b), b) a*(b*c) = (a*b)*c
  • 30. CvRDT: increment only 30 is an element of for each i
  • 31. CvRDT: grow-only set (add) 31 add {e} to set A S.A is a subset of T.A unite sets
  • 32. CvRDT: 2P-set (add, remove) 32
  • 33. Operational transformation (OT) 33 is a technology for supporting a range of collaboration functionalities in advanced collaborative software systems. OT was originally invented for consistency maintenance and concurrency control in collaborative editing of plain text documents Apache Wave Google Docs
  • 34. Operational transformation (OT) 34 ➔O1 = Insert[0, "x"] // “xabc” (to insert character "x" at position "0") ➔O2 = Delete[2, "c"] // “xabc” ??? (to delete the character "c" at position "2") “abc” ➔* O2 = Delete[3, "c"] // “xab”
  • 35. Operational transformation (OT) 35 Unfortunately, implementing OT sucks. There's a million algorithms with different tradeoffs, mostly trapped in academic papers. The algorithms are really hard and time consuming to implement correctly. ... Wave took 2 years to write and if we rewrote it today, it would take almost as long to write a second time. Joseph Gentle who is an ex Google Wave engineer and an author of the Share.JS
  • 36. Example: Chat 36 {String} title {Object} participants {Array} messages CvRDT increment-only (LWW) CvRDT set CmRDT or CvRDT
  • 37. Example: Booking 37 {Date} date_from, date_to {String} user_id {String} room_id {String} booking_status CvRDT (LWW) NONE (not editable) CvRDT (LWW) CvRDT
  • 38. Example: Collaborative field editing 38 {String} text Operational transformation
  • 39. Don’t forget about AUDIT 39 ● Why do we have this value? ● Who did this change? ● When? ● What was the previous value?
  • 40. References: read theory ● Offline First manifesto http://offlinefirst.org/ ● Links to articles, events, samples https://github.com/offlinefirst ● Designing Offline-First Web Apps http://alistapart.com/article/offline-first ● SAY HELLO TO OFFLINE FIRST http://hood.ie/blog/say-hello-to-offline-first.html ● Optimistic replication https://www.wikiwand.com/en/Optimistic_replication ● CRDT http://www.wikiwand.com/en/Conflict-free_replicated_data_type ● OT http://www.wikiwand.com/en/Operational_transformation ● appSync.org: open-source patterns & code for data synchronization in mobile apps http://confluence.tapcrowd.com/pages/viewpage.action;jsessionid=3F4D2C44DBFC46644A7955F82 A416DC2?pageId=2262404 ● * Free Book “Distributed Systems” by Mikito Takada http://book.mixu.net/distsys/index.html ● Roshi CRDT explanation https://developers.soundcloud.com/blog/roshi-a-crdt-system-for- timestamped-events ● A comprehensive study of CRDTs by Marc Shapiro https://hal.inria.fr/file/index/docid/555588/filename/techreport.pdf 40
  • 41. References: source code ● appSync source https://bitbucket.org/nikonelissen/appsync/src ● CRDT Roshi by SoundCloud with great expanation https://github.com/soundcloud/roshi ● CRDT Riak by Basho (League of Legends) https://github.com/basho/ ● ShareJS https://github.com/share/ShareJS ● Hoodie https://github.com/hoodiehq/hoodie 41
  • 42. References: borrowed resources ● Sync types diagram http://confluence.tapcrowd.com/pages/viewpage.action?pageId=2262404 ● Free icons found here http://findicons.com/ 42
  • 43. Summary: how to build offline-first apps 43 ● Know the Paradigm ● Plan data structure and synchronization approaches before development ● Be paranoid about user’s data ● Develop offline-first applications
  • 44. The End? 44 Thank you. eager to use your great Offline apps 😉

Editor's Notes

  1. TODO: Chat example should explain choosing of sync structure for different fields (title, messages, participants) Tell them how important to understand approaches to not work around hacks and bugs (my experience during SCollab development)
  2. Current approach of mobile app (web, hybrid, native) development takes into account that a client has connection to server or sometimes can have connection breaks and a user can wait until the connection is restored. We live in a disconnected & battery powered world, but our technology and best practices are a leftover from the always connected & steadily powered past.
  3. But this paradigm is not complete because: connection might blink device might not detect connection status change immediately connection might be unstable (request handled but not communicated to the client back) So, to bring super-stable experience the client should be super-smart and the server should understand it.
  4. Field workers TV, internet, cell providers, doctor visits, energy providers, plumbers, etc. Store observation Technical audit Car, house, utilities assets audit Medical observation
  5. TODO: Insert a picture of mobile device and cell/radio tower
  6. TODO: insert a diagram “start” of offline-first app branches - User Interface - User Experience - Offline Data - Connectivity - Synchronization - Troubleshooting
  7. TODO: insert a diagram “start” of offline-first app branches - User Interface - User Experience - Offline Data - Connectivity - Synchronization - Troubleshooting
  8. TODO: Insert a picture of mobile device and cell/radio tower
  9. ## Application itself - scripts, - styles - media resources ## Static meta-data - configs and settings - e.g. how to connect to services, client-server time difference, - layout declaration - permissions - translations ## Business data - dictionaries - fetched data - entered data (aka User data) ## System runtime data - logs (action, error, profiling) - session data (app state, offline authentication) - transaction states (data sync, app updates)
  10. ## Application itself - scripts, - styles - media resources
  11. ## Static meta-data - configs and settings - e.g. how to connect to services, client-server time difference, - layout declaration - permissions - translations
  12. ## Business data - dictionaries - fetched data - entered data (aka User data)
  13. ## System runtime data - logs (action, error, profiling) - session data (app state, offline authentication) - transaction states (data sync, app updates)
  14. Data synchronization is the process of establishing consistency among data from a source to a target data storage and vice versa and the continuous harmonization of the data over time. It is fundamental to a wide variety of applications, including file synchronization and mobile device synchronization
  15. One-way sync: data is only synced from the server to the apps (e.g. news app where content is synced from the backend CMS to the apps) or data is synced from the apps to a server (e.g. logging/analytics). Two-way sync: data is synced in two directions, from an app to a backend and back. E.g. a user is logged in and can manage his own data on a website and in an app (assuming user cannot be logged in on 2 devices at the same time). Multi-way sync: data is synced from multiple devices to a server/backend and back. This also means that data from one device is synced to the server and from the server to other devices (e.g. collaboration apps...).
  16. One-way sync: data is only synced from the server to the apps (e.g. news app where content is synced from the backend CMS to the apps) or data is synced from the apps to a server (e.g. logging/analytics). Two-way sync: data is synced in two directions, from an app to a backend and back. E.g. a user is logged in and can manage his own data on a website and in an app (assuming user cannot be logged in on 2 devices at the same time). Multi-way sync: data is synced from multiple devices to a server/backend and back. This also means that data from one device is synced to the server and from the server to other devices (e.g. collaboration apps...).
  17. Traditional pessimistic replication systems try to guarantee from the beginning that all of the replicas are identical to each other, as if there was only a single copy of the data all along. Optimistic replication does away with this in favor of eventual consistency, meaning that replicas are guaranteed to converge only when the system has been quiesced for a period of time. As a result there is no longer a need to wait for all of the copies to be synchronized when updating data, which helps concurrency and parallelism. The trade-off is that different replicas may require explicit reconciliation later on, which might then prove difficult or even insoluble.
  18. Informally, eventual consistency means that replicas eventually reach the same value if clients stop submitting updates. Eventually consistent systems accept local updates without remote synchronization, improving performance and scalability by sacrificing strong consistency. Without remote synchronization, replicas concurrently hold different values which are expected to converge over time. Convergence is complicated by conflicts which arise when merging values between replicas. A conflict is a combination of concurrent updates which may be individually correct, but taken together violate some system invariant. A conflict is a combination of concurrent updates which may be individually correct, but taken together violate some system invariant. Conventional conflict-resolution schemes involve state roll-back, full consensus, or even user interaction.
  19. An optimistic replication algorithm consists of five elements: Operation submission: Users submit operations at independent sites. Propagation: Each site shares the operations it knows about with the rest of the system. Scheduling: Each site decides on an order for the operations it knows about. Conflict resolution: If there are any conflicts among the operations a site has scheduled, it must modify them in some way. Commitment: The sites agree on a final schedule and conflict resolution result, and the operations are made permanent. There are two strategies for propagation: state transfer, where sites propagate a representation of the current state, and operation transfer, where sites propagate the operations that were performed (essentially, a list of instructions on how to reach the new state). Scheduling and conflict resolution can either be syntactic or semantic. Syntactic systems rely on general information, such as when or where an operation was submitted. Semantic systems are able to make use of application-specific information to make smarter decisions. Note that state transfer systems generally have no information about the semantics of the data being transferred, and so they have to use syntactic scheduling and conflict resolution.
  20. Strong eventual consistency is a property of some eventually-consistent systems: replicas that have received and applied the same set of updates must immediately have equivalent state. There is no conflict arbitration process, because conflicts do not exist in strongly-consistent systems. CRDTs are used to achieve strong eventual consistency in a distributed system.
  21. State-based CRDTs are called convergent replicated data types, or CvRDTs. In contrast to CmRDTs, CvRDTs send their full local state to other replicas. CvRDTs have the following local interface:
  22. query - reads the state of the replica, with no side effects update - writes to the replica state in accordance with certain restrictions merge - merges local state with the state of some remote replica The merge function must be commutative, associative, and idempotent. It provides a join for any pair of replica states, so the set of all states forms a semilattice. The updatefunction must monotonically increase the internal state, according to the same partial order rules as the semilattice.
  23. A common strategy in CRDT development is to stick multiple primitive CRDTs together to make a more complex CRDT. In this case, two increment-only counters were combined to create a CvRDT supporting both increment and decrement operations. Note that the CvRDT's internal state must increase monotonically, even though its external state as exposed throughquery can return to previous values.
  24. The grow-only set is a CvRDT implementing a set which only allows adds. Since it is impossible for adds and removes to commute (one must take precedence over the other), any CvRDT supporting both add and remove operations must pick and choose its semantics.
  25. Two grow-only set CvRDTs are combined to create the 2P-set CvRDT. With the addition of a "tombstone" set, elements can be added and also removed. Once removed, an element cannot be re-added; that is, once an element e is in the tombstone set, query will never again return True for that element. The 2P-set uses "remove-wins" semantics, so remove(e) takes precedence over add(e).