1
Create API for your databases Rest, gRPC, GraphQL
@clunven | @vxdmicroservice | #microservices
Design API for
your databases
2
Create API for your databases Rest, gRPC, GraphQL
@clunven | @vxdmicroservice | #microservices
https://github.com/clun
https://fr.linkedin.com/in/clunven
@clunven
Cédrick Lunven
Developer Advocate @
About me
3
Create API for your databases Rest, gRPC, GraphQL
@clunven | @vxdmicroservice | #microservices
Objectives
1. Provide you a working API implementing Rest, gRPC
and GraphQL
2. Give implementations details through Demo
3. Reveal hints to choose and WHY, (specially to work
with Databases)
4
Create API for your databases Rest, gRPC, GraphQL
@clunven | @vxdmicroservice | #microservices
KillrVideo
http://dev.killrvideo.com
https://killrvideo.github.io/
5
Create API for your databases Rest, gRPC, GraphQL
@clunven | @vxdmicroservice | #microservices
Data model design
Entities & Relationships
Queries
6
Create API for your databases Rest, gRPC, GraphQL
@clunven | @vxdmicroservice | #microservices
Conceptual Data Model
7
Create API for your databases Rest, gRPC, GraphQL
@clunven | @vxdmicroservice | #microservices
Application workflow
Q2: Find comments posted for a user with a known id
(show most recent first)
comments_by_video
comments_by_user
Q1: Find comments for a video with a known id
(show most recent first)
Q3: CRUD Operations
8
Create API for your databases Rest, gRPC, GraphQL
@clunven | @vxdmicroservice | #microservices
Logical Data Model
userid
creationdate
commentid
videoid
comment
comments_by_user
K
C
↑
videoid
creationdate
commentid
userid
comment
comments_by_video
C
↑
K
C
↑
↑C
9
Create API for your databases Rest, gRPC, GraphQL
@clunven | @vxdmicroservice | #microservices
Physical Data Model
userid
commentid
videoid
comment
comments_by_user
TIMEUUID
K
TEXT
C
UUID
UUID
↑
videoid
commentid
userid
comment
comments_by_video
TIMEUUID
K
TEXT
C
UUID
UUID
↑
10
Create API for your databases Rest, gRPC, GraphQL
@clunven | @vxdmicroservice | #microservices
DDL Schema
CREATE TABLE IF NOT EXISTS comments_by_user (
userid uuid,
commentid timeuuid,
videoid uuid,
comment text,
PRIMARY KEY ((userid), commentid)
) WITH CLUSTERING ORDER BY (commentid DESC);
CREATE TABLE IF NOT EXISTS comments_by_video (
videoid uuid,
commentid timeuuid,
userid uuid,
comment text,
PRIMARY KEY ((videoid), commentid)
) WITH CLUSTERING ORDER BY (commentid DESC);
11
Create API for your databases Rest, gRPC, GraphQL
@clunven | @vxdmicroservice | #microservices
Databases access patterns
Entities/Relationships
Mutations
Queries /
Functions
Paging
Sorting
Filtering
Caching
Sync vs Async
Atomicity
Reactive
Consistency
Level
Versioning, Performance, Latencies
Conceptual
Data Model
Application
Workflow
12
Create API for your databases Rest, gRPC, GraphQL
@clunven | @vxdmicroservice | #microservices
Tools in Action
killrvideo-dse
Drivers
DAO
killrvideo-api-rest killrvideo-api-grpc killrvideo-api-graphql
13
Create API for your databases Rest, gRPC, GraphQL
@clunven | @vxdmicroservice | #microservices
DEMO
14
Create API for your databases Rest, gRPC, GraphQL
@clunven | @vxdmicroservice | #microservices
+ Resources Oriented
+ Decoupled client and server
+ API can evolve over time (versioning)
+ Reuse HTTP
 Mutations
 Create Read Update Delete
 Servlerless endpoints
- Big Payload
- Functions exposition
- No ad hoc discoverability
15
Create API for your databases Rest, gRPC, GraphQL
@clunven | @vxdmicroservice | #microservices
+ Very large network of services
+ High Performance
+ Streaming
 High Performance
 Action/Function oriented API
 Streaming & Async
- Strongly Coupled
- No discoverability
- Function exposition
16
Create API for your databases Rest, gRPC, GraphQL
@clunven | @vxdmicroservice | #microservices
+ Low network overhead
+ Typed schema
+ Relations
 Latencies matter (mobile)
 Service aggregation
 Nice for clients – caution for Server side
- Complexity
- Caching
- Versioning
- Still early
GraphQL
17
Create API for your databases Rest, gRPC, GraphQL
@clunven | @vxdmicroservice | #microservices
Databases access patterns
Entities/Relationships
Mutations
Queries /
Functions
Conceptual
Data Model
Application
Workflow
18
Create API for your databases Rest, gRPC, GraphQL
@clunven | @vxdmicroservice | #microservices
 https://github.com/clun/voxxeddays-api
19
Create API for your databases Rest, gRPC, GraphQL
@clunven | @vxdmicroservice | #microservices

Create API for your Databases

  • 1.
    1 Create API foryour databases Rest, gRPC, GraphQL @clunven | @vxdmicroservice | #microservices Design API for your databases
  • 2.
    2 Create API foryour databases Rest, gRPC, GraphQL @clunven | @vxdmicroservice | #microservices https://github.com/clun https://fr.linkedin.com/in/clunven @clunven Cédrick Lunven Developer Advocate @ About me
  • 3.
    3 Create API foryour databases Rest, gRPC, GraphQL @clunven | @vxdmicroservice | #microservices Objectives 1. Provide you a working API implementing Rest, gRPC and GraphQL 2. Give implementations details through Demo 3. Reveal hints to choose and WHY, (specially to work with Databases)
  • 4.
    4 Create API foryour databases Rest, gRPC, GraphQL @clunven | @vxdmicroservice | #microservices KillrVideo http://dev.killrvideo.com https://killrvideo.github.io/
  • 5.
    5 Create API foryour databases Rest, gRPC, GraphQL @clunven | @vxdmicroservice | #microservices Data model design Entities & Relationships Queries
  • 6.
    6 Create API foryour databases Rest, gRPC, GraphQL @clunven | @vxdmicroservice | #microservices Conceptual Data Model
  • 7.
    7 Create API foryour databases Rest, gRPC, GraphQL @clunven | @vxdmicroservice | #microservices Application workflow Q2: Find comments posted for a user with a known id (show most recent first) comments_by_video comments_by_user Q1: Find comments for a video with a known id (show most recent first) Q3: CRUD Operations
  • 8.
    8 Create API foryour databases Rest, gRPC, GraphQL @clunven | @vxdmicroservice | #microservices Logical Data Model userid creationdate commentid videoid comment comments_by_user K C ↑ videoid creationdate commentid userid comment comments_by_video C ↑ K C ↑ ↑C
  • 9.
    9 Create API foryour databases Rest, gRPC, GraphQL @clunven | @vxdmicroservice | #microservices Physical Data Model userid commentid videoid comment comments_by_user TIMEUUID K TEXT C UUID UUID ↑ videoid commentid userid comment comments_by_video TIMEUUID K TEXT C UUID UUID ↑
  • 10.
    10 Create API foryour databases Rest, gRPC, GraphQL @clunven | @vxdmicroservice | #microservices DDL Schema CREATE TABLE IF NOT EXISTS comments_by_user ( userid uuid, commentid timeuuid, videoid uuid, comment text, PRIMARY KEY ((userid), commentid) ) WITH CLUSTERING ORDER BY (commentid DESC); CREATE TABLE IF NOT EXISTS comments_by_video ( videoid uuid, commentid timeuuid, userid uuid, comment text, PRIMARY KEY ((videoid), commentid) ) WITH CLUSTERING ORDER BY (commentid DESC);
  • 11.
    11 Create API foryour databases Rest, gRPC, GraphQL @clunven | @vxdmicroservice | #microservices Databases access patterns Entities/Relationships Mutations Queries / Functions Paging Sorting Filtering Caching Sync vs Async Atomicity Reactive Consistency Level Versioning, Performance, Latencies Conceptual Data Model Application Workflow
  • 12.
    12 Create API foryour databases Rest, gRPC, GraphQL @clunven | @vxdmicroservice | #microservices Tools in Action killrvideo-dse Drivers DAO killrvideo-api-rest killrvideo-api-grpc killrvideo-api-graphql
  • 13.
    13 Create API foryour databases Rest, gRPC, GraphQL @clunven | @vxdmicroservice | #microservices DEMO
  • 14.
    14 Create API foryour databases Rest, gRPC, GraphQL @clunven | @vxdmicroservice | #microservices + Resources Oriented + Decoupled client and server + API can evolve over time (versioning) + Reuse HTTP  Mutations  Create Read Update Delete  Servlerless endpoints - Big Payload - Functions exposition - No ad hoc discoverability
  • 15.
    15 Create API foryour databases Rest, gRPC, GraphQL @clunven | @vxdmicroservice | #microservices + Very large network of services + High Performance + Streaming  High Performance  Action/Function oriented API  Streaming & Async - Strongly Coupled - No discoverability - Function exposition
  • 16.
    16 Create API foryour databases Rest, gRPC, GraphQL @clunven | @vxdmicroservice | #microservices + Low network overhead + Typed schema + Relations  Latencies matter (mobile)  Service aggregation  Nice for clients – caution for Server side - Complexity - Caching - Versioning - Still early GraphQL
  • 17.
    17 Create API foryour databases Rest, gRPC, GraphQL @clunven | @vxdmicroservice | #microservices Databases access patterns Entities/Relationships Mutations Queries / Functions Conceptual Data Model Application Workflow
  • 18.
    18 Create API foryour databases Rest, gRPC, GraphQL @clunven | @vxdmicroservice | #microservices  https://github.com/clun/voxxeddays-api
  • 19.
    19 Create API foryour databases Rest, gRPC, GraphQL @clunven | @vxdmicroservice | #microservices

Editor's Notes

  • #3 Traitement, fonction, story, comportement  Qui traverse toutes les couches applicatives