Using Namespaces

40 views
Skip to first unread message

SMF

unread,
Apr 22, 2014, 9:06:24 AM4/22/14
to google-a...@googlegroups.com
Hi there

I have a few basic questions

1. If I have 1000+  Namespaces, how will they get displayed in the App Engine Admin Console (Datastore Viewer),
Right now I have few and they are displayed in a dropdown box.


2. I have a Multi-Tenant app where each tenant has its own namespace. the model and entities related to the tenant is within their respective namespace except for the User entities each tenant can have multiple users.
thats why all users are stored without any namespace.

The user's  UserId ,name and TenantId (also used as namespace) is stored in the Users Model

After user log's in through Google , We Query this Model to Find the Namespace of the logged in User, Once found we set it and use it for reading / storing entities in their respective  namespace.

My Question is What could go wrong with this approach ?, and do we have any better solution for handling Multiple Tenants with Multiple User Accounts.
We need to do this without using Sub Domain Names and URL Paths (Containing the namespace id or key)


3. We also need to have (CRON) Jobs which will run at a minimum of 3 times a day to Query Some Entities and Update Some and Send the Report to the Tenants users. In this case we would have to Query the meta data to get list of namespaces, and then for each namespace query the desired entities.
This would increase the cpu and memory consumption, is there any better way to run CRON on multiple namespaces.


Any help will be highly appreciated.

Thanks
Sarfaraz




.














Renzo Nuccitelli

unread,
Apr 22, 2014, 5:12:31 PM4/22/14
to google-a...@googlegroups.com
On Tuesday, April 22, 2014 10:06:24 AM UTC-3, SMF wrote:
Hi there

I have a few basic questions

1. If I have 1000+  Namespaces, how will they get displayed in the App Engine Admin Console (Datastore Viewer),
Right now I have few and they are displayed in a dropdown box.

 I am curious about it too. I haven't a large number of tenants yeat but would be nice to know how to handle it. But I have a feeling that the UI will be the same and probably we will must to handle it developing the tools to make administrative tasks on each tenant.
 


2. I have a Multi-Tenant app where each tenant has its own namespace. the model and entities related to the tenant is within their respective namespace except for the User entities each tenant can have multiple users.
thats why all users are stored without any namespace.

The user's  UserId ,name and TenantId (also used as namespace) is stored in the Users Model

After user log's in through Google , We Query this Model to Find the Namespace of the logged in User, Once found we set it and use it for reading / storing entities in their respective  namespace.

My Question is What could go wrong with this approach ?, and do we have any better solution for handling Multiple Tenants with Multiple User Accounts.
We need to do this without using Sub Domain Names and URL Paths (Containing the namespace id or key)


 I have done things a litle different. I have created a unique user for login purpose on the empty namespace. After that i used this "universal" user id to make a link with a namespace aware user. So basicly i have 1 x N relationship without the need to keep the Tenants id on entities.

 Another thing I have done on empty namespaspace is keeping record for all of them. So I have a Namespace entity which stores namespace data. I two strategies to map tenants:

1) Google Apps. If client wants a personal domain, I use it to map to a desired namespace

2) My subdomain. So the foo.mydomain.com would make the client access the "foo" namespace

The only problem with this approach is that in both you must configure your subdomain on Google Apps, and maybe that is why you are avoiding this approach.
 

3. We also need to have (CRON) Jobs which will run at a minimum of 3 times a day to Query Some Entities and Update Some and Send the Report to the Tenants users. In this case we would have to Query the meta data to get list of namespaces, and then for each namespace query the desired entities.
This would increase the cpu and memory consumption, is there any better way to run CRON on multiple namespaces.


I fact i use same approach. The only diffence is that my cron query namespace metadata and starts a Task Queue on each, once this api is namespace aware. Of course there is the cost of this cron job, but compared to tasks, it is little most of times.
 

Any help will be highly appreciated.

Thanks
Sarfaraz



This is an excelent post and I will be reading further answers.

 Regards,
 Renzo
 


.














Alejandro Gonzalez

unread,
Apr 23, 2014, 3:27:27 AM4/23/14
to google-a...@googlegroups.com
Hello!

In the new console, the datastore viewer has been improved. There, the namespace selection is made through a nice autocomplete input rather than a combo select, which is useless when you have a lot of namespaces.

As Renzo says, i consider very useful storing some entities in a common namespace, having a NamespaceEntity stored in a common namespace will help you to find the namespace of a particular user given his email. 

For executing maintenance/report task agains all namespace, again im following the same approach as Renzo, having the CRON calling a servlet, which iterates over the namespaces and launch a task for each one. This way you can control each task for each namespace separately.

Cheers!

aswath satrasala

unread,
Apr 23, 2014, 7:23:50 AM4/23/14
to google-a...@googlegroups.com
Hello,


On Tue, Apr 22, 2014 at 6:36 PM, SMF <sarfaraz...@gmail.com> wrote:
Hi there

I have a few basic questions

1. If I have 1000+  Namespaces, how will they get displayed in the App Engine Admin Console (Datastore Viewer),
Right now I have few and they are displayed in a dropdown box.
We have lots of namespaces 2000+.  Currently, in the appengine admin console, the namespace is selected by a suggestbox style (auto complete).  
If there are fewer namespaces, it is displayed in a dropdown.  


2. I have a Multi-Tenant app where each tenant has its own namespace. the model and entities related to the tenant is within their respective namespace except for the User entities each tenant can have multiple users.
thats why all users are stored without any namespace.

The user's  UserId ,name and TenantId (also used as namespace) is stored in the Users Model

After user log's in through Google , We Query this Model to Find the Namespace of the logged in User, Once found we set it and use it for reading / storing entities in their respective  namespace.

My Question is What could go wrong with this approach ?, and do we have any better solution for handling Multiple Tenants with Multiple User Accounts.
We need to do this without using Sub Domain Names and URL Paths (Containing the namespace id or key)
We do similar things.  For every user/company, we create a namespace name and store in a separate model in the empty namespace.  Every time, the request comes, we check the logged in user, and then get the namespace from the model and set the namespace.
We use GWT and Objectify.  Every rpc, we check who logged in and set the namespace using the NamespaceManger. We have issues dealing with the Objectify keys while doing the rpc's using this namespace approach.  We got workaround those, and going on.  We modified the objectify jar and moving on.
You can star the issue, if you are using GWT.
 


3. We also need to have (CRON) Jobs which will run at a minimum of 3 times a day to Query Some Entities and Update Some and Send the Report to the Tenants users. In this case we would have to Query the meta data to get list of namespaces, and then for each namespace query the desired entities.
This would increase the cpu and memory consumption, is there any better way to run CRON on multiple namespaces.
We do this way also sometimes and works for small tasks.  If you are doing large processing within each namespace, then the 10 min task time out can happen.  We have faced this while processing large data with in the namespace, so we did workarounds like use backends to run the task. 
 

Any help will be highly appreciated.

Thanks
Sarfaraz




.














--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages