有沒有同志在用mongodb做讀寫分離?

來源:互聯網
上載者:User
有沒有同志在用mongodb做讀寫分離?
php擴充如何?mongodb讀寫分離?

回複內容:

有沒有同志在用mongodb做讀寫分離?
php擴充如何?mongodb讀寫分離?

可以做一層orm,比如orm中添加select,insert,update三個方法,分別指向不同的伺服器,這樣就可以簡單實現讀取分離,可以參考thinkphp的讀取分離機制

mongodb有一個地方有點坑,在mapreduce的查詢中,如果有out結果到新集合這個就不知道怎麼處理了。

複製集的一主多從可以通過指定read_preferences實現寫主讀從.
擴充直接指定read_preferences即可.

mongodb 不建議使用 master/slave 方式做讀寫分離,所以最好別這樣做,使用 replica sets 吧。

Replica sets replace master-slave replication for most use cases. If possible, use replica sets rather than master-slave replication for all new production deployments. This documentation remains to support legacy deployments and for archival purposes only.

如果要最佳化讀寫效能應該嘗試使用 auto-sharding,使用 mongos 作為 db proxy,動態平衡各個資料庫的壓力。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.