Skip to content

shashankrnr32/mongodb-application-sharding

Repository files navigation

mongodb-application-sharding

Java CI with Maven Maven Package codecov

SonarCloud

Mongo DB Application Sharding allows you to shard your Mongo DB cluster from your application using different strategies. This project is inspired by Apache's shardingsphere which enables the users to shard the relational databases through the application.

Application Sharding Strategies supported by the library

  1. Collection Sharding Strategy
  2. Database Sharding Strategy
  3. Composite Sharding Strategy

Get Started

Spring / Spring Boot Projects

To use this library in your project, just add the package sharding-spring as a dependency to your project.

<!-- sharding-spring -->
<dependency>
    <groupId>com.alpha.mongodb</groupId>
    <artifactId>sharding-spring</artifactId>
    <version>${mongodb.sharding.version}</version>
</dependency>

Mongo DB Clients - Application built without Spring.

<!-- sharding-driver -->
<dependency>
    <groupId>com.alpha.mongodb</groupId>
    <artifactId>sharding-driver</artifactId>
    <version>${mongodb.sharding.version}</version>
</dependency>

To see a sample usage of different Sharding Strategies, visit the documentation here.

Features

  1. Supports 3 different sharding strategies for Spring / Spring Boot projects by extending MongoTemplate.
  2. Supports Reactive Mongo Templates (for all the sharding strategies)
  3. Sharding support for Mongo Clients (without the need of spring dependencies). This supports both executable and reactive Mongo Clients.
  4. Hint Resolution through ThreadLocal and callback based mechanism.
  5. Automatic Hint Resolution Callback discovery for Spring Beans using ApplicationContext
  6. Custom configuration available for Sharding, validation of shards etc.
  7. Tested using Spring's Mongo Template and Repository

Roadmap

This project is in its budding stage. But I do see a lot of features that can be added.

  1. More customization to Sharding options to allow dynamic shards, custom validations etc.
  2. Support non-sharded collections within a sharded database.
  3. Support to query from all the shards when the library is unable to route the query to a particular shard.
  4. Configuring Sharding from property files without writing any Java Code
  5. Support Aggregation queries
  6. And so much more...!

Code Analysis

Technical Debt Maintainability Rating Security Rating Bugs Code Smells Vulnerabilities Duplicated Lines (%) Reliability Rating

Author

Shashank Sharma