3
votes

I have a spring based web application running on app engine java that receives about 1 hit / min.

Unfortunately, app engine scheduler kills off instances that are idle for more than 10 seconds or so. Therefore each request to my site takes around 30 seconds to complete, while a new Dynamic instance loads.

Tried to use resident instance, however, requests never go to resident instance. Regardless, of how many resident instances there are (I have tried up to 4), a new request always spawns off a new Dynamic instance so even with 4 idle instances, a request has to wait 30 seconds.

What settings of idle instances and latency can allow my app to run always on, so that the odd 1 request I receive every minute is met with a warm/live instance.

2
I have tried one thing, still experimenting to see the impact. 1) set min-max idle instances to 1-1 2) set min-max latency to 15-auto The logic is that it will force scheduler to send new requests to existing instance instead of aggressively creating new instances. - aronzygo
Did your test work? I have basically the same issue, where there could be no traffic for quite a long time, and then suddenly a lot of traffic, which causes multiple on-demand instances to start. The other thing you might want to check is what size of instance you are using. I'm using Spring and Jersey, and it gets close to the 128MB memory of the smallest instance size, which can also cause AppEngine to spawn new instances. - crazystick

2 Answers

1
votes

I have been dealing with this kind of issues for more than 6 months so far, with a hit/min similar than yours, maybe a little higher, and the best settings I have found with F1 and without breaking the bank (but still expensive comparing with other hosting services which provide better perfomance) are:

min idle instances = 1
max idle instances = 1
min pending latency = 15s
max pending latency = 15s

If your memory consumption is more than 128MB per instance, then you can consider to go for 2 or 3 as max idle instance.

From my experience, with this configuration some of the requests will be handled by the resident instance, and some other will be handled by a new dynamic one which, with a bit of luck, app engine will have preloaded if it served a warmup request before, getting a better response time than the usual 30 seconds (if not a DeadlineExceededException).
However there will be some requests which will run new loading instances, and this is something unavoidable using automatic scaling. There is something quite novel called manual scalling which is configurable, but it would increase your app complexity and wouldn´t solve the root causes of this serious performance issue.

I´s a shame google is unable to provide a decent service for java apps using DI frameworkds like Spring, Guice... as you can check on multiple forums and lots of open threads about this problem, some of them for more than two years ago.
It doesn´t matter either how well you optimize Spring, unfortunately the waiting times in many cases will still be unacceptable for professional applications in google app engine for java.

0
votes

Don't use Google App Engine. Use a IaaS instead. At such small scale, you don't need autoscaling. You do need more control.