2

I've been using Google App Engine to host my APIs and keep banging up against the limitation of concurrent database connections. The docs say that you can only have up to 12 concurrent connections per "app engine instance" (https://cloud.google.com/sql/faq#sizeqps) but I'm not quite sure what that means.

I'm using GoLang and my app is transactional, so a limit of 12 concurrent database connections effectively means fewer than 12 concurrent API connections. That's really low and seems out of step with Google's other rate limits which are pretty generous.

Each individual process doesn't need more than a single database connection so if there's a way to spawn multiple "instances" I'd be fine. But I'm not quite sure what it means and whether it applies to all services pooled, each individual service, each handler, etc.

Thanks in advance for any help. Dan

Dan
  • 21
  • 1

1 Answers1

2

An instance is the basic building block of your App Engine application and refers to a machine running a version of your code on one of the services that make up your App Engine application. One of the features of App Engine is the ability to scale your application up or down to meet the demand. This is done by creating and shutting down instances according to the scaling configuration you selected when deploying your application.

Since you say you've been running against the 12 connections per instance limit I assume this means App Engine determined your instance should be able to handle more than 12 requests at once. To avoid this scenario you should set max_concurrent_requests to 12 or lower in your app.yaml and make sure to cleanly terminate all connections once you're done with them. That way no single instance should try to use more than 12 database connections concurrently.

Note that this restriction is stated to only apply to the App Engine standard environment, meaning that an instance running on the Flexible environment would not be subject to this per-instance connection limit and could properly handle connections until another instance's creation is deemed necessary by App Engine.

Yannick MG
  • 193
  • 5
  • 1
    To better understand instances and how they fit with the other building blocks of App Engine you should read about [how instances are managed](https://cloud.google.com/appengine/docs/standard/go/how-instances-are-managed) and [an overview of App Engine](https://cloud.google.com/appengine/docs/standard/go/an-overview-of-app-engine). – Yannick MG Jun 26 '17 at 20:39