SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Downloaden Sie, um offline zu lesen
Scaling MongoDB dengan ReplicaSet dan
Sharding
Download paper: http://de.tk/UKbjC
Application Design
● Strategi penambahan server
● Strategi mendistribusikan request
● Strategi pengembangan database
● Strategi penanganan static file
● Strategi penanganan session
● dst
Success Story
● Facebook
● Twitter
● Dll
Tidak selalu bisa diimplementasikan dengan mudah
Scaling Database
● Konsistensi data
● Cara mendistribusikan data
● Cara menangani id unik
● Strategi failover
Salah satu kunci utama, tapi yang paling sulit
dilakukan, karena:
Application Evolution
Tahap 1: Semua service dalam satu server
Tahap 2: Pemisahan aplikasi dan database
Tahap 3: Penambahan Webserver
Tahap 4: Penambahan Cache Service
Tahap 5: Database Master-slave
Tahap 6: Database Master-master
Tahap 7: Database Partitioning
Kriteria scaling database
● Automatc failover
● Symmetric
● Konfigurasi minimum dari sisi client
● Write-scalable
Feture ReplicaSet dan Shariding MongoDB yang
memenuhi kriteria ini.
ReplicaSet
Dikutip dari docs.MongoDB.org:"A MongoDB
replica set is a cluster of mongod instances that
replicate amongst one another and ensure
automated failover. Most replica sets consists of
two or more mongod instances with at most one
of these designated as the primary and the rest
as secondary members. Clients direct all writes
to the primary, while the secondary members
replicate from the primary asynchronously".
ReplicaSet
Setup ReplicaSet
> mongod --replSet myReplicaSet
> mongo 192.168.1.1:27017
> rs.initiate();
> rs.add('192.168.1.2:27017');
> rs.add('192.168.1.3:27017');
Implementasi ReplicaSet di PHP
$mongo = new MongoClient('92.168.1.1');
$mongo = new
MongoClient('92.168.1.1,92.168.1.2,92.168.1.3',
array('replicaSet' => 'myReplicaSet'));
ReadPreference
$mongo-
>setReadPreference(MongoClient::RP_SECO
NDARY_PREFERRED);
Sharding
Setup Sharding
> mongod --configsvr --dbpath /tmp/mongoconfig --port 27019
> mongos --configdb mongoconfig1,mongoconfig2,mongoconfig3
> mongo
> sh.addShard( "myReplicaSet/mongod1:27017" )
> sh.addShard( "myReplicaSet2/mongod2:27017" )
> sh.enableSharding("DBBlog")
> sh.shardCollection("DBBlog.posts", {"post_id" : 1})

Weitere ähnliche Inhalte

Ähnlich wie Scaling mongo db dengan replicaset dan sharding

Webinar: What's New in MongoDB 3.2
Webinar: What's New in MongoDB 3.2Webinar: What's New in MongoDB 3.2
Webinar: What's New in MongoDB 3.2MongoDB
 
Big data and polyglot solutions
Big data and polyglot solutionsBig data and polyglot solutions
Big data and polyglot solutionsKumaran Ramanujam
 
Geo2tag performance evaluation, Zaslavsky, Krinkin
Geo2tag performance evaluation, Zaslavsky, Krinkin Geo2tag performance evaluation, Zaslavsky, Krinkin
Geo2tag performance evaluation, Zaslavsky, Krinkin OSLL
 
MongoDB World 2018: Breaking the Mold - Redesigning Dell's E-Commerce Platform
MongoDB World 2018: Breaking the Mold - Redesigning Dell's E-Commerce PlatformMongoDB World 2018: Breaking the Mold - Redesigning Dell's E-Commerce Platform
MongoDB World 2018: Breaking the Mold - Redesigning Dell's E-Commerce PlatformMongoDB
 
Conceptos básicos. Seminario web 6: Despliegue de producción
Conceptos básicos. Seminario web 6: Despliegue de producciónConceptos básicos. Seminario web 6: Despliegue de producción
Conceptos básicos. Seminario web 6: Despliegue de producciónMongoDB
 
Evolution of DBA in the Cloud Era
 Evolution of DBA in the Cloud Era Evolution of DBA in the Cloud Era
Evolution of DBA in the Cloud EraMydbops
 
How to boost performance of your rails app using dynamo db and memcached
How to boost performance of your rails app using dynamo db and memcachedHow to boost performance of your rails app using dynamo db and memcached
How to boost performance of your rails app using dynamo db and memcachedAndolasoft Inc
 
MongoDB at Gilt Groupe
MongoDB at Gilt GroupeMongoDB at Gilt Groupe
MongoDB at Gilt GroupeMongoDB
 
Webinar: An Enterprise Architect’s View of MongoDB
Webinar: An Enterprise Architect’s View of MongoDBWebinar: An Enterprise Architect’s View of MongoDB
Webinar: An Enterprise Architect’s View of MongoDBMongoDB
 
how_can_businesses_address_storage_issues_using_mongodb.pptx
how_can_businesses_address_storage_issues_using_mongodb.pptxhow_can_businesses_address_storage_issues_using_mongodb.pptx
how_can_businesses_address_storage_issues_using_mongodb.pptxsarah david
 
Microservice Workshop Hands On
Microservice Workshop Hands On Microservice Workshop Hands On
Microservice Workshop Hands On Ram G Suri
 
how_can_businesses_address_storage_issues_using_mongodb.pdf
how_can_businesses_address_storage_issues_using_mongodb.pdfhow_can_businesses_address_storage_issues_using_mongodb.pdf
how_can_businesses_address_storage_issues_using_mongodb.pdfsarah david
 
Druid Summit 2023 : Changing Druid Ingestion from 3 hours to 5 minutes
Druid Summit 2023 : Changing Druid Ingestion from 3 hours to 5 minutesDruid Summit 2023 : Changing Druid Ingestion from 3 hours to 5 minutes
Druid Summit 2023 : Changing Druid Ingestion from 3 hours to 5 minutesShivji Kumar Jha
 
Introduction to MongoDB and its best practices
Introduction to MongoDB and its best practicesIntroduction to MongoDB and its best practices
Introduction to MongoDB and its best practicesAshishRathore72
 
Building multi tenancy enterprise applications - quick
Building multi tenancy enterprise applications - quickBuilding multi tenancy enterprise applications - quick
Building multi tenancy enterprise applications - quickuEngine Solutions
 
Database Virtualization: The Next Wave of Big Data
Database Virtualization: The Next Wave of Big DataDatabase Virtualization: The Next Wave of Big Data
Database Virtualization: The Next Wave of Big Dataexponential-inc
 

Ähnlich wie Scaling mongo db dengan replicaset dan sharding (20)

Webinar: What's New in MongoDB 3.2
Webinar: What's New in MongoDB 3.2Webinar: What's New in MongoDB 3.2
Webinar: What's New in MongoDB 3.2
 
Big data and polyglot solutions
Big data and polyglot solutionsBig data and polyglot solutions
Big data and polyglot solutions
 
Geo2tag performance evaluation, Zaslavsky, Krinkin
Geo2tag performance evaluation, Zaslavsky, Krinkin Geo2tag performance evaluation, Zaslavsky, Krinkin
Geo2tag performance evaluation, Zaslavsky, Krinkin
 
MongoDB World 2018: Breaking the Mold - Redesigning Dell's E-Commerce Platform
MongoDB World 2018: Breaking the Mold - Redesigning Dell's E-Commerce PlatformMongoDB World 2018: Breaking the Mold - Redesigning Dell's E-Commerce Platform
MongoDB World 2018: Breaking the Mold - Redesigning Dell's E-Commerce Platform
 
Conceptos básicos. Seminario web 6: Despliegue de producción
Conceptos básicos. Seminario web 6: Despliegue de producciónConceptos básicos. Seminario web 6: Despliegue de producción
Conceptos básicos. Seminario web 6: Despliegue de producción
 
Evolution of DBA in the Cloud Era
 Evolution of DBA in the Cloud Era Evolution of DBA in the Cloud Era
Evolution of DBA in the Cloud Era
 
Noha mega store
Noha mega storeNoha mega store
Noha mega store
 
Mongo db 3.4 Overview
Mongo db 3.4 OverviewMongo db 3.4 Overview
Mongo db 3.4 Overview
 
How to boost performance of your rails app using dynamo db and memcached
How to boost performance of your rails app using dynamo db and memcachedHow to boost performance of your rails app using dynamo db and memcached
How to boost performance of your rails app using dynamo db and memcached
 
MongoDB at Gilt Groupe
MongoDB at Gilt GroupeMongoDB at Gilt Groupe
MongoDB at Gilt Groupe
 
Webinar: An Enterprise Architect’s View of MongoDB
Webinar: An Enterprise Architect’s View of MongoDBWebinar: An Enterprise Architect’s View of MongoDB
Webinar: An Enterprise Architect’s View of MongoDB
 
how_can_businesses_address_storage_issues_using_mongodb.pptx
how_can_businesses_address_storage_issues_using_mongodb.pptxhow_can_businesses_address_storage_issues_using_mongodb.pptx
how_can_businesses_address_storage_issues_using_mongodb.pptx
 
Mongodb
MongodbMongodb
Mongodb
 
Microservices
MicroservicesMicroservices
Microservices
 
Microservice Workshop Hands On
Microservice Workshop Hands On Microservice Workshop Hands On
Microservice Workshop Hands On
 
how_can_businesses_address_storage_issues_using_mongodb.pdf
how_can_businesses_address_storage_issues_using_mongodb.pdfhow_can_businesses_address_storage_issues_using_mongodb.pdf
how_can_businesses_address_storage_issues_using_mongodb.pdf
 
Druid Summit 2023 : Changing Druid Ingestion from 3 hours to 5 minutes
Druid Summit 2023 : Changing Druid Ingestion from 3 hours to 5 minutesDruid Summit 2023 : Changing Druid Ingestion from 3 hours to 5 minutes
Druid Summit 2023 : Changing Druid Ingestion from 3 hours to 5 minutes
 
Introduction to MongoDB and its best practices
Introduction to MongoDB and its best practicesIntroduction to MongoDB and its best practices
Introduction to MongoDB and its best practices
 
Building multi tenancy enterprise applications - quick
Building multi tenancy enterprise applications - quickBuilding multi tenancy enterprise applications - quick
Building multi tenancy enterprise applications - quick
 
Database Virtualization: The Next Wave of Big Data
Database Virtualization: The Next Wave of Big DataDatabase Virtualization: The Next Wave of Big Data
Database Virtualization: The Next Wave of Big Data
 

Mehr von k4ndar

Big data-at-detik
Big data-at-detikBig data-at-detik
Big data-at-detikk4ndar
 
Introduction Laravel By Hasannuh Bz
Introduction Laravel By Hasannuh BzIntroduction Laravel By Hasannuh Bz
Introduction Laravel By Hasannuh Bzk4ndar
 
Optimize Web Application Infrastructure by Rizki Nanda Agam
Optimize Web Application Infrastructure by Rizki Nanda Agam Optimize Web Application Infrastructure by Rizki Nanda Agam
Optimize Web Application Infrastructure by Rizki Nanda Agam k4ndar
 
Panada: An Introduction by Iskandar Soesman
Panada: An Introduction by Iskandar SoesmanPanada: An Introduction by Iskandar Soesman
Panada: An Introduction by Iskandar Soesmank4ndar
 
Yii2 by Peter Jack Kambey
Yii2 by Peter Jack KambeyYii2 by Peter Jack Kambey
Yii2 by Peter Jack Kambeyk4ndar
 
Git for development and deployment By Azhari Harahap
Git for development and deployment By Azhari HarahapGit for development and deployment By Azhari Harahap
Git for development and deployment By Azhari Harahapk4ndar
 
Composer Panada Conference 2014 by Mulia Nasution
Composer Panada Conference 2014 by Mulia NasutionComposer Panada Conference 2014 by Mulia Nasution
Composer Panada Conference 2014 by Mulia Nasutionk4ndar
 
Optimize php application in high traffic environment
Optimize php application in high traffic environmentOptimize php application in high traffic environment
Optimize php application in high traffic environmentk4ndar
 

Mehr von k4ndar (8)

Big data-at-detik
Big data-at-detikBig data-at-detik
Big data-at-detik
 
Introduction Laravel By Hasannuh Bz
Introduction Laravel By Hasannuh BzIntroduction Laravel By Hasannuh Bz
Introduction Laravel By Hasannuh Bz
 
Optimize Web Application Infrastructure by Rizki Nanda Agam
Optimize Web Application Infrastructure by Rizki Nanda Agam Optimize Web Application Infrastructure by Rizki Nanda Agam
Optimize Web Application Infrastructure by Rizki Nanda Agam
 
Panada: An Introduction by Iskandar Soesman
Panada: An Introduction by Iskandar SoesmanPanada: An Introduction by Iskandar Soesman
Panada: An Introduction by Iskandar Soesman
 
Yii2 by Peter Jack Kambey
Yii2 by Peter Jack KambeyYii2 by Peter Jack Kambey
Yii2 by Peter Jack Kambey
 
Git for development and deployment By Azhari Harahap
Git for development and deployment By Azhari HarahapGit for development and deployment By Azhari Harahap
Git for development and deployment By Azhari Harahap
 
Composer Panada Conference 2014 by Mulia Nasution
Composer Panada Conference 2014 by Mulia NasutionComposer Panada Conference 2014 by Mulia Nasution
Composer Panada Conference 2014 by Mulia Nasution
 
Optimize php application in high traffic environment
Optimize php application in high traffic environmentOptimize php application in high traffic environment
Optimize php application in high traffic environment
 

Scaling mongo db dengan replicaset dan sharding