Scaling mongo db dengan replicaset dan sharding

885 views
793 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
885
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

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})

×