Vaadin 10 and AppEngine

Hello,

Will Vaadin 10 work with Google AppEngine? I have some dependencies around datastore and am looking to migrate away from GWT.

Thanks,

E

Hi,

GAE is not supported, at least right now. This might change if they improve their persistence options, but currently if you want to use GCP, you’ll need to stick to GCE.

-Olli

Olli, thanks for the response. What exactly is the shortcoming of the persistence options? I’ve had great success with Datastore/Objectify and also with their CloudSQL offerings. Which pieces of Vaadin require persistence?

Thanks!

According to my (limited) understanding, it’s not so much the application-level persistence but more about how GAE doesn’t support session persistence / sticky sessions or session migration between nodes, and other things of that nature.

AppEngine does support session, just not by default. You’ve got to add:

<sessions-enabled>true</sessions-enabled>

to the AppEngine configuration but otherwise it slamms the data into Datastore/Memcache and will sling it around as necessary.

Hi,

that’s not enough; that won’t cover things like sticky sessions, costless session migration between nodes or a mechanism for preventing concurrent access to the same session.

-Olli

And using memcache to persist the session?
It’s replicated between nodes, and pretty fast

Olli, sticky sessions are not needed on GAE as the sessions are persisted to the Datastore which all nodes already have access to: https://stackoverflow.com/questions/10640120/how-do-i-implement-server-affinity-or-sticky-sessions-on-app-engine

What do you mean with costless session migration?

Vaadin apps store application state on the server (although TypeScript views might change this in the future, if you go all-in with them). Using GAE’s Session Affinity to achieve consistent server-side state won’t work, since, [according to GAE documentation]
(https://cloud.google.com/appengine/docs/flexible/java/using-websockets-and-session-affinity),

Session affinity in App Engine is implemented on a best-effort basis. When developing your app, you should always assume that session affinity is not guaranteed.

and

You should never use session affinity to build stateful applications.

First, just to get it out of the way - in a really simple app or one which isn’t very important, this might not matter. You might not ever notice.

But if you want to make a reliable app and serialize and deserialize the application’s state on every single request (since at any given moment, the old server instance may be gone), this means every class in your application must be serializable. Development like that is really painful on anything non-trivial. This is both really bad for the developer experience and, no matter how efficient your serialization datastore, really CPU heavy (and probably memory/storage-heavy as well). Even with fast super fast state de/serialization, you’ll still see a decrease in response times, too.

The only case where I’d recommend full state serialization would be in a really mission-critical app, and in that case I woudn’t use GAE.

Have you experienced problems with GAE or are these theoretical issues?

<async-session-persistence enabled="true" /> could be used to minimize the effect on performance the persistance makes.

IMO: A reliable app would not depend on session state to store important information, it would save important data to a database.

I vote for atleast making it easy to use GAE and if it is problematic, warn developers. But to not offer it? Seem like a cop-out. I have been using “vaadin-compatibility-server-gae” with my app and I have not experienced any issues.

Personally, I think GAE and Vaadin are perfect for eachother.

Jonatan Jönsson:
Have you experienced problems with GAE or are these theoretical issues?

Not personally, but I’ve discussed with several people who ended up with costly migrations away from GAE and performance issues even with the old supported Vaadin 7 version.

I see. GCE with docker images is pretty sweet as well so I guess I might try that out for Vaadin 14 instead.

Nevertheless there is a tutorial for deploying vaadin applications to GAE - https://vaadin.com/learn/tutorials/cloud-deployment/google. This tutorial doesn’t even mention that one might run into trouble at google…

→ Either the tutorial is bad advice and paying customers might try to get their money back
→ Or this forum page is outdated and GAE are perfect for each other (at least when scaling is done manually)

btw. when instances are moved or shut down, according to https://cloud.google.com/appengine/docs/standard/python3/how-instances-are-managed#scaling_types google sends a shutdown notification one can implement a shutdown-hook for (probably https://cloud.google.com/appengine/docs/standard/java/javadoc/com/google/appengine/api/LifecycleManager.html)
so one could implement a shutdown-hook and serialize all session-state. If so that should be documented in the tutorial.

Sebastian Dietrich:
→ Either the tutorial is bad advice and paying customers might try to get their money back
→ Or this forum page is outdated and GAE are perfect for each other (at least when scaling is done manually)

The key in the tutorial is to use the [flexible environment]
(https://cloud.google.com/appengine/docs/the-appengine-environments) in GAE that runs the applications within Docker containers on GCE VMs.

However, I still recommend the pre-containerized approach for GCP. I’ll update the tutorial with a clear disclaimer.

Mikael Sukoinen:
However, I still recommend the pre-containerized approach for GCP. I’ll update the tutorial with a clear disclaimer.

I suppose you mean the [standard environment (e.g. Java 11) for GAE]
(http://https://cloud.google.com/appengine/docs/the-appengine-environments) (i.e. no docker or whatever container)?

No, I’d still use Docker thanks to the broad compatibility with frameworks and the option for custom runtimes etc. even after GAE Standard env added support for Java 11.