Your weather app queries a database every 15 minutes to get the current temperature. The frontend is powered by Google App Engine and server millions of users. How should you design the frontend to respond to a database failure?
A.
Issue a command to restart the database servers.
B.
Retry the query with exponential backoff, up to a cap of 15 minutes.
C.
Retry the query every second until it comes back online to minimize staleness of data.
D.
Reduce the query frequency to once every hour until the database comes back online.
Correct answer is B. App engine create applications that use Cloud SQL database connections effectively. Below is what is written in google cloud documnetation.
If your application attempts to connect to the database and does not succeed, the database could be temporarily unavailable. In this case, sending too many simultaneous connection requests might waste additional database resources and increase the time needed to recover. Using exponential backoff prevents your application from sending an unresponsive number of connection requests when it can't connect to the database.
This retry only makes sense when first connecting, or when first grabbing a connection from the pool. If errors happen in the middle of a transaction, the application must do the retrying, and it must retry from the beginning of a transaction. So even if your pool is configured properly, the application might still see errors if connections are lost.
reference link is https://cloud.google.com/sql/docs/mysql/manage-connections
Exponential backoff is a commonly used technique to handle temporary failures, such as a database server becoming temporarily unavailable. This approach retries the query, initially with a short delay and then with increasingly longer intervals between retries. Setting a cap of 15 minutes ensures that you don't excessively burden your system with constant retries.
Option C (retrying the query every second) can be too aggressive and may lead to excessive load on the server when it comes back online.
Option D (reducing the query frequency to once every hour) would result in significantly stale data and a poor user experience, which is generally not desirable for a weather app.
Option A (issuing a command to restart the database servers) is not a suitable action for a frontend component and might not address the issue effectively. Database server restarts should be managed as a part of the infrastructure and not initiated by the frontend.
correct answer -> Retry the query with exponential backoff, up to a cap of 15 minutes.
If your application attempts to connect to the database and does not succeed, the database could be temporarily unavailable. In this case, sending too many simultaneous connection requests might waste additional database resources and increase the time needed to recover. Using exponential backoff prevents your application from sending an unresponsive number of connection requests when it can't connect to the database.
Exponential backoff with a cap is a common technique used to handle temporary failures, such as database outages. In this approach, the frontend will retry the query with increasing intervals (e.g., 1s, 2s, 4s, 8s, etc.) up to a maximum interval (in this case, 15 minutes), this will help to avoid overwhelming the database servers with too many requests at once, and minimize the impact of the failure on the users.
Option A, is not recommended because it's not guaranteed that restarting the database servers will fix the problem, it could be a network or a configuration problem and it could cause more downtime.
Option C is not recommended because it could cause too many requests to be sent to the server, overwhelming the database and causing more downtime.
Option D is not recommended because reducing the query frequency too much would result in stale data, and users will not receive the most up-to-date information.
I guess that when u have failed after 15 minutes, your app must go through a serious review before being used again, since it is not able to provide the updated results as quickly as desired.
Truncated exponential backoff is a standard error-handling strategy for network applications. In this approach, a client periodically retries a failed request with increasing delays between requests
B,
backoff is a standard error handling strategy for network applications in which a client periodically retries a failed request with increasing delays between requests. Clients should use truncated exponential backoff for all requests to Cloud Storage that return HTTP 5xx and 429 response codes, including uploads and downloads of data or metadata.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Radhika7983
Highly Voted 4 years agollamaste
Highly Voted 4 years, 4 months agortcpost
Most Recent 2 months agosamdhimal
2 months agosamdhimal
1 year, 10 months agoRT_G
1 year agorocky48
1 year agogudguy1a
1 year, 2 months agoDatardp
1 year, 5 months agovaga1
1 year, 6 months agovaga1
1 year, 6 months agoyafsong
1 year, 11 months agohiromi
2 years agoshiv14
2 years, 9 months agodeep_ROOT
2 years, 10 months agoMaxNRG
3 years agoanji007
3 years, 1 month agosumanshu
3 years, 7 months agolbhhoya82
3 years, 8 months ago