Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to start discussion? #9

Closed
surfer26th opened this issue Aug 3, 2012 · 12 comments
Closed

How to start discussion? #9

surfer26th opened this issue Aug 3, 2012 · 12 comments

Comments

@surfer26th
Copy link

Bernardo -

This is not an issue perse, but more a question about communications about this project. What you are doing is very important for SaaS apps, and I have forked the code and started to explore it for my own SaaS development. There does not seem to be a place for communications on django-tenant-schemas, like a forum. Has there been one set up? I think some sort of forum could really generate a lot of interest and positive contributions.

I'm interested in using the code, but would like to get it to work with Django's built-in authorization/authentication. I've looked at Django simple multi-tenant and this blog: http://www.loggly.com/blog/2009/12/django-middleware-munging/ , so I think with a little effort, we can get some good authorization/authentication supported leveraging existing stuff.

Also, it would be great to use it with Django contrib.admin. With the current setup using your public token, the code will need some small work to enable that.

Thanks,

Ted (surfer26th@gmail.com)

@bernardopires
Copy link
Owner

Hi Ted,

thanks for your feedback! There should be nothing stopping you from using django's built-in authorization/authentication. In fact, I'm using it in my project. Are you having any troubles? I'll gladly help. :)

You are not forced to use the token, you can just leave it unset and you should be good to go to use the admin.

About the forums, I'm not entirely sure if it would help. I think most of the people are too lazy to create a forum account and most of them already have a git accout. But of course, if you have the time I'd love if you could create a forum for us. Many thanks in advance.

Cya!

@surfer26th
Copy link
Author

Hi Bernardo,
Very much appreciate you getting back to me. I'm just starting to add the multi-tenant and AA capabilities to my app which is still on my development system. So, I am happy to hear that you are using the built in AA successfully. I haven't yet started on it, but am planning on linking the Client model to User via a foreignkey. I assume that you have done just that.
With respect to the Token, instead of using a PUBLIC TOKEN, I created a PRIVATE token and am doing the same thing you have done, but instead of adding the token to the public path (i.e. using a 'main' token and adding it to the public path) I am adding a 'private' token. I modified the middleware to accomplish this and am just mirroring your code but adding the token to the private path. So, any tenant will have the path /private/tenantname... That way, I can use the built-in admin without any problems.  I am curious about your thoughts on that approach, and whether you think I will encounter any problems. I may encounter a problem with your url resolvers, which I haven't thought through yet.
With respect to adding a forum, I may be willing to help host that once I make further progress on my development. I am by no means a master python/django guru, which makes me a bit hesitant. But I would love to contribute back once I get some more experience under my belt. 
Once again, I cannot say enough how important the project is that you helped resurrect. I cannot find another one in the django world that accommodates my needs better.
Regards,
Ted
--- On Fri, 8/3/12, Bernardo Pires reply@reply.github.com wrote:

From: Bernardo Pires reply@reply.github.com
Subject: Re: [django-tenant-schemas] How to start discussion? (#9)
To: "Ted Chen" surfer26th@yahoo.com
Date: Friday, August 3, 2012, 1:41 AM

Hi Ted,

thanks for your feedback! There should be nothing stopping you from using django's built-in authorization/authentication. In fact, I'm using it in my project. Are you having any troubles? I'll gladly help. :)

You are not forced to use the token, you can just leave it unset and you should be good to go to use the admin.

About the forums, I'm not entirely sure if it would help. I think most of the people are too lazy to create a forum account and most of them already have a git accout. But of course, if you have the time I'd love if you could create a forum for us. Many thanks in advance.

Cya!


Reply to this email directly or view it on GitHub:
#9 (comment)

@bernardopires
Copy link
Owner

Hi Ted,

thanks again for your feedback! What do you mean with client? Do you mean tenant? If that is the case, I think you misunderstood a little how this app works. The client can always be deduced from the URL. You don't need a foreign key because you only have access to the current tenant's schema. The data of the tenants are all separate.

On a previous version I did have a private token instead of a public token. I did have some problems because of the URL routers and apps being used on tenant schemas. I still haven't thought of a better solution. However, any problems you encounter feel free to write here and we will think of something. :)

Cheers,
Bernardo

@surfer26th
Copy link
Author

Bernardo,
By "Client", I meant to refer to the model in your wiki example whose parent class is TenantMixin. I haven't thought through this entirely, but I am tempted is to link via a Foreign Key on the Client to the User class in the built-in authorization/authentication. I understand that I don't necessarily need to do that to understand the name of the tenant in the path. I do need to have a way to create permissions among multiple users within each Tenant. Also, I want to grant admin rights to one or more of those users. Basecamp uses a scheme which is similar to that which I am thinking.
By linking in the Class(TenantMixin) object to the User class will give me a lot of flexibility.
Thanks for mentioning your experience with the private token. I'll be looking out for the issues you cited. Once I make more progress on the AA, I'll get back to you about what I do in that regard, as well as what I find out more about using a Private token.
Regards,
Ted

--- On Sun, 8/5/12, Bernardo Pires reply@reply.github.com wrote:

From: Bernardo Pires reply@reply.github.com
Subject: Re: [django-tenant-schemas] How to start discussion? (#9)
To: "Ted Chen" surfer26th@yahoo.com
Date: Sunday, August 5, 2012, 1:24 AM

Hi Ted,

thanks again for your feedback! What do you mean with client? Do you mean tenant? If that is the case, I think you misunderstood a little how this app works. The client can always be deduced from the URL. You don't need a foreign key because you only have access to the current tenant's schema. The data of the tenants are all separate.

On a previous version I did have a private token instead of a public token. I did have some problems because of the URL routers and apps being used on tenant schemas. I still haven't thought of a better solution. However, any problems you encounter feel free to write here and we will think of something. :)

Cheers,
Bernardo


Reply to this email directly or view it on GitHub:
#9 (comment)

@bernardopires
Copy link
Owner

Hi Ted,

oh I think I now understand what you ment. You want your tenants to also be able to login (to some sort of tenant control panel) from your main domain and not from the tenant subdomain, that's why you need a foreign key on your client to the user class, right? Yeah, feel free to add whichever models you want to the tenant model, but remember that they are only being selected from the public schema. Any problems you have feel free to write an issue! :)

Cheers,
Bernardo

@surfer26th
Copy link
Author

Bernardo,
I have been taking advantage of tenant_schemas in my code and am now pushing to the cloud. Looking at dotcloud and heroku. In looking at Heroku, I stumbled upon this comment in their FAQ. I'm wondering if you have a view on this.:Yes, Heroku Postgres supports multiple schemas.The most common use case for using multiple schemas in a database is building a software-as-a-service application wherein each customer has their own schema. While this technique seems compelling, we strongly recommend against it as it has caused numerous cases of operational problems. We have seen that even a moderate number of schemas (> 50) can severely impact the performance of Heroku’s database snapshots tool,pg:backups.Thanks,
Ted

--- On Sun, 8/5/12, Bernardo Pires reply@reply.github.com wrote:

From: Bernardo Pires reply@reply.github.com
Subject: Re: [django-tenant-schemas] How to start discussion? (#9)
To: "Ted Chen" surfer26th@yahoo.com
Date: Sunday, August 5, 2012, 1:49 PM

Hi Ted,

oh I think I now understand what you ment. You want your tenants to also be able to login (to some sort of tenant control panel) from your main domain and not from the tenant subdomain, that's why you need a foreign key on your client to the user class. Yeah, feel free to add whichever models you want to the tenant model, but remember that they are only being selected from the public schema. Any problems you have feel free to write an issue! :)

Cheers,
Bernardo


Reply to this email directly or view it on GitHub:
#9 (comment)

@bernardopires
Copy link
Owner

Hi Ted,

I did a small research about your concerns because I myself haven't had any big problems so far. Apparently the whole problem is around pg_dump, which for every call needs to scan all tables in the database. So if you are calling pg_dump for each schema, it will be highly inefficent (assuming you have n schemas with m tables each, you'd scan in total n_n_m tables). I assume this is how Heroku's pg:backup tool works, that is, it uses pg_dump.

Here's the thread I based my reply on: http://postgresql.1045698.n5.nabble.com/Thousands-databases-or-schemas-td5731189.html

I myself use amazon AWS for my solution and I right now I only have 4 schemas, so I haven't had any big troubles. Anyhow, even if I had more schemas, I shouldn't have the problem you mentioned because my backups are all file-system backups (amazon incremental snapshots), so it's extremely fast and doesn't depend on postgresql at all.

There should be however no problem with performance on Heroku besides any tools that rely on pg_dump. So if you can find an alternativate with Heroku for the backups you shouldn't be concerned.

Cheers,
Bernardo

@surfer26th
Copy link
Author

Thank you for your reply Bernardo! I have pushed my code to dotcloud's sandbox and am thinking about doing the same into Heroku's sandbox. I need to use dotcloud's paid service to exercise schemas for subdomains, however, so I will likely need to cough up some money sooner than I had hoped. For me, it will likely be between dotcloud and Heroku for production.
Ted

--- On Wed, 11/14/12, Bernardo Pires Carneiro notifications@github.com wrote:

From: Bernardo Pires Carneiro notifications@github.com
Subject: Re: [django-tenant-schemas] How to start discussion? (#9)
To: "bcarneiro/django-tenant-schemas" django-tenant-schemas@noreply.github.com
Cc: "Ted Chen" surfer26th@yahoo.com
Date: Wednesday, November 14, 2012, 12:42 PM

Hi Ted,

I did a small research about your concerns because I myself haven't had any big problems so far. Apparently the whole problem is around pg_dump, which for every call needs to scan all tables in the database. So if you are calling pg_dump for each schema, it will be highly inefficent (assuming you have n schemas with m tables each, you'd scan in total n_n_m tables). I assume this is how Heroku's pg:backup tool works, that is, it uses pg_dump.

Here's the thread I based my reply on: http://postgresql.1045698.n5.nabble.com/Thousands-databases-or-schemas-td5731189.html

I myself use amazon AWS for my solution and I right now I only have 4 schemas, so I haven't had any big troubles. Anyhow, even if I had more schemas, I shouldn't have the problem you mentioned because my backups are all file-system backups (amazon incremental snapshots), so it's extremely fast and doesn't depend on postgresql at all.

There should be however no problem with performance on Heroku besides any tools that rely on pg_dump. So if you can find an alternativate with Heroku for the backups you shouldn't be concerned.

          —

          Reply to this email directly or view it on GitHub.

@bernardopires
Copy link
Owner

You could also check amazon's AWS free tier if you have the time to fiddle with server configurations. I used an image that already had postgresql, django and apache installed. It's from bitnami, I'll send you the link if you are interested. You have full root access to the server on amazon, so you can do pretty much anything you want with it. I had no problem setting up apache to route all subdomains to my django project so I don't have to setup any subdomains manually.

@surfer26th
Copy link
Author

Bernardo,
Thank you for the tip! Since I'm a one man band and trying to start a business, I am concerned about going anywhere other than a PaaS site (like dotcloud and Heroku) for maintenance purposes. I keep on hearing that one needs to play sys admin a fair amount of time if one goes the IaaS route. On the other hand, I keep on hearing it's pretty straightforward getting things up on an IaaS like AWS, slice, etc.
However, getting up on dotcloud is probably going to run me $60-$70/month min even with few customers for the amount of memory I need and SSL frontend. So, I may re-consider. I would be interested in hearing your experiences on AWS over time.
Best regards,
Ted
--- On Wed, 11/14/12, Bernardo Pires Carneiro notifications@github.com wrote:

From: Bernardo Pires Carneiro notifications@github.com
Subject: Re: [django-tenant-schemas] How to start discussion? (#9)
To: "bcarneiro/django-tenant-schemas" django-tenant-schemas@noreply.github.com
Cc: "Ted Chen" surfer26th@yahoo.com
Date: Wednesday, November 14, 2012, 1:12 PM

You could also check amazon's AWS free tier if you have the time to fiddle with server configurations. I used an image that already had postgresql, django and apache installed. It's from bitnami, I'll send you the link if you are interested. You have full root access to the server on amazon, so you can do pretty much anything you want with it. I had no problem setting up apache to route all subdomains to my django project so I don't have to setup any subdomains manually.

          —

          Reply to this email directly or view it on GitHub.

@bernardopires
Copy link
Owner

Hi Ted,

you are definitely right that it will be extra work to get everything working under AWS, but it should be worth on the long run, specially if you are short on cash and want fine grained control over everything on the server.

This is the image I used to get everything up and working quickly: http://bitnami.org/stack/djangostack. I also try to use the most amazon services I can. I don't like reinventing the wheel and that saves time. So I use Amazon's Route 53 for DNS and Amazon's SES for sending e-mails (there's a neat app called django-ses that makes everything pretty easy). So I didn't have to worry about setting my own email server up, which would be a huge pain in the ass.

There was an additional factor that I considered when picking amazon that was that they had servers in São Paulo, in Brazil, where all my clients are located. Pretty much all services like Heroku only support servers in the US. Amazon has servers everywhere, US, Europe, South America, Asia, Australia.

If I were you, I'd make some sort of pros/cons list and try to figure it out if the extra bucks on Heroku are worth it. If I had the money and if they had servers in Brazil I think I'd have picked Heroku.

Cheers,
Bernardo

@surfer26th
Copy link
Author

Hi Bernardo,
I will definitely investigate what you have done and will look at AWS more seriously. Last night I started really exercising my app in dotcloud -- loading CSV file into the DB and trying to do an html view of the data. I'm getting connection timeouts loading and viewing. I'm getting very discouraged with them.
Thank you Bernardo!
Ted
--- On Thu, 11/15/12, Bernardo Pires Carneiro notifications@github.com wrote:

From: Bernardo Pires Carneiro notifications@github.com
Subject: Re: [django-tenant-schemas] How to start discussion? (#9)
To: "bcarneiro/django-tenant-schemas" django-tenant-schemas@noreply.github.com
Cc: "Ted Chen" surfer26th@yahoo.com
Date: Thursday, November 15, 2012, 1:52 AM

Hi Ted,

you are definitely right that it will be extra work to get everything working under AWS, but it should be worth on the long run, specially if you are short on cash. This is the image I used to get everything up and working quickly: http://bitnami.org/stack/djangostack. I also try to use the most amazon services I can. I don't like reinventing the wheel and that saves time. So I use Amazon's Route 53 for DNS and Amazon's SES for sending e-mails (there's a neat app called django-ses that makes everything pretty easy). So I didn't have to worry about setting my own email server up, which would be a huge pain in the ass.

There was an additional factor that I considered when picking amazon that was that they had servers in São Paulo, in Brazil, where all my clients are located. Pretty much all services like Heroku only support servers in the US.

If I were you, I'd make some sort of pros/cons list and try to figure it out if the extra bucks on Heroku are worth it. If I had the money and if they had servers in Brazil I think I'd have picked Heroku.

Cheers,

Bernardo

          —

          Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants