Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Scaling MongoDB dengan ReplicaSet dan
Sharding
Download paper: http://de.tk/UKbjC
Application Design
● Strategi penambahan server
● Strategi mendistribusikan request
● Strategi pengembangan database
● Str...
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 k...
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 on...
ReplicaSet
Setup ReplicaSet
> mongod --replSet myReplicaSet
> mongo 192.168.1.1:27017
> rs.initiate();
> rs.add('192.168.1.2:27017');...
Implementasi ReplicaSet di PHP
$mongo = new MongoClient('92.168.1.1');
$mongo = new
MongoClient('92.168.1.1,92.168.1.2,92....
ReadPreference
$mongo-
>setReadPreference(MongoClient::RP_SECO
NDARY_PREFERRED);
Sharding
Setup Sharding
> mongod --configsvr --dbpath /tmp/mongoconfig --port 27019
> mongos --configdb mongoconfig1,mongoconfig2,m...
Upcoming SlideShare
Loading in …5
×

Scaling mongo db dengan replicaset dan sharding

1,094 views

Published on

  • Be the first to comment

  • Be the first to like this

Scaling mongo db dengan replicaset dan sharding

  1. 1. Scaling MongoDB dengan ReplicaSet dan Sharding Download paper: http://de.tk/UKbjC
  2. 2. Application Design ● Strategi penambahan server ● Strategi mendistribusikan request ● Strategi pengembangan database ● Strategi penanganan static file ● Strategi penanganan session ● dst
  3. 3. Success Story ● Facebook ● Twitter ● Dll Tidak selalu bisa diimplementasikan dengan mudah
  4. 4. Scaling Database ● Konsistensi data ● Cara mendistribusikan data ● Cara menangani id unik ● Strategi failover Salah satu kunci utama, tapi yang paling sulit dilakukan, karena:
  5. 5. Application Evolution Tahap 1: Semua service dalam satu server
  6. 6. Tahap 2: Pemisahan aplikasi dan database
  7. 7. Tahap 3: Penambahan Webserver
  8. 8. Tahap 4: Penambahan Cache Service
  9. 9. Tahap 5: Database Master-slave
  10. 10. Tahap 6: Database Master-master
  11. 11. Tahap 7: Database Partitioning
  12. 12. Kriteria scaling database ● Automatc failover ● Symmetric ● Konfigurasi minimum dari sisi client ● Write-scalable
  13. 13. Feture ReplicaSet dan Shariding MongoDB yang memenuhi kriteria ini.
  14. 14. 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".
  15. 15. ReplicaSet
  16. 16. 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');
  17. 17. 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'));
  18. 18. ReadPreference $mongo- >setReadPreference(MongoClient::RP_SECO NDARY_PREFERRED);
  19. 19. Sharding
  20. 20. 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})

×