Understanding 'Frontend Instance Hours'

已查看 14,383 次
跳至第一个未读帖子

KK

未读,
2011年12月21日 23:03:222011/12/21
收件人 google-a...@googlegroups.com
Hi,

My dashboard shows that my apps's Frontend Instance Hours is more than 50% in about 18 hours and it has only received about 200 requests.

Frontend Instance Hours
53%
53%14.90 of 28.00 Instance HoursOkay

I am not sure how the number of instance hours could be so high for such a small number of requests.

I would appreciate if someone could help me understand
 - why the instance hours percent is so high for such a small number of requests
 - Is there any thing I can do in my code to improve this
 - What happens when the number of instance hours reach its limit. Does the appengine stop serving the requests? or the responses just get delayed?

Thanks
Krishna

Andreas

未读,
2011年12月22日 10:27:472011/12/22
收件人 google-a...@googlegroups.com
the instance hours could be that high because of different reasons.

for example your code is not optimized and consumes more resources than it should or you did not set the instances to a specific number in the application settings and multiple instances spin up and consume more than it would be necessary for your app.

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/DEVQ7ic2Ao4J.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.

Simon Knott

未读,
2011年12月22日 10:53:482011/12/22
收件人 google-a...@googlegroups.com
Hi,

If an instance is spun up, then you will use up 15mins of Frontend instance hours automatically for spinning up the instance.  So if those 200 requests are fairly spread out over the 18 hours then it's more than possible to use 50% of your quota.


If you go over your quota, then your application will stop serving requests.

Cheers,
Simon

KK

未读,
2011年12月22日 11:33:182011/12/22
收件人 google-a...@googlegroups.com
Thanks for your reply.

So, you mean 4 requests per hour that are perfectly spread out can cause 1 instance hour. Right? So, if I only have ONE instance all the time, it would only mean 24 instance hours in a day and I would never exceed the quota. How do I make sure that my app only uses one instance? Does setting 'maximum idle instances' to 1 help?

Does the following message in the log file related to this? Does it mean it is creating another instance (or Is it another process in the same instance?)
This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.

Thanks
Krishna

Gerald Tan

未读,
2011年12月22日 12:41:362011/12/22
收件人 google-a...@googlegroups.com
There's no way to make sure that your app uses only one instance. Setting max idle instance ensures that you will be changed for a maximum of 1 idle instance. If traffic goes up, the the scheduler may spin up extra instances, however you are only charged for "Max Idle Instance + Active Instances", so you really shouldn't need to worry about extra instances - you will usually not be paying for those if you set max idle instance to 1.

KK

未读,
2011年12月22日 14:15:282011/12/22
收件人 google-a...@googlegroups.com
That's interesting.

So, if my app just prints "Welcome!" and does nothing else. And if there is a request every 15mins., the front-end instance hours will be 24 at the end of the day? 

Thanks
Krishna

Brandon Wirtz

未读,
2011年12月22日 14:22:242011/12/22
收件人 google-a...@googlegroups.com

Yes.

Unless you set your cache headers to 60 minutes then it will be 6 hours at the end of the day. (even if there is a request every second.

--

You received this message because you are subscribed to the Google Groups "Google App Engine" group.

To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/qrPnCBy4xy4J.

Gerald Tan

未读,
2011年12月22日 14:24:392011/12/22
收件人 google-a...@googlegroups.com
Yes. So in this case I'd even recommend setting min idle instance to 1 too
So that the "Welcome!" message doesn't need to wait for an instance to warmup before appearing

Barry Hunter

未读,
2011年12月22日 14:25:132011/12/22
收件人 google-a...@googlegroups.com
Yes. An instance is kept there ready to server traffic, so it costs
Google money - so it costs you too.

But of course that 24 hours (plus the extra 4) is free.

KK

未读,
2011年12月22日 14:36:032011/12/22
收件人 google-a...@googlegroups.com
Thanks every one for the responses.

Since it is going to be at least 24 frontend instance hours in a day if there is steady traffic to my app. What are the guidelines I can follow in my app to reduce the number of frontend isntance hours above 24? 

Would things like setting setting cache headers such a way that all image files are cached for ever help? If yes, how do I do this?
What other things can be done?

Thanks
Krishna

Barry Hunter

未读,
2011年12月22日 14:44:572011/12/22
收件人 google-a...@googlegroups.com
On Thu, Dec 22, 2011 at 7:36 PM, KK <krishna...@gmail.com> wrote:
> Thanks every one for the responses.
>
> Since it is going to be at least 24 frontend instance hours in a day if
> there is steady traffic to my app. What are the guidelines I can follow in
> my app to reduce the number of frontend isntance hours above 24?

The biggest one is pretty much to minimise your latency. Make each
request as quick as possible.

AppStats can help track stuff that could be optimized.


Its still in development, but using threads as part of python 2.7
runtime, can help too. But its not a 'universal' fix yet...

>
> Would things like setting setting cache headers such a way that all image
> files are cached for ever help? If yes, how do I do this?

Well images (& css etc) would proabbly be served from 'static' -
which then doesnt even use your dynamic instances. Can still set cache
headers to reduce your bandwidth use.

Any requests could can allow to be cached, probably should be.


> What other things can be done?
>
> Thanks
> Krishna
>

> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/google-appengine/-/pHi-DwkAozQJ.

stevep

未读,
2011年12月22日 23:09:592011/12/22
收件人 Google App Engine
Be sure you do not have something that is periodically creating a
burst of tasks into a task queue. I believe the scheduler responds to
this by thinking, "Wow. I've got a lot of tasks to clear as soon as
possible." This could be very detrimental to your instance counts as
you may get a burst of instances to clear the tasks - yet each
instance lives many minutes past its useful purpose. Look to your
queue.yaml to govern any TQ that does not need quick response.

HTH,
stevep

Uman Lata

未读,
2012年4月25日 01:21:092012/4/25
收件人 google-a...@googlegroups.com
I also experience the same problem in my website. When this thing happen I observe there is large number of request in the log in small time. So if your app is initiated at burst then this may happen. You can check logs in appengine logs and you can find requests at brust when this problem happens.
回复全部
回复作者
转发
0 个新帖子