SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
807 stars 171 forks source link

Configure multiple replicas #110

Closed francisco-andrade closed 8 years ago

francisco-andrade commented 8 years ago

Hi there,

I'm trying to find if there's a way to configure Restheart to access more than one replicaSet. Looking on the configurations, it seems to me that one instance of RestHeart will only connect to one mongodb replicaSet. But I may be loosing something.

I wonder if it's possible to receive the replicaSet configuration or having several configurations and use each one depending on the request.

Does anyone had this need before?

Thanks! Francisco Andrade

ujibang commented 8 years ago

Hi @chicoandrade

you have 2 options:

use sharded replica sets

in any request, you can use the shardkey query parameter to properly select the replica set

more info at https://docs.mongodb.org/manual/core/sharded-cluster-shards/

GET /db/coll?shardkey={"key":1}

use several restheart instances

restheart is a lightweight server, it should be fine to have one instance per each replica set bound to different port

francisco-andrade commented 8 years ago

Got it. Thanks!