# Custom sharding logic

**URL:** <https://discuss.dgraph.io/t/custom-sharding-logic/9899>\
**Category:** Dgraph\
**Tags:** kind:question\
**Created:** [August 29, 2020, 1:16pm UTC](https://discuss.dgraph.io/t/custom-sharding-logic/9899 "2020-08-29T13:16:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aleclofabbro](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/aleclofabbro/32/4500_2.png) [@aleclofabbro](https://discuss.dgraph.io/u/aleclofabbro)\
**Post date:** [August 29, 2020, 1:16pm UTC](https://discuss.dgraph.io/t/custom-sharding-logic/9899/1 "2020-08-29T13:16:05Z")

</div>

I’m developing a platform that let users publish stuff, stored in Dgraph, in a social-network flavour.

Instances of this platform can be deployed independently by any organization and delivering service as a standalone platform.  
Users can search instance contents using proper Dgraph query and indexes

Organizations have also the option to join a federation.  
Federated instances allow users to seamlessly search for content through all federated-instances.  
This may be achieved to some extent by configuring each federated Dgraph as (1+)Group in a federated shard.

anyhow a bunch of requirements shall be guaranteed:  
A : content generated in an instance must be stored in its relative group (in their own storage)  
B : query/read is allowed for all instances  
C : write is allowed for generating group only  
D : when federated querying the query should succeed with available groups, even if a are down

I can imagine a couple of approaches for this:  
1 : having a central single Zero, representing “The Federation” and adding some custom logic to a central single Zero properly tweaked to obtain these behaviors, maybe by implemnting some plugins?  
2 : having a dedicate Dgraph for search functionalities in all instances, in this case federated organization may share the whole searchable dataset as replicas

option 1 looks the most interesting, if Zero logic can be tweaked

option 2 may be more straightforward, and would make requirement A not relevant.  
I wonder if it would be possible to store indexes only for search purposes, and not the whole datasets (as they would become a heavy redundance)

this question is kind of a followup to [this topic](http://discuss.hypermode.com/t/shard-zero-and-alpha-nodes-in-a-federated-flavour/9709)

---

<div class="post-metadata">

**Author:** ![chewxy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/chewxy/32/4339_2.png) [@chewxy](https://discuss.dgraph.io/u/chewxy)\
**Post date:** [September 7, 2020, 4:31am UTC](https://discuss.dgraph.io/t/custom-sharding-logic/9899/2 "2020-09-07T04:31:15Z")

</div>

Hi @pawan do we know of any way to do this?
