SlideShare a Scribd company logo
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Cedrick Lunven | Director of Developer Advocacy #DataStax @clunven
Build APIS with
SpringBoot
REST, GRPC, GRAPHQL
Which one should you
pick?
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
About me: Cedrick Lunven
Director of Developer Advocacy
Creator and Maintainer of FF4j
Java and Spring Dinosaur
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Agenda
50min
2
3 DEMO and Code Browse
Data Model & Persistence with Apache Cassandra
1 Anatomy of a Spring Boot Micro service
4 Decision tree
5 Take my code and slides + Q&A
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
NEW PROFESSIONAL
JAVA EVENT
MAY 30th, 2020
KYIV, UKRAINE
Cedrick Lunven | Director of Developer Advocacy #DataStax @clunven
Anatomy of a Spring Boot Microservice
1
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Monolithic
Business Logic
User Interface
Data Interface
Multichannel
UI Mobile UI Web
ESB
SOA
Specialization
BUS
S1 S2 S3 Sn
RDBMS
noSQL
DataLake
Micro
Frontend
All Things Distributed
Web Components SPA Native
BFF (Backend for Frontend)
Micro
Services
Data Mesh
Api Gateway Service Discovery
RDBMS Graph Hadoop
Document KV newSQLColumn
TSDB
Distributed Tracing
Containerization
Layers
Business Logic
(Services)
User Interface
Data Interface
(Dao)
Backend
Front-end
OLTP OLAP
RDBMS
Microservices Architectures
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Building a Spring Boot Microservice
Exposition Layer
Service Layer
Persistence Layer
Database
Data Model
Configuration
Monitoring
Security
Access Patterns
Volume
Throughput
Latency
Security
(Service, Component)
(Controllers)
(Dao, Repository)
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
« Vanilla » So easy….
Exposition Layer
Service Layer
Persistence Layer
Database
Microservice
(Service, Component)
(Controllers)
(Dao, Repository)
1
Normalized
Data Model
2 CRUD
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
« Vanilla » So easy….
Exposition Layer
Service Layer
Persistence Layer
Database
Microservice
(Service, Component)
(Controllers)
(Dao, Repository)
DATA
DATA-REST
WEB MVC
Configuration
Monitoring
Security
Database Driver
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Entity => Spring-Data => Spring-Data-REST
@Entity
public class Customer {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
private String firstName;
private String lastName;
private Customer() {}
private Customer(
String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
@RepositoryRestResource(
collectionResourceRel = "customers",
path = "customers")
public interface CustomerRepository extends
CrudRepository<Customer, Long> {
List<Customer> findByLastName(String lastName);
Customer findById(long id);
}
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
When volumes grow ?
Exposition Layer
Service Layer
Persistence Layer
Database
Microservice
(Service, Component)
(Controllers)
(Dao, Repository)
CREATE INDEX
JOIN
SHARDING
…
3 CUSTOM QUERIES
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
CAP Theorem for Distributed Systems
Consistency Availability
Partition
Tolerance
?
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
NEW PROFESSIONAL
JAVA EVENT
MAY 30th, 2020
KYIV, UKRAINE
Cedrick Lunven | Director of Developer Advocacy #DataStax @clunven
Persistence Layer and
Data Model with Apache Cassandra™
2
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
NODE
NODE
NODE
NODE
NODE NODE
NODE
Apache Cassandra™
1 Installation = 1 NODE
ü Capacity: ± 1TB
ü Throughput: 3000 Tx/sec/core
Communication:
ü Gossiping
DataCenter | Ring
= Distributed NoSQL Database
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Scales Linearly
• Need more capacity?
• Need more throughput?
• Add nodes!
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Data is Distributed
Country City Habitant
USA New York 8.000.000
USA Los Angeles 4.000.000
FR Paris 2.230.000
DE Berlin 3.350.000
UK London 9.200.000
AU Sydney 4.900.000
FR Toulouse 1.100.000
JP Tokyo 37.430.000
IN Mumbai 20.200.000
DE Nuremberg 500.000
CA Montreal 4.200.000
CA Toronto 6.200.000
Partition Key
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Data is replicated
59 (data)
RF = 3
0
50
33
1783
67
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Data is replicated
RF = 3
0
50
33
1783
67
59 (data)59 (data)
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Data is replicated
RF = 3
0
50
33
1783
67
59 (data)
59 (data)
59 (data)
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Self Healing
RF = 3
0
50
33
1783
67
59 (data)59 (data)
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Self Healing
RF = 3
0
50
33
1783
67
59 (data)
59 (data)
59 (data)
Hint
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Self Healing
RF = 3
0
50
33
1783
67
59 (data)
59 (data)
59 (data)
Hint
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Self Healing
RF = 3
0
50
33
1783
67
59 (data)
59 (data)
59 (data)
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Use Cases
High Throughput
High Volume
Mission Critical
Availability
Realtime
Distributed
Heavy Writes
Heavy Reads
Event Streaming
Internet of Things
Log Analytics
Any TimeSeries
Caching
Market Data
Prices
No Data Loss
Reponsive
System
Any CRUD
API Layer
Geograhically
DeploymentsD
R
A
S
Banking
Track and Trace
Customer Apps Enterprise Data
Layer
Applications
Global Company
Retailers
Hybrid Cloud
MultiCloud
?
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Apache Cassandra MicroServices
• REALTIME REQUESTS & SCALABILITY AT CORE
• DISTRIBUTED ARCHITECTURES
– From ACID to BASE (Basic Availability, Soft-State, Eventual Consistency)
– Implementations: CQRS, Event Sourcing
– Colocate service and Data
• DECOUPLING BY DESIGN
– 1 KEYSPACE = DOMAIN
– 1 QUERY = 1 TABLE
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Reference Application
http://killrvideo.github.io
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Data Model Design
Entities & Relationships
Queries
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Conceptual Data Model
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Application Workflow
R1: Find comments related to target video using its identifier
• Get most recent first
• Implement Paging
R2: Find comments related to target user using its identifier
• Get most recent first
• Implement Paging
R3: Implement CRUD operations
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Mapping
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
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
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
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
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
↑
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Schema DDL
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);
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
We have everything we need
Conceptual Data
Model
(Entities, Relations)
Application Workflow
(Queries)
Database Family
(Technos +Table)
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Api Design Methodology
1
killrvideo-dse
Drivers
DAO3
killrvideo-api-rest killrvideo-api-grpc killrvideo-api-graphql
2
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
NEW PROFESSIONAL
JAVA EVENT
MAY 30th, 2020
KYIV, UKRAINE
Cedrick Lunven | Director of Developer Advocacy #DataStax @clunven
DEMO
3
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
https://github.com/clun
/javafest-2020
docker-compose up –d
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Configuration – 1# Convention
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Configuration – #2 Java Config
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Configuration - #3 Custom Definition
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
CLIENT API DRIVER
Parameters
SynchronousQueries
PreparedStatement
& Parameters
Bind
Parameters
BoundStatement
ResultSet
ResultSet
Results
Blocked
API
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
CLIENT API DRIVER
v
Parameters
AsyncQueries
PreparedStatement
& Parameters Bind
Parameters
BoundStatement
AsyncResultSet
AsyncResultSet
Result
API
CompletionStage
Callback Hell
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
CLIENT API DRIVER
v
Parameters
ReactiveQueries
PreparedStatement
& Parameters Bind
Parameters
Row
ReactiveRow
Flux
API
ReactiveResultSet
Subscribe
BoundStatement
Subscriber.onNext
Query execution
onComplete()
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
NEW PROFESSIONAL
JAVA EVENT
MAY 30th, 2020
KYIV, UKRAINE
Cedrick Lunven | Director of Developer Advocacy #DataStax @clunven
DECISION TREE
4
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Analysis Criteria
Conceptual
Data Model
Application
Workflow
(Queries)
Database Family
(Technos +Table)
Caching
Sync vs Async Reactive
SLA (Volume)
Data Integrity
Filters
Paging
Sort
Latencies Throughput
Versionning
Confidentiality
Atomicity
Cardinality
Developers
Users/Consumers
Language
CodeFirst/
Vs SchemaFirst
Documentation
Test
Build
Packaging
Api Catalog
Internal vs
Public Techno
Profile
XP
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Analysis Matrix
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Decision Tree
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
v Decoupling Client / Server (Schema on read)
v Api Lifecycle (Versioning)
v Tooling (API Management, Serverless)
v Verbose payloads (json, xml)
v No discoverability
v Not suitable for command-like (functions) API
v CRUD superstar
v Relevant for mutations (OLTP)
v Public and web APIs
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
v High Performances (http/2 – binary serialisation)
v Multiple stubs : Sync, Async, Streaming
v Multi languages - Interoperability
v Strongly coupled (schema with proto files)
v No discoverability
v Protobuf serialization format
v Distributed network of services (no waits)
v High throughput & streaming use cases
v Command-like (eg: slack)
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
v Discoverability, documentation
v Custom payloads
v Match standards (Json | Http)
v Single endpoint (versioning, monitoring, security)
v Complex implementation (tooling, still young)
v Nice for customers nasty for DB (N+1 select)
v Backend for frontend (JS)
v Service aggregation | composition (joins)
v When volume matters (mobile phones)
GraphQL
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
NEW PROFESSIONAL
JAVA EVENT
MAY 30th, 2020
KYIV, UKRAINE
Cedrick Lunven | Director of Developer Advocacy #DataStax @clunven
RESOURCES
5
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Github repo
https://github.com/clun/javafest-2020
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
DataStax Developers on Youtube
• https://www.youtube
.com/channel/UCAIQ
Y251avaMv7bBv5PCo
-A
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
Sample CODES
Micro-service REST
https://bit.ly/31RL62I
Micro-service GraphQL
https://bit.ly/2MVicup
Micro-service GRPC Micro-service Kafka
Reactive with Webflux Micro-service Serverless
https://bit.ly/2pofk0b
https://bit.ly/34ePzhL
https://bit.ly/2JwsFdM
https://bit.ly/31VQz8G
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
community.datastax.com
switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020
NEW PROFESSIONAL
JAVA EVENT
MAY 30th, 2020
KYIV, UKRAINE
THANK YOU ! (@clunven)

More Related Content

Similar to JavaFest. Cedrick Lunven. Build APIS with SpringBoot - REST, GRPC, GRAPHQL which one should you pick? (20)

PPTX
Java Play Restful JPA
Faren faren
 
PDF
SpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
VMware Tanzu
 
PPTX
Designing API: REST | gRPC | GraphQL, which one should you pick? - Cedrick Lu...
Shift Conference
 
KEY
using Spring and MongoDB on Cloud Foundry
Joshua Long
 
PDF
An Introduction to Spring Data
Oliver Gierke
 
KEY
Taming NoSQL with Spring Data
Sergi Almar i Graupera
 
PPTX
Spring Test Framework
GlobalLogic Ukraine
 
PDF
Economies of Scaling Software
Joshua Long
 
PDF
SQL, NoSQL, NewSQL? What's a developer to do?
Chris Richardson
 
KEY
A Walking Tour of (almost) all of Springdom
Joshua Long
 
PDF
Introduction to Spring Boot.pdf
ShaiAlmog1
 
PPTX
Cutting through the fog of microservices: lightsabers optional
Graham Charters
 
PDF
A Microservices approach with Cassandra and Quarkus | DevNation Tech Talk
Red Hat Developers
 
KEY
Spring in the Cloud - using Spring with Cloud Foundry
Joshua Long
 
PDF
apidays LIVE Paris 2021 - Stargate.io, An OSS Api Layer for your Cassandra by...
apidays
 
PDF
Rediscovering Spring with Spring Boot(1)
Gunith Devasurendra
 
PDF
Extending spring
Joshua Long
 
PDF
From Spring Boot 2.2 to Spring Boot 2.3 #jsug
Toshiaki Maki
 
PDF
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
Appster1
 
PDF
dokumen.tips_rediscovering-spring-with-spring-boot1.pdf
Appster1
 
Java Play Restful JPA
Faren faren
 
SpringOne Tour: Spring Recipes: A Collection of Common-Sense Solutions
VMware Tanzu
 
Designing API: REST | gRPC | GraphQL, which one should you pick? - Cedrick Lu...
Shift Conference
 
using Spring and MongoDB on Cloud Foundry
Joshua Long
 
An Introduction to Spring Data
Oliver Gierke
 
Taming NoSQL with Spring Data
Sergi Almar i Graupera
 
Spring Test Framework
GlobalLogic Ukraine
 
Economies of Scaling Software
Joshua Long
 
SQL, NoSQL, NewSQL? What's a developer to do?
Chris Richardson
 
A Walking Tour of (almost) all of Springdom
Joshua Long
 
Introduction to Spring Boot.pdf
ShaiAlmog1
 
Cutting through the fog of microservices: lightsabers optional
Graham Charters
 
A Microservices approach with Cassandra and Quarkus | DevNation Tech Talk
Red Hat Developers
 
Spring in the Cloud - using Spring with Cloud Foundry
Joshua Long
 
apidays LIVE Paris 2021 - Stargate.io, An OSS Api Layer for your Cassandra by...
apidays
 
Rediscovering Spring with Spring Boot(1)
Gunith Devasurendra
 
Extending spring
Joshua Long
 
From Spring Boot 2.2 to Spring Boot 2.3 #jsug
Toshiaki Maki
 
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
Appster1
 
dokumen.tips_rediscovering-spring-with-spring-boot1.pdf
Appster1
 

More from FestGroup (10)

PPTX
JavaFest. Барух Садогурский. DevOps для разработчиков (или против них?!)
FestGroup
 
PDF
JavaFest. Виктор Полищук. Legacy: как победить в гонке
FestGroup
 
PDF
JavaFest. Philipp Krenn. Scale Elasticsearch for Your Java Applications
FestGroup
 
PDF
JavaFest. Grzegorz Piwowarek. Hazelcast - Hitchhiker’s Guide
FestGroup
 
PDF
JavaFest. Денис Макогон. 6 заблуждений относительно современной Java
FestGroup
 
PDF
JavaFest. Taras Boychuk. There is always a choice. Spring Data JDBC vs. Hiber...
FestGroup
 
PDF
JavaFest. Вадим Казулькин. Projects Valhalla, Loom and GraalVM
FestGroup
 
PDF
JavaFest. Антон Лемешко. Model-Driven Development in the Open Java Universe
FestGroup
 
PDF
JavaFest. Дмитрий Сергеев. Data processing with Kafka Streams and Spring Fram...
FestGroup
 
PDF
JavaFest. Nanne Baars. Web application security for developers
FestGroup
 
JavaFest. Барух Садогурский. DevOps для разработчиков (или против них?!)
FestGroup
 
JavaFest. Виктор Полищук. Legacy: как победить в гонке
FestGroup
 
JavaFest. Philipp Krenn. Scale Elasticsearch for Your Java Applications
FestGroup
 
JavaFest. Grzegorz Piwowarek. Hazelcast - Hitchhiker’s Guide
FestGroup
 
JavaFest. Денис Макогон. 6 заблуждений относительно современной Java
FestGroup
 
JavaFest. Taras Boychuk. There is always a choice. Spring Data JDBC vs. Hiber...
FestGroup
 
JavaFest. Вадим Казулькин. Projects Valhalla, Loom and GraalVM
FestGroup
 
JavaFest. Антон Лемешко. Model-Driven Development in the Open Java Universe
FestGroup
 
JavaFest. Дмитрий Сергеев. Data processing with Kafka Streams and Spring Fram...
FestGroup
 
JavaFest. Nanne Baars. Web application security for developers
FestGroup
 
Ad

Recently uploaded (20)

PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
GRADE-3-PPT-EVE-2025-ENG-Q1-LESSON-1.pptx
EveOdrapngimapNarido
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPTX
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
GRADE-3-PPT-EVE-2025-ENG-Q1-LESSON-1.pptx
EveOdrapngimapNarido
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
Dimensions of Societal Planning in Commonism
StefanMz
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Horarios de distribución de agua en julio
pegazohn1978
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
Ad

JavaFest. Cedrick Lunven. Build APIS with SpringBoot - REST, GRPC, GRAPHQL which one should you pick?

  • 1. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Cedrick Lunven | Director of Developer Advocacy #DataStax @clunven Build APIS with SpringBoot REST, GRPC, GRAPHQL Which one should you pick?
  • 2. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 About me: Cedrick Lunven Director of Developer Advocacy Creator and Maintainer of FF4j Java and Spring Dinosaur
  • 3. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Agenda 50min 2 3 DEMO and Code Browse Data Model & Persistence with Apache Cassandra 1 Anatomy of a Spring Boot Micro service 4 Decision tree 5 Take my code and slides + Q&A
  • 4. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 NEW PROFESSIONAL JAVA EVENT MAY 30th, 2020 KYIV, UKRAINE Cedrick Lunven | Director of Developer Advocacy #DataStax @clunven Anatomy of a Spring Boot Microservice 1
  • 5. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Monolithic Business Logic User Interface Data Interface Multichannel UI Mobile UI Web ESB SOA Specialization BUS S1 S2 S3 Sn RDBMS noSQL DataLake Micro Frontend All Things Distributed Web Components SPA Native BFF (Backend for Frontend) Micro Services Data Mesh Api Gateway Service Discovery RDBMS Graph Hadoop Document KV newSQLColumn TSDB Distributed Tracing Containerization Layers Business Logic (Services) User Interface Data Interface (Dao) Backend Front-end OLTP OLAP RDBMS Microservices Architectures
  • 6. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Building a Spring Boot Microservice Exposition Layer Service Layer Persistence Layer Database Data Model Configuration Monitoring Security Access Patterns Volume Throughput Latency Security (Service, Component) (Controllers) (Dao, Repository)
  • 7. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 « Vanilla » So easy…. Exposition Layer Service Layer Persistence Layer Database Microservice (Service, Component) (Controllers) (Dao, Repository) 1 Normalized Data Model 2 CRUD
  • 8. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 « Vanilla » So easy…. Exposition Layer Service Layer Persistence Layer Database Microservice (Service, Component) (Controllers) (Dao, Repository) DATA DATA-REST WEB MVC Configuration Monitoring Security Database Driver
  • 9. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Entity => Spring-Data => Spring-Data-REST @Entity public class Customer { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; private String firstName; private String lastName; private Customer() {} private Customer( String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } @RepositoryRestResource( collectionResourceRel = "customers", path = "customers") public interface CustomerRepository extends CrudRepository<Customer, Long> { List<Customer> findByLastName(String lastName); Customer findById(long id); }
  • 10. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 When volumes grow ? Exposition Layer Service Layer Persistence Layer Database Microservice (Service, Component) (Controllers) (Dao, Repository) CREATE INDEX JOIN SHARDING … 3 CUSTOM QUERIES
  • 11. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 CAP Theorem for Distributed Systems Consistency Availability Partition Tolerance ?
  • 12. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 NEW PROFESSIONAL JAVA EVENT MAY 30th, 2020 KYIV, UKRAINE Cedrick Lunven | Director of Developer Advocacy #DataStax @clunven Persistence Layer and Data Model with Apache Cassandra™ 2
  • 13. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 NODE NODE NODE NODE NODE NODE NODE Apache Cassandra™ 1 Installation = 1 NODE ü Capacity: ± 1TB ü Throughput: 3000 Tx/sec/core Communication: ü Gossiping DataCenter | Ring = Distributed NoSQL Database
  • 14. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Scales Linearly • Need more capacity? • Need more throughput? • Add nodes!
  • 15. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Data is Distributed Country City Habitant USA New York 8.000.000 USA Los Angeles 4.000.000 FR Paris 2.230.000 DE Berlin 3.350.000 UK London 9.200.000 AU Sydney 4.900.000 FR Toulouse 1.100.000 JP Tokyo 37.430.000 IN Mumbai 20.200.000 DE Nuremberg 500.000 CA Montreal 4.200.000 CA Toronto 6.200.000 Partition Key
  • 16. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Data is replicated 59 (data) RF = 3 0 50 33 1783 67
  • 17. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Data is replicated RF = 3 0 50 33 1783 67 59 (data)59 (data)
  • 18. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Data is replicated RF = 3 0 50 33 1783 67 59 (data) 59 (data) 59 (data)
  • 19. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Self Healing RF = 3 0 50 33 1783 67 59 (data)59 (data)
  • 20. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Self Healing RF = 3 0 50 33 1783 67 59 (data) 59 (data) 59 (data) Hint
  • 21. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Self Healing RF = 3 0 50 33 1783 67 59 (data) 59 (data) 59 (data) Hint
  • 22. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Self Healing RF = 3 0 50 33 1783 67 59 (data) 59 (data) 59 (data)
  • 23. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Use Cases High Throughput High Volume Mission Critical Availability Realtime Distributed Heavy Writes Heavy Reads Event Streaming Internet of Things Log Analytics Any TimeSeries Caching Market Data Prices No Data Loss Reponsive System Any CRUD API Layer Geograhically DeploymentsD R A S Banking Track and Trace Customer Apps Enterprise Data Layer Applications Global Company Retailers Hybrid Cloud MultiCloud ?
  • 24. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Apache Cassandra MicroServices • REALTIME REQUESTS & SCALABILITY AT CORE • DISTRIBUTED ARCHITECTURES – From ACID to BASE (Basic Availability, Soft-State, Eventual Consistency) – Implementations: CQRS, Event Sourcing – Colocate service and Data • DECOUPLING BY DESIGN – 1 KEYSPACE = DOMAIN – 1 QUERY = 1 TABLE
  • 25. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Reference Application http://killrvideo.github.io
  • 26. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Data Model Design Entities & Relationships Queries
  • 27. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Conceptual Data Model
  • 28. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Application Workflow R1: Find comments related to target video using its identifier • Get most recent first • Implement Paging R2: Find comments related to target user using its identifier • Get most recent first • Implement Paging R3: Implement CRUD operations
  • 29. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Mapping 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
  • 30. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 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
  • 31. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 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 ↑
  • 32. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Schema DDL 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);
  • 33. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 We have everything we need Conceptual Data Model (Entities, Relations) Application Workflow (Queries) Database Family (Technos +Table)
  • 34. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Api Design Methodology 1 killrvideo-dse Drivers DAO3 killrvideo-api-rest killrvideo-api-grpc killrvideo-api-graphql 2
  • 35. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 NEW PROFESSIONAL JAVA EVENT MAY 30th, 2020 KYIV, UKRAINE Cedrick Lunven | Director of Developer Advocacy #DataStax @clunven DEMO 3
  • 36. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 https://github.com/clun /javafest-2020 docker-compose up –d
  • 37. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Configuration – 1# Convention
  • 38. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Configuration – #2 Java Config
  • 39. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Configuration - #3 Custom Definition
  • 40. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 CLIENT API DRIVER Parameters SynchronousQueries PreparedStatement & Parameters Bind Parameters BoundStatement ResultSet ResultSet Results Blocked API
  • 41. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 CLIENT API DRIVER v Parameters AsyncQueries PreparedStatement & Parameters Bind Parameters BoundStatement AsyncResultSet AsyncResultSet Result API CompletionStage Callback Hell
  • 42. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 CLIENT API DRIVER v Parameters ReactiveQueries PreparedStatement & Parameters Bind Parameters Row ReactiveRow Flux API ReactiveResultSet Subscribe BoundStatement Subscriber.onNext Query execution onComplete()
  • 43. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 NEW PROFESSIONAL JAVA EVENT MAY 30th, 2020 KYIV, UKRAINE Cedrick Lunven | Director of Developer Advocacy #DataStax @clunven DECISION TREE 4
  • 44. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Analysis Criteria Conceptual Data Model Application Workflow (Queries) Database Family (Technos +Table) Caching Sync vs Async Reactive SLA (Volume) Data Integrity Filters Paging Sort Latencies Throughput Versionning Confidentiality Atomicity Cardinality Developers Users/Consumers Language CodeFirst/ Vs SchemaFirst Documentation Test Build Packaging Api Catalog Internal vs Public Techno Profile XP
  • 45. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Analysis Matrix
  • 46. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Decision Tree
  • 47. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 v Decoupling Client / Server (Schema on read) v Api Lifecycle (Versioning) v Tooling (API Management, Serverless) v Verbose payloads (json, xml) v No discoverability v Not suitable for command-like (functions) API v CRUD superstar v Relevant for mutations (OLTP) v Public and web APIs
  • 48. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 v High Performances (http/2 – binary serialisation) v Multiple stubs : Sync, Async, Streaming v Multi languages - Interoperability v Strongly coupled (schema with proto files) v No discoverability v Protobuf serialization format v Distributed network of services (no waits) v High throughput & streaming use cases v Command-like (eg: slack)
  • 49. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 v Discoverability, documentation v Custom payloads v Match standards (Json | Http) v Single endpoint (versioning, monitoring, security) v Complex implementation (tooling, still young) v Nice for customers nasty for DB (N+1 select) v Backend for frontend (JS) v Service aggregation | composition (joins) v When volume matters (mobile phones) GraphQL
  • 50. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 NEW PROFESSIONAL JAVA EVENT MAY 30th, 2020 KYIV, UKRAINE Cedrick Lunven | Director of Developer Advocacy #DataStax @clunven RESOURCES 5
  • 51. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Github repo https://github.com/clun/javafest-2020
  • 52. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 DataStax Developers on Youtube • https://www.youtube .com/channel/UCAIQ Y251avaMv7bBv5PCo -A
  • 53. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 Sample CODES Micro-service REST https://bit.ly/31RL62I Micro-service GraphQL https://bit.ly/2MVicup Micro-service GRPC Micro-service Kafka Reactive with Webflux Micro-service Serverless https://bit.ly/2pofk0b https://bit.ly/34ePzhL https://bit.ly/2JwsFdM https://bit.ly/31VQz8G
  • 54. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 community.datastax.com
  • 55. switch(SpringBoot.api()) { Case REST,GRAPHQL,GRPC } | @clunven KYIV, 2020 NEW PROFESSIONAL JAVA EVENT MAY 30th, 2020 KYIV, UKRAINE THANK YOU ! (@clunven)