I am new to web2py and google app engine, i tried to develop simple CRUD operations web2py application have one database table like db.regiser and deploy this application in google app engine in two different regions and now i need to create the namespaces for this application database to access the two different regions users to perform the CRUD operations on their own namespaces without affecting the main db, and how to create the namespaces to the database for web2py application.
I don't think it's in the documentation (though it is noted in the scaffolding app code), but you can specify the namespace in the connection string:
db = DAL('google:datastore+ndb://mynamespace')
Also, as a possible alternative, note that the web2py DAL includes its own multi-tenancy functionality. Using this method, your code would be portable should you choose a different hosting/datastore option in the future.
Related
In Naming Developer Environments Google suggests 2 approaches for implementing different CI/CD environments for GAE apps
based on different services (which used to be called modules) inside the same project/app:
If you choose to create your microservices application by using only
multiple services, you can create a single App Engine project for each
of your environments and name them accordingly, such as web-app-dev,
web-app-qa, and web-app-prod.
based on different projects/apps:
Alternatively, if you choose to create your microservices application
by using multiple projects, you can achieve the same separation
between environments, but you'll need to use more projects, such as
web-app-dev, web-app-prod, user-service-dev, and
user-service-prod. You will need to use code patterns to ensure that
the dev projects only call other dev projects and the prod
projects only call other prod projects.
The phrasing in the above documentation snippets appears to suggest the 2 approaches would be roughly equivalent, but there is at least one significant difference between the 2 approaches: a project/app based approach ensures data isolation, while a service/module based one does not - the datastore and memcache are shared by all services.
A more detailed comparison between the 2 approaches from the isolation perspective is documented in Comparison of service isolation and project isolation:
The following table provides a comparison between using multiple
services and multiple projects in a microservices architecture:
My question is: apart from the above-mentioned differences, are there other advantages of using the project-based approach versus the service-based one? Or anything that may be considered a disadvantage?
The project based approach also allows you to separate billing concerns, and IAM roles.
You could go as far as having different credits cards charged, or just set billing limits independently (who wants prod to go down because a dev bug exceeded your billing limit?). You'll also get separate billing reports, so we can determine what prod vs dev cost you more easily.
The service based approach potentially minimizes additionally administrative work. For example, if for some reason you needed to set up VPNs or other networking aspects, a single project means you only need to configure it once, rather than once per project.
I am working on a system on GAE that includes app server, Datastore, a mobile app and a web client.
My each customer will need to have a customized (separate) app server, datastore, mobile app and a web client. I am not able to find any information on how I should design my system:
[Option A]:-Separate project for each customer, hence app server and datastore will be available exclusively for that customer. In the sense, do I need to clone my base project for each of my customers and then customize to have separate datastore and appservers ?
OR
[Option B]:-Same project with different versions of application for each customer. In this case, can I have individual (exclusive) data store and app server for each customer? In the sense, I want a separate datastore and app server for each customers. I am not sure if I can take advantage of using different datastore buckets for different customers for my requirement.
I could not find any reference link addressing my problem.
Any help will greatly be appreciated.
Thanks in advance!
You should consider App Engine's native support of multitenancy. If this is not good enough for your requirements, then you will have to create a separate project for each customer. The Datastore for a single project is shared across all versions, so you will not be able to segment it (unless you are ok using namespaces as described in the linked doc).
I would also recommend making sure that you actually need to have separate applications running for each customer. Unless you sign up for a premier account, you have a limited number of projects that you can create. Besides that, it will most likely make management of those apps much more difficult for you.
I'm wondering what the basic protocol is for storing users in a database, creating accounts, and authenticating them - with ASP.NET MVC 3 framework (using C#), and Azure SQL.
More specifically:
1.) Where in an ASP.NET C# MVC3 Visual Studio project do I write code that only runs on the back-end? Such as logging into my database as an admin, so I can write to and read from the database.
2.) Where should I make database calls from using MVC framework? Do I call a back-end function (e.g. - to create a new account in the database) from the controller?
Thanks for any help!
I'm not 100% sure whether you are talking about SQL Users or Application users.
However, generally, what ASP.Net MVC applications do is:
they use one or two defined users to connect to the database (e.g. they might define a read-write and a readonly connection for different types of queries)
they use the ASP.Net Membership API for application-level user accounts
they use an ORM framework like NHibernate or Entity Framework for other database access
There are lots of tutorials and articles for this sort of information out there - one place to look might be Scott Hanselman's blog - see:
a tutorial on using ASP.Net Membership with SQL Azure
the Mix11 tools walkthrough - including Code First Entity Framework
1) You could use Membership (which I used to use) or simply write your own Authentication code. There are 2 drawbacks with Membership. First, there are a ton of tables and stored procedures that are installed but worse, there's no way to change a user name via the Membership API. Try telling a customer that they cannot change their username (which is usually their email address) and they'll give you weird looks.
2) Forget EF and use your own repository, which simply harnesses SPROCs. Go ahead, make a ton of changes to your EF design canvas, change the db schema, and I can guarantee you will run into issues with the "behind the scene" files at one point or another.
I currently have a Grails application I'm evaluating to port to Google App Engine and I'd like to know experiences regarding:
Acegi security: the application relies on this library to enforce the security (update: just learned that it's based on hibernate so can't be ported; any recommended replacements?).
Use of JPA or JDO instead of the hibernate plugin (I'll have to migrate the Domain classes); which one is better ?
I have a growing number of pre-generated pdf files I keep uploading; is there any foreseeable problem with this?
Thanks in advance.
This isn't the answer you want, I'm sure, but I spent some time exploring Grails on GAE and finally came to the conclusion that it's not a good fit. By the time you give up (or work around) the native Domain capabilities, forego many of the plugins, and deal with the host of other minor incompatibilities, you've essentially wiped out most of the productivity advantage of Grails. I'd consider a standard J2EE, a compatible framework, or possibly a GWT based app for GAE. If you want to stick with Grails, I'd host it on AWS or a dedicated J2EE hosting provider.
That said, I hope the integration eventually works cleanly because GAE is a pretty cool engine/model.
You may also be interested in Gaelyk (http://gaelyk.appspot.com/) Gaelyk is a lightweight wrapper which enables you to deploy applications written in Groovy to the App Engine.
Gaelyk offers a lot of the advantages of Grails including:
standards for Views, Controllers
flexible URL routing
plugin system
It has simple wrappers for the App Engine (including datastore access and coercion to POJO/POGOs, email, memcache, Jabber & more)
(although it doesn't include internationalisation, CRUD scaffolding or a HQL type query wrapper)
As it is more lightweight it doesn't have the performance issues on App Engine that Grails does and now that you can reserve instances
http://code.google.com/appengine/docs/adminconsole/instances.html#Always_On it is possible to remove the startup time problems!
I wrote a blog series about my experience with Grails on App Engine. It discusses most of your questions.
What is the current status of grails and google app engine deployment. I am new to app engine but wonder worth exploring it. Some specific qns are
the latest plugin, which has high user rating, has any restrictions? or it work seamlessly with all gorm features
is there any issue with high startup time for grails application. How is it in real world scenario? (with a typical small and large scale application)
what about other grails plugins (like, shiro, joda time, nimble etc). I guess they wont play well. So using those libraries directly is the better option
If decided to give up goole-app as a deployment option, how easy to switch to a normal environment. The JPA support ensures the compatibility with other traditional DBs?
Not sure what else are major issues.. probably, this is the foundation for a good discussion.
thanks.
I got few good response from grails mailing list, and the conclusion shares the comment by David. see the thread here
Couple of relevant responses:
From Tomas Lin:
I would suggest looking into Gaelyk if you really want to build a
project on the App Engine. It is built from the ground up with the App
Engine as the target engine, so it can bypass problems like long
loadtimes due to Spring and Hibernate. The newly introduced plugin
mechanism guarantees that your Gaelyk applications can be extended in
a way guaranteed to work on GAE.
Gaelyk has it's own native entity persistence DSL, which is a little
cleaner that the JPA/JDO abstractions on top of the App Engine.
I currently see many HardDeadlineExceeded exceptions with the App
Engine and Grails. It is just not designed to work well with Spring
right now. Hopefully this will improve with the later releases of
Groovy, Grails and the Spring / Google partnership for GAE for
business, but I wouldn't consider Grails on GAE production ready.
Even with Gaelyk, there are reports of slow performance. So imagine
the difficulties that arise with the much bigger Grails stack.
The app-engine comes with it's own implementation of a user / security
management system based on GMail accounts. If you just want to provide
an admin / non-admin implementation, this is supported in the
appengine configuration. Cannot comment on Shiro.
Be aware that one of the major restrictions of the App Engine is the
inability to write a file, so even basic file uploading in Spring
becomes problematic since the default mechanism writes to a temporary
file. I would imagine that most of the plugins would not work out of
the box without digging into their code and changing it.
I think the biggest issue here is lack of support for native JDBC. JPA
is not as well supported as plain JDBC GORM, things like named queries
would probably not work out of the box without retrofitting. If you
want to use the latest and greatest parts of Grails, it might be
worthwhile to consider other hosting solutions.
From Aaron Eischeid
1.The GAE plugin and the JPA-GORM plugins combined do not get you all GORM features seamlessly. Though you should get basics like .save(), .delete(), and maybe .list() the dynamic finders etc. are going to be out (at least for now). I could be way off here, but I think most/all Hibernate dependent features are out or replaced by something else (since it relies on SQL under the hood and GAE doesn't currently have SQL based DB...) so for example any criteria builders are a no go. It is unclear to me how much of the dot drilling you can do on objects. For example, not sure if you could do something like:
def b = new Book()
def stores = b.authors.publishers.bookstores
One place I could use some pointers is how to use JPA in the domain classes. I am sure there is good info out there, but I just haven't found it yet.
unsure
grails plugins that include domain classes or manipulate your current domain classes are bound to have issues since you have to construct your domain classes differently to play nice with JPA which is necessary because Googles Datastore isn't quite like a relational DB. On the flip side. you can use Google's built in security so you shouldn't necessarily need plugins like Acegi or Shiro.
This probably boils down to the different levels of GORM that you can use in controllers and services and the different ways you define domain classes. Some refactoring seems inevitable unless JPA plays just as nice with SQL DB's as it does with Googles Datastore. If JPA can move like that then transferring should be easy, but by using JPA-GORM you give up some stuff you would probably want if you weren't benefiting from due to being on GAE.
Eager to hear what others have to say,
Aaron