Giter Club home page Giter Club logo

mongoproxy's Introduction

Table of Contents

mongoproxy is just like mysqlproxy:

https://raw.github.com/idning/mongoproxy/master/docs/mysql-proxy-types-trx-splitting.png

(image from mysqlproxy)

why:

  • load-balance on primary and secondary.
  • mongo-php-drive is too heavy to create a connection
  • too many php workers, too many connections
  • client should not to know it's a replset(no slaveok for client)

what's better:

  • single process, less ping to backend mongod
  • avoid blocking ping before querys.
  • one client => one server conn

TODO:

  • print request_id into log done
  • dump request & response done
  • handler slave_ok done
  • handler primary change
  • client idle
  • server side timeout. done
  • close serverside conn when too many idle conns(easy to do).
  • ssl support
  • smart clients may use ismaster to find out backends, we should hide this

conf/mongoproxy.cfg

MONGOPROXY_BIND = 0.0.0.0
MONGOPROXY_PORT = 9527

#replica set
MONGOPROXY_USE_REPLSET = 1

MONGOPROXY_REPLSET_NAME = cluster0
#select will go to slaves
MONGOPROXY_REPLSET_ENABLE_SLAVE = 1

#MONGOPROXY_BACKEND = 127.0.0.1:27017
MONGOPROXY_BACKEND = 127.0.0.1:30001,127.0.0.1:30003
ning@ning-laptop ~/idning/blog_and_notes$ mongo --port 9527
MongoDB shell version: 2.0.6
connecting to: 127.0.0.1:9527/test
SECONDARY> db.foo.find()
{ "_id" : ObjectId("506afa5300ee31bfddede23d"), "x" : 3 }
{ "_id" : ObjectId("506afa7a5428e4e2f65ce8fb"), "x" : 3 }
{ "_id" : ObjectId("506b30adf6f0dc3792367efe"), "3" : 5 }
{ "_id" : ObjectId("506b9f4cc50ba0162da625bf"), "x" : 3 }
SECONDARY> db.foo.insert({x:9})
PRIMARY> db.foo.find()
{ "_id" : ObjectId("506afa5300ee31bfddede23d"), "x" : 3 }
{ "_id" : ObjectId("506afa7a5428e4e2f65ce8fb"), "x" : 3 }
{ "_id" : ObjectId("506b30adf6f0dc3792367efe"), "3" : 5 }
{ "_id" : ObjectId("506b9f4cc50ba0162da625bf"), "x" : 3 }
{ "_id" : ObjectId("506ba7e74f1b2720690ce3c0"), "x" : 9 }
PRIMARY>

use pymongo testcases:

git clone https://github.com/mongodb/mongo-python-driver
cd mongo-python-driver
export DB_PORT=9527

nosetests -I test_ssl -vx

mongoproxy's People

Contributors

idning avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.