Setting datasource's maximumPoolSize with a HikariDataSource on AppEngine with Cloud SQL

231 views
Skip to first unread message

Roxana Ioana Roman

unread,
Jun 8, 2017, 8:43:51 AM6/8/17
to Google App Engine
Hello, 
I am a bit confused regarding setting the optimal connections pool size (dataSource.setMaximumPoolSize(maxPoolSize)).
Correct me if my judgement is wrong. Instances on AppEngine have only a single core. Given that, the optimal max number of threads is 2 per instance (i.e. 2 per core). Since the optimal number of connections in a connection pool should be equal to the number of threads, this means the maximumPoolSize per instance should be 2? 
The maximum we can set with AppEngine is 12, though. 
My instance type is B4 and it is scaled. i am using HikariDataSource and Cloud SQL. What is the optimal poolSize or how can this be computed?

Thanks!

Alex Martelli

unread,
Jun 8, 2017, 1:57:06 PM6/8/17
to google-a...@googlegroups.com
On Thu, Jun 8, 2017 at 5:43 AM, Roxana Ioana Roman <rroxan...@gmail.com> wrote:
Hello, 
I am a bit confused regarding setting the optimal connections pool size (dataSource.setMaximumPoolSize(maxPoolSize)).
Correct me if my judgement is wrong. Instances on AppEngine have only a single core. Given that, the optimal max number of threads is 2 per instance (i.e. 2 per core). Since the

This only applies if no thread is ever blocked waiting for some I/O operation (e.g, a networking interaction) to complete -- IOW, if the process is 100% CPU-bound. Such an extreme situation hardly ever happens; the vast majority of processes to need SOME I/O (many, in fact, need A LOT OF I/O, and are known as "I/O-bound").
 
optimal number of connections in a connection pool should be equal to the number of threads, this means the maximumPoolSize per instance should be 2? 
The maximum we can set with AppEngine is 12, though. 

12, of course, would allow for "quite a bit of" I/O blocking (somewhere between "some" and "a lot of" -- not exactly rigorous mathematical terms, as you'll recognize).
 
My instance type is B4 and it is scaled. i am using HikariDataSource and Cloud SQL. What is the optimal poolSize or how can this be computed?

I do not believe there is, nor can be, any mathematical formula to compute that: it depends too highly on the actual flow of control of your code during typical interactions that you wish to optimize for. Note that this is a general statement about almost every case in which you're tweaking configuration parameters to optimize/tune for performance: it is in absolutely no way restricted to, nor specific to, App Engine, and connection pool sizes within it in particular.

The general approach is: prepare a "load test" reproducing the relevant set of interactions you want to optimize your tuning parameters for; run the load test with different tuning parameters settings, measuring the performance effect of each such setting; pick settings for your production deployment according to such measurements.


Alex

 

Thanks!

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscribe@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/f12ac2ed-d20a-4eb8-9c44-4e65515fb061%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages