KEMBAR78
NoSQL design pitfalls with Java | PDF
Otavio Santana
@otaviojava
NoSQL design
pitfalls with Java
Otavio Santana
@otaviojava
DevRel Engineer
+ Java Champion
+ JCP-EC-EG-EGL
+ Apache Committer
+ Eclipse Committer
+ Eclipse Project Leader
+ Book and blog writer
Speaker
What it is not!
● “New research shows 75% of ‘open’ Redis servers infected”
● The Twelve Factor App
NoSecurity
● Schemaless
● Validation
No Data integrity
● Complexity
● Maintain
No Responsibility
● The right questions
● Horizontal vs Vertical
● Write vs Read
Scalability??
● Benchmark
● CAP theorem
No-mistake
● CAP theorem
● Backup
No-Trade-off
● SQL
● NewSQL
● NoSQL
No-single-solution
Model
● Key
● Biggest mistakes
● View
Modeling
What Apache Cassandra is not
● Big Data
● Rich Query
● Relational
Cassandra
● Key
○ Partition Key
○ Clustering Key
● Secondary Key
● Allow Filtering
Queries
● List
● Map
● Tuple
● UDT
Cassandra Powers
● Load Balancer
● Consistency Level ALL
● Backup
Troy
Sample
@Entity
public class Contact {
@Id
private String name;
@Column
private LocalDate birthday;
@Column
private Map<String, String> details;
}
● Map
● UDT
Sample @Entity
class Car {
@Id
private String plate;
@Column
private String city;
@Column
private String color;
@UDT("owner")
@Column
private Owner owner;
}
● UDT
Sample
@Entity
public class Recipe {
@Id
private String name;
@Column
private String city;
@Column
@UDT("ingredient")
private Set<Ingredient> ingredients;
}
● Set
● UDT
MongoDB
● Transaction
● ACID
What MongoDB is not
“In a relational database, we usually model the schema at
the very beginning of the project. Why is this so bad?
Because the beginning of the project is exactly the
moment that we know least about it”
Oren Eini - Modeling in a
Non Relational World
● Coherence
● Independence
● Isolation
DDD - Elemar Jr
● Self Sufficient
● Business
Coherence
● Exist
● It does not need anyone
Independence
La liberté guidant le people (1830)
● Cannot impact another entity
Isolation
● Entity
● Aggregate
● Value Object
Sample @Entity
public class Order {
@Id
private ObjectId id;
@Column
private LocalDateTime orderedAt;
@Column
private List<Product> items;
@Column
private Address shipTo;
}
Cloud
● Containers
● Mutable
● Kubernetes
● Services
Cloud
● Bean Validation
● ORM
● Reactive programming
● Impedance
Java Frameworks
Demo Time
Platform.sh
We live in a cloud economy
Use cloud ready
SaaS services
Complexity
Cost
Risk
High
Med - High
Low
Migrate existing
workloads into
cloud
Build new apps
cloud ready
Degrees of risk around
enterprise cloud consumption...
^
^
We’re a polyglot, multicloud PaaS, with
continuous deployment built in.
At Platform.sh we believe your code
should just run. Monoliths?
Microservices? Stateful? Stateless?
Develop and deliver them all with
consistent tools.
Much more than
hosting
Infrastructure as
code
Add MySQL, PostgreSQL, MongoDB, Kafka,
Elasticsearch, Solr, Redis, RabbitMQ, or
InfluxDB to your project with a few lines of
code. Infrastructure changes are versioned
and auditable.
Service updates and security?
That’s on us. No more effort wasted on
patching your fleet.
Application
name: app
type: "java:11"
disk: 1024
hooks:
build: mvn clean package
relationships:
database: "db:postgresql"
web:
commands:
start: java -jar $JAVA_OPTS $CREDENTIAL file.jar
Services
database1:
type: mysql:10.1
disk: 2048
database2:
type: postgresql:9.6
disk: 1024
Route
"https://{default}/":
type: upstream
upstream: "app:http"
"https://www.{default}/":
type: redirect
to: "https://{default}/"
Platform.sh provides
an end-to-end PaaS
to build, run, and maintain
polyglot fleets of digital
experience applications
Developers can then focus on what matters
to the organization: shipping great web apps
and sites
Container Orchestration
Infrastructure
Continuous Deployment
Data Services
App Runtimes
Routing + Edge Security
Continuous Integration
Application Code
Application Data
Provisioning APIs, Integrations, Template Libraries
Web Console
…
Source Operations™
1000s
e-commerce, life sciences, government, education,
media & entertainment, and high-tech customers
$47m
invested by top-tier international partners
Platform.sh at
a glance
Q&A Thank you!
Otavio Santana
DevRel Engineer, Platform.sh
@otaviojava

NoSQL design pitfalls with Java