Sharding with spring mongo

爷,独闯天下 提交于 2019-12-06 07:53:43

问题


I'm using mongoDB for storing and querying close to 50 mn records (Large Json files with no fixed schema), through a spring web application. Simple K-V pair based find queries run into a few seconds. I'm looking at ways to bring search time down to < 1s.

Indexing doesn't work for me because of the nature of the files stored. I was looking at alternatives and came across sharding. However, I found no good tutorial explaining how to set up sharding for my existing spring-mongo application.

Can someone please point me towards a good explanation for the same? Also any other suggestions for optimizing search time would be welcome!

EDIT

Following the comment, I converted my existing Mongo database into a sharded one with 1 config server, 1 query server and 2 shards. Previously my (spring-boot) application.properties file looked like this :

...
spring.data.mongodb.database=pam
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.repositories.enabled=true
spring.data.mongodb.uri=mongodb://localhost:27017/pam
...

How do I modify it now to adapt to the sharded database, with the same name?


回答1:


If you read carefully docs https://docs.mongodb.com/manual/sharding/ you would agree that fact of sharding is and should be transparent for the rest of the system. That is initially your system can be just single database, and then full shard with

  • mongos Router
  • Config Server
  • Shards (that are replicas)

i.e. sharding is deployment question, not a design. MongoDB interface stays the same.



来源:https://stackoverflow.com/questions/35497070/sharding-with-spring-mongo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!