What the conceptual difference between tenant and namespace
Asked Answered
L

1

6

I'm faced with the tenant term a little time ago in context of Stormpath and after in context of Google Cloud Datastore. And what made me crazy about this, is why we where need to introduce new term to define a namespace? Or maybe I'm missing something that describes tenant's specific qualities that namespace doesn't have?

And although, in this whole concept I'm still can't get the concept of the multitenancy here? What the point of multitenancy? It just looks like multinamespaces thing, but with the same structure.

So, what the difference betwen this two terms?

Lumbye answered 8/4, 2017 at 18:24 Comment(0)
U
8

In Datastore, one would use Namespaces to create a multitenant structure.

Example:

Let's say you want to create a social network, like Facebook, but simplified. You'd have users, posts, and comments.

Entities

  • users
  • posts
  • comments

Namespace

Instead of declaring a 'post' entity as a child of 'user' entity, you can assign a namespace (user-ID) to the 'post'.

In terms of data structure, it might seem there's no difference, but in terms of performance, it does. When you declare an entity as a child of a parent, Datastore will need to store all children together and assure consistency of data within that parent. When you assign a namespace to an entity, it can distribute the data and doesn't guarantee absolute consistency.

That's why Datastore limits to 1 write per second (on average) within each Parent, but doesn't impose write limits within a namespace.

What does 'Consistency' mean?

In this example, let's say Jack published a post right now. Mary and John are his friends. If Mary and John access Jack's posts right after Jack posts, is it 100% guaranteed that both will see this new post?

  • If the post is a child of user (Jack), they will.
  • If the post is in the user (Jack) namespace, it might not be true at a given point of time; eventually, both will see the post, but it might take some time for the change to propagate.
Unshod answered 12/4, 2017 at 16:45 Comment(5)
So, basicaly, it is all about data structuring to achieve higher performance?Lumbye
That's right. If you expect a high number of writes per second, go with namespaces. If your use case require data consistency, go with ancestor path. If you need both, Datastore is not for you. Check out Datastore Multitenancy documentation for more details. In this page, you'll also find links with guidelines about how to implement this architecture in Go, Java and Python SDKs.Unshod
One clarification: the number of writes per second should stay below 1/second (on average across time) for each parent. You can have 1 million writes per second, as long as it's not above 1/second (on average) for a single parent.Unshod
@RenatoByrro is there any limit for reads for ancestor path? which is faster when reading, ancestor or namespace?Harriman
Sorry, don't know the answer to those questions, @JohnBalvinAriasUnshod

© 2022 - 2024 — McMap. All rights reserved.