I just upgraded my app from Google Datastore (Gen 1), to Google Firestore in Datastore mode (2nd Gen).
My DB queries went from around 200ms, to around 2 seconds. I'm trying to figure out what I did wrong.
It's running in Google App Engine Standard, as a Spring Boot 3 app with Java 17 and Embedded Tomcat as the web server.
When I run locally with the datastore emulator, the DB queries are super fast. It's only when I deploy, they run slowly.
I made all my DB queries have ReadOption.eventualConsistency()
but that didn't help.
I can't see any documentation around the management of the connection to the DB. I'm just doing this:
Datastore datastore = DatastoreOptions.getDefaultInstance().getService();
I'm wondering if it's having to make a new connection on every DB call.
Any ideas why I'm seeing the poor performance would be great.
Thanks.
EDIT: Switching Spring Boot from using Tomcat to use Undertow fixed it. Much smaller memory footprint which is now within the F1 instance limits. Everything runs great, even then DB calls.
Thank you for the comments, I think I've figured it out.
The old 1st gen GAE framework was very memory efficient. Spring Boot with Embedded Tomcat, not so much. It seems to use around 300MB of memory, just starting the server with the GAE libraries.
The F1 instances that were working fine, now struggle, as they have a memory limit of 384MB.
I've now switched to using the F2 instances, and while my app is still slower than the old 1st gen GAE framework, it's running okay.
My next steps will be to tune Spring Boot to be more efficient, or move away from it.
Thanks all.