I've been looking at CloudFlare as a CDN service for my Google App Engine hosting, and as a student, cost is always an issue (aka free services only). I read on the CF blog that when the origin server is down, CF will serve a cached version of the website from its own servers to users.
So if we hit the GAE quota limit, is the server considered as "down"? Will CF display the cached website? I don't plan to have a lot of dynamic content so serving an entire cached website is not too much of an issue to me.
If the answer to my first question is no, is it possible to get CF to serve it's cached website content automatically once GAE hits any quota limit? I know it's probably unlikely but just wanted to throw this question out.
According to CloudFlare's wiki, the Always Online feature will return a cached page only if the backend server is unavailable or returns a response code of 502 or 504. When you hit quota limits App Engine itself will generally still be available, so whether the cache works depends on the response code in your case.
If your app exceeds its bandwidth or instance hour quota, App Engine will return a 403 Forbidden response code. It is possible to customize the content of the error response, but not the code. It seems then that CloudFlare will not serve a cached page in this case.
However, if your app hits an API usage quota, your code will receive an exception and you can choose to return one of those 50x codes and trigger the cache.
I'm not sure if this particular case will work for CloudFlare because of the error code that App Engine returns (we are working on some enhancements for Always Online, but it really won't tackle 403 errors).
It does appear that AppEngine does allow you some customization of the error pages?
Tip: You can configure your application to serve a custom error page when your application exceeds a quota. For details, see Custom Error Responses documentation for Python and Java.
Related
I have been working with Google Cloud Platform & Flask for the first time - my client wanted me to deliver a solution on it in 2 weeks.
I have been successful so far in creating a Flask application and wanted to productionize it through Google App Engine. However, the runtime of my function is a little over 2.5 minutes and I get a "504 Gateway Timeout" error. In the code piece, I am accessing bigQuery, google spreadsheets and GCS buckets. Should I switch to a new GCP service or can some tweaks in my code/yaml file suffice? My yaml config is -
runtime: python37
liveness_check:
check_interval_sec: 300
timeout_sec: 299
failure_threshold: 10
success_threshold: 10
initial_delay_sec: 500
readiness_check:
app_start_timeout_sec: 1800
I would be very, very grateful to anyone who can help me resolve this issue.
Thank you!
Edit: Just to give a brief about the application - this is a forecasting application that reads data from bigquery, GCS buckets, and Google Spreadsheets, processes it and runs ML models on it. The results are written back to Google Spreadsheets within the application itself (i.e. no response needed from the application per see). I'm triggering the application using google AppsScript.
The best option is to restructure how your website works. You can then stick with GAE standard. Even if you switch to GAE flexible, it will work better this way.
Here is the sequence of operations:
A user submits a request from web page.
Your website returns immediately with a page that indicates that you are working on it.
The page you return includes Javascript that will poll your website to ask if the task is complete.
When the task is complete, the Javascript will update the page and present the results to the user.
On the server side, you can use cloud tasks for doing the processing which I believe has a time limit of 10 minutes.
This way, the user is always viewing a web page and isn't sitting there waiting and looking at a blank screen while waiting for the server to return something.
I tried to set up Google Cloud CDN for my server on Google Compute Engine. I have done everything correct but images on my server are not getting cached.
Cache hit ratio is n/a.
In logs, I am getting 200 status code for http://(ip address)/poweredby.png. So I am assuming frontend IP is not hitting my server but somewhere else. Other than this I can't find any error, all setup is correct. May be I have to change something in my nginx conf file? but I don't know. Let me know if question is not clear.
Update:
I was using http but someone suggested https is must. So, i have updated it to https but now health check is getting failed.
Thanks,
According to this documentation not all responses are cacheable. You need to meet all requirements for Cloud CDN to cache a response.
Regarding the HTTPS health checks: confirm that you have added 35.191.0.0/16 and 130.211.0.0/22 to your firewall rules. More information is in the documentation on GCP health checks.
I followed this guide: Quickstart for Python. After launching the "hello, world" app to app engine (flex) I went to [project].appspot.com and noticed that it is very slow. I tried testing it in different devices and network conditions and I still have the same issue. I went to Cloud Trace and can't build a report due to a lack of traces. It is also slow in both http and https. I deployed to us-central and I am in Texas.
I have attached some logs from Logging and a snippet from Google Chrome's Dev Tools to show the slowness.
Logs from Logging:
Chrome Dev Tools:
The images don’t show anything especially unexpected. Response time will vary depending on the location of the client and its distance to the region of the App Engine Flex instance. Responses that take an especially long time are likely due to a cold boot.
You probably use a free instance of app engine. Because it's free the lifespan is very short, therefor it shuts down after a short amount of time without requests. When you send a new request after some time, the instance has to set up and then process the request, which takes time. You can keep pinging the app to keep the instance alive. Similiar question is anwered here.
I have an issue with our Python 2.7 Google App Engine project where after a lot of research it appears as though App Engine is repeatedly sending through the same request to our servers. Is anyone else experiencing this issue?
EDIT:
It's a standard request with all the same parameters as it was first sent with (some of which are 15 days old now). I'm wandering if it's a similar situation to this https://groups.google.com/forum/#!topic/google-appengine-downtime-notify/9fAYP7UyppQ
Typically App Engine doesn't send requests, it's the framework you use to handle requests.
If you're getting duplicate requests coming in, you should look to see where it's coming from. If it's coming from an app engine server to your own external server, then somebody is running some sort of process on their app engine account that's accessing data from your server during its execution.
The details, including what you would do about it, are all situation-dependent. There's no catch-all response. Just be aware that, yes, any computer on the Internet can make web requests to any other. And that includes app engine (in both directions).
My Google App Engine application returns 503 codes to clients when they should try later to receive data from the server. This appears to cause app engine to think the application is failing and after several such responses the instance is restarted, adding to average latency. Is there a way to prevent app engine from restarting instances just because you manually return 503 or other non-200 http response codes? TIA!
Edit 1:
Here's a screenshot of how it typically goes (with some app-specific stuff ablated due to the sensitive nature of my app). Note that all the [I]nformational and [D]ebug messages are generated by my code, while the [W]arning about the restart is obviously GAE itself. The only thing that distinguishes the times this happens is when I return a 503.
App Engine doesn't base decisions to terminate or restart instances based on the status codes you return, or on what you log.
It seems App Engine now does base instancing decisions on your return code. To the best of my knowledge, there's no way to return a 5xx code, but tell App Engine that nothing's really wrong.