Post on 15-Feb-2017
MongoDB et Elasticsearch,
meilleurs ennemis ?
<Nous />
<Serli />
Petit sondage ...
MongoDB
Elasticsearch
Projets types Mongo et Elasticsearch
Beaucoup de points communs
Mongo ou Elasticsearch ?
Comment choisir ?
Popularité ?
db-engines.com
db-engines.com
db-engines.com
Pas très fiable ...
Démarrage rapide
Developer friendly
Vers le Minimum Viable Product
Installation d’un cluster Elasticsearch
2 minutes
cluster.name: my_cluster
$ ./elasticsearch$ ./elasticsearch
config/elasticsearch.yml
Installation d’un replicaset Mongo
$ mongod --dbpath=~/mongo-data/0 --replSet rs0$ mongod --dbpath=~/mongo-data/1 --replSet rs0 --port 27018$ mongod --dbpath=~/mongo-data/2 --replSet rs0 --port 27019
rs.initiate()rs.add("<hostname>:27018")rs.add("<hostname>:27019")
mongo shell
2 minutes + 30 sec
Démarrer un noeud Elasticsearch en Java
Settings settings = Settings. builder() .put("http.port", "9200") .put("network.host", "localhost") .put("path.home", "/tmp/es-unit-tests" ) .put("path.data", "/tmp/es-unit-tests-data" ) .build();
Node node = NodeBuilder. nodeBuilder() .local(true) .data(true) .clusterName( "elasticsearch-unit-tests" ) .settings(settings) .build();
node.start();
Data INData OUT
MongoDB
MongoDB
Index dans MongoDB
Storage Engines (Mongo > 3.0)
Ecriture dans Elasticsearch
Near real-time ?
Index Inversé
⇒
Terme Documents
brian #1
sens #2
vie #2 #1
Mise à jour dans Elastic
Relations
Disclaimer
Relations dans MongoDB
⇒
Relations dans MongoDB
⇒
Relations dans Elasticsearch
Full Text Search
Je veu fair du fotbal
MongoDB Full Text Search
Full Text Search
Agrégations
Les agrégations
MongoDB aggregation pipeline
jsonjson
json
json
$match $unwind $group
$sum $avg $min $max
$addToSet$year $month$week
Les agrégations dans Elasticsearch
2015
1974jsonjson
jsonjson
jsonjson
2015
batte sabre
1974
gun sabre
2015
sabre145.3
1974
gun2.4
sabre0.34
batte245.3
Stockage de fichiers
GridFS
Attachment Type
GridFS / Attachment Type
Pour stocker des fichiers...
Modèle distribué
Modèle distribué
⇒
Modèle distribué
Write Consistency
Modèle distribué
⇒
Sharding
CAP
⇒
Call me maybe : Kyle Kingsbury
https://aphyr.com/tags/jepsen
Call me maybe - MongoDB
Performances
Benchmark
Benchmark
Benchmarks sucks !
Production
Allez, on passe en Prod !
Systèmes vivants !
Ecosystème
Ecosystème MongoDB
Ecosystème MongoDB
Client Elastic
Ecosystème Elastic
Cloud
Alors, Mongo ou Elasticsearch ?
Alors ? MongoDB ou ElasticSearch ?
Les deux ?
Même paradigme
Une solution
write read
Mais ...
write read
?
Teeing
write read
write
Batch Maison
write read
Message Queue
write read
read write
Write
Push
Rôle de l’Indexer
Dénormaliser
Exemple (sans Parent Child)
Tweets
Users
Tweets
Exemple update
Tweets
Users
Tweets
Précalculer
Exemple pré-calcul : nbTweets
Tweets
Users
Tweets
Exemple pré-calcul
Tweets
Users
Tweets
Pour conclure
Conclusion
Conclusion
Storage Mashup ;-)
Merci !
Drink & Food Time