28
LiveQueries via LiveServer Ondrej Lehecka YOW Australia, 2017

LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

LiveQueries via LiveServerOndrej LeheckaYOW Australia, 2017

Page 2: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

Agenda

1. What are LiveQueries?

2. What is LiveServer?

3. Architecture of LiveServer

4. Use cases

5. Implementation challenges

Page 3: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

What is GraphQL query?

Text here

Text here

Text here

Page 4: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

What is LiveQuery?

Text here

Text here

Text here

Page 5: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

Subscriptions (mutation)

Text here

Text here

Text here

Page 6: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

Subscriptions

Text here

Text here

Text here

Page 7: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

LiveQuery

Text here

Text here

Text here

Page 8: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

What is a Live Query?

• Extended GraphQL API

• get-and-subscribe semantic

• Updated on state changes

Page 9: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

How to implement LiveQueries?

Page 10: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

Client-Side Polling

Text here

Text here

Text here

Client can translate an @live annotation to mean “poll with some frequency”

Client: Are we there yet? Are we there yet? Are we there yet?

Pros/Cons:• Simple• Inefficient

If you're using Relay, there exists built-in support:https://github.com/facebook/relay/commit/88d09dcc30f851d8d9abd696d686eb9683b56ba6

Page 11: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

Server-Side Polling

Text here

Text here

Text here

Server can poll with some frequency, push updates to clients.

Server: Are we there yet? Are we there yet? Are we there yet?

Pros/Cons:• Don’t waste client resources• Server smarts (batching queries, etc.)• Inefficient• Requires long living connection to Client

Page 12: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

Reactive back end

Text here

Text here

Text here

Pros/Cons:• Dependency tracking• Server smarts (batching queries, etc.)• Saves compute

Page 13: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

Reactive backend (with micro services)

Text here

Text here

Text here

Page 14: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

What is LiveServer?

1. Reactive backend with automatic dependency capture for queries

2. Delivers updates to client

3. Stateful

4. With consistent routing

5. Interacts with reactive data sources

Page 15: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

LiveServer – architecture

Text here

Text here

Gateway

Mobileclient

*client

Webclient

Reactive Data Source

Query Execution Engine(PHP)

Reactive Data SourceReactive Data

SourceRouting

Page 16: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

LiveServer – execution of a LiveQuery

Text here

Text here

Gateway

Mobileclient

*client

Webclient

Reactive Data Source

Query Execution Engine(PHP)

Reactive Data SourceReactive Data

SourceRouting

Session

Dependency tracking

Q1: Dep1

Page 17: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

LiveServer – statefulness

Text here

Text here

Text here

Text here

Gateway

mobile

mobile

mobile

Reactive Data SourceReactive Data

SourceReactive Data Source

Routing

Session Manager

Dependency tracker

Query state Resume info

Query Execution Engine(PHP)

Page 18: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

LiveServer – consistent routing

Text here

Text here

Text here

Text here

Text here

Text here

Gateway host 1

mobile

mobile

mobile

Routing

social hash

host mapping

store

Gateway hostGateway hostGateway host

Page 19: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

LiveServer – reactive data sources

Text here

Text here

Text here

Text here

Text here

Text here

Gateway

Reactive Data Source

Query Execution Engine(PHP)

Reactive Data SourceReactive Data

Source

Data Source

Reactive Extensions

Update Log: <u1>, <u2>, …

Page 20: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

RSocket: protocol, connectivity, resumability

Text here

Text here

Text here

Text here

Gateway

mobile

mobile

mobile

Reactive Data Source

Query Execution Engine(PHP)

Reactive Data SourceReactive Data

SourceRouting

Page 21: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

RSocket: protocol layering

Text here

Text here

Text here

Text here

RSocket

HTTPTCP Quic

Page 22: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

RSocket over extended HTTP/2

Text here

Text here

Text here

Text here

HTTP/2 (+pub/sub, resumability, credit-based flow control)

Page 23: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

Use cases

• Interactive user interface• Updating client caches• Push updates to clients in background

Page 24: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

Use case: Delayed execution

Text here

Text here

Page 25: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

Implementation challenges

• Over-observing

• Masked dependencies thru caching layers

• Consistency and race conditions

• Partial reactivity

Page 26: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

What are your

key takeaways from this workshop?

• Stateful service for efficient implementation of LiveQueries

• Connection oriented network protocols

• Reactive data sources

Page 27: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

GraphQL Future (React-Europe 2016): https://youtu.be/ViXL0YQnioU?t=17m54s

Realtime React Apps with GraphQL (React Conf2017): https://www.youtube.com/watch?v=AYbVMNtO-ro

Best Practices for GraphQL Subscriptions (Nordic.js2017): https://www.youtube.com/watch?v=XfHOrfTyJJw

RSocket – the future of micro-services communication (Code Europe 2017): https://youtu.be/oyeALF_1ZPQ

ADDITIONAL RESOURCES

Page 28: LiveQueries via LiveServer - YOW Australia 2017 · What is a Live Query? • Extended GraphQLAPI • get-and-subscribe semantic • Updated on state changes

What are your

key takeawaysfrom this workshop?

Q&A