This question comes from working on my webapp, a feed reader written in Go. The code is available at http://github.com/matthewbauer/rivulet although that should not be necessary to answer the question.
I have a webapp written in Go that is running on Google's App Engine. It uses the usual common App Engine libraries like datastore, memcache, and user.
Is there any way to let my users run this app on their own without breaking App Engine compatibility?
Go now provides build constraints that exclude/include files based on target build platform:
// +build !appengine
So, I know that this is possible. But, my biggest problem is with my libraries that depend on App Engine: datastore, memcache, and user. I know other libraries provide datastore and memcache, and I can implement user on my own, but how would I go about wrapping it up?
I know that I can have them set up a development server with the SDK, but that might be too involved for some users. I want a single executable that normal Go projects provide. IS that possible?
If any examples exist, I haven't found them yet; any examples of App Engine independent webapps would be appreciated. I can learn by example.
You will probably have refactor your code.
The basic rule of thumb will be anywhere you depend on an AppEngine package define your own interface for the way you use it. This will allow you decouple the app from the appengine libraries.
Once you've defined those interfaces then you can start providing alternatives that satisfy the interfaces. You'll be able to plugin any Datastore or Memcache that satisfies the interfaces and your app will be able to both run on appengine or as a standalone with the alternatives.
Related
I have a website on AppEngine that is 99% static. It is running on Python 2.7 runtime. Now the time has come to evolve this webapp, and since I have almost none Python code in it, I'd prefer to write it in Go instead.
Can I change runtime from Python 2.7 to Go, while keeping the project intact? Specifically, I want to keep the same app-ID, the same custom domain attached to it, the same SSL certificate, and so on.
What do I have to do in order to do that? I surely have to change runtime in the app.yaml. Is there anything else?
Bonus question: will such change happen without a downtime?
I'd be grateful for any links to documentation on exactly that (swapping runtime on a live app). I can't find any.
Specify a runtime as well as a new value for version. When deployed you'll have an older version that is Python and a newer version that is Go. There won't be any downtime (same as when deploying a newer version of Python).
Rather than trusting links/docs (that may be out of date or not 100% exactly what you're trying to do), why not create a new GAE-Std project for testing purposes and try it yourself. Having a GAE-Std test project is good for testing new function (especially by other testers who won't have access to the dev environ on your laptop).
The GAE services offer complete code isolation. So it should be possible to simply deploy a new version of the service, which can be written in a different language or even use a different GAE (standard/flex) environment. Personally I didn't go through a language change, but I did go through a split of a single-service app into a multi-service one, I see no reason for which the same principles wouldn't apply.
Maybe develop the new version as a separate app first, to be able to test it properly without risking an accidental impact on the old version and only after that bring the code as a new version in the old app. That'd be using the GAE project isolation. You can, in fact, test the entire version migration as a separate app if you so desire without even touching the existing app. I am using this technique - a separate app ID - to implement a staging environment for my app, completely isolated from my production app, see How to copy / clone entire Google App Engine Project
Make sure to not switch traffic to the new version at deployment time. This keeps the app working with the old version. Test first that the new version works as expected using Targeted routing. Then maybe use Splitting traffic across multiple versions to perform A/B testing with just a small percentage of the traffic going to the new version. Finally, when happy with the results, switch all traffic to the new version.
You need to pay special attention to the app-level configs (dispatch, cron, queue, datastore indexes), shared by all services/versions. They need to be functionally equivalent in the 2 versions. The service isolation doesn't apply to them, only project isolation can ensure no impact to the old version.
There should be no need to make any change to the app ID, custom domain mapping or SSL config. The above mentioned tests should confirm that.
A few potentially interesting posts related to re-working services/modules:
Converting App Engine frontend versions to modules
Google App Engine upgrading part by part
Migrating to app engine modules, test versions first?
Advantages of implementing CI/CD environments at GAE project/app level vs service/module level?
I have implemented a simple API in Go on Google App Engine Standard using just:
func init() {
http.HandleFunc("/api/v1/resource",submitResource)
}
Nothing special. However I want to port this code to using Cloud Endpoints instead in order to get the better monitoring and diagnostics.
Is it even possible with STANDARD instances or must I move to FLEXIBLE?
I can't find any documentation on this. Nor answers to this seemingly simple question. At the moment I half wish I had chosen Python because its support seems more mature. I chose Go because it seems more appropriate for API-like code because my minimal research suggested Go offered better performance.
If it is possible, are there any pointers to how please?
Only Python and Java are supported on GAE Standard via the Endpoints Frameworks. However, Go is supported on GAE Flexible.
Here is the Go GAE Flexible sample:
https://github.com/GoogleCloudPlatform/golang-samples/tree/master/endpoints/getting-started
After much research and trial and error, the simple answer is "No." - as of Dec 2016.
The longer answer is it's possible if you want to put far too much effort into making up to date libraries of your own. There is basically no support, even in alpha, for the current Google Cloud Endpoints using Go with Google App Engine Standard.
It's possible to run Go+endpoints on GAE Standard environment, however libraries might be outdated now.
Libraries and sample app can be found on github:
https://github.com/GoogleCloudPlatform/go-endpoints
I have successfully deployed "Greetings" as AppEngine SE app, and it works.
I have this application that will be run in a local network where a number of devices should interact with a database. I could use xampp and go for CherryPy or any other Python framework (Python is usually my choice) but it is the sum of a lot of different things: Python, Apache, MySQL... With GAE, which I have previously used in a number of applications successfully, I feel everything is neatly packed in a single box. Thay may not be true, but using the Google App Engine Launcher to create a local working copy of an app couldn't be easier.
But is it reliable? Should it be used like that? I know it's intended for development, so I'm unsure about using it as a local server in production. A few versions ago there even was this nasty bug that flushed the local datastore from time to time. But it seems that they fixed it and now data persists.
Would you recommend GAE for an application running in a local network or should I stick to LAMP (P for Python)?
Other alternative is http://code.google.com/p/appscale/.
May be you can check the the project TyphoonAE. I think it is exactly what you need.
The TyphoonAE project aims at providing a full-featured and productive
serving environment to run Google App Engine (Python) applications. It
delivers the parts for building your own scalable App Engine while
staying compatible with Google's API.
I have created a GWT application and now want to deploy it outside GAE. The reason I wish to deploy outside the GAE is the Sandbox security feature of GAE, which disallows me from writing files to my system. I store my data in the form of an ontology (.owl file) under my '/war/WEB_INF' and I want the end user to be able to modify (write to / save) this file through the server.
I understand that GAE does not let me do this, but is there a paid Google Service (e.g. google apps) that would allow hosting a GWT application which would allow writing files to the system? For instance, like an add-on to GAE?
If not, what solution would you recommend to host a GWT application (that would let me write a file to the WEB-INF folder) on the web?
EDIT: I solved this by deploying the GWT project as a .war file and hosting in TomCat.
I'm very new to GAE, but in case you haven't looked at their experimental write/read blobstore services you can check that out here. They have a similar API for python I believe. It's ofcourse stored on the GAE blobstore and not under /war/WEB-INF/ directory but It does allow a possible solution to what you're looking for.
Also, if you're looking to run your own server (possibly on EC2 for example), then you might want to look into AppScale. But I, personally, would stay away from that as a solution because I highly doubt that AppScale performs as well as google's GAE web servers and furthermore lacks the same degree of support/development.
Have you ruled out something like creating an Owl Entity to hold your ontologies, and arranging for *.owl requests to be handled by using that as a key name to find and serve the corresponding Owl? That's really simple code.
GWT is primarily a client side technology. GAE is a server side technology. You seem to be getting GWT and GAE engine mixed up with each other. GAE can work with almost any client side technology, and GWT can connect to many different back end platforms.
Are you trying to move your back end code directly to a new platform? Are you planning on rewriting the back end for a new platform, but keep the GWT code? What is your goal for this application? To be used by you and a few friends, or by thousands of people? For free or paying customers?
If you want to move off of AppEngine, you can switch to pretty much any java hosting service that you want - anything from a tiny shared VPS up to a Amazon EC2 mini cloud of your own. I don't think google offers generic java hosting. I don't know how you have built your application's back end, but you probably used servlets, which you should be able to get working pretty much anywhere.
If you want to stay on AppEngine, you should think about whether or not you can break your owl file into smaller sections that can be stored as entities in the database.
Whichever platform you choose, if you are planning on serving more than a few people, you will need some way to prevent one giant owl file from becoming a huge bottleneck.
Is it possible to run executable files in google app engine? Like by using Runtime.exec?
There is whitelist on google app engine documentation which list classes that can be used but functions/ inside the classes are not specified.
No, absolutely not.
The only thing that make AppEngine possible is that both the Python and Java environments are controlled by Google so that performance/scability and security issues are minimized. They don't even allow to use all the standard Java/Python classes, so imagine the problems that could arise if they let people run any executable file. One may even be a virus!