Google Cloud Datastore (In Datastore mode) - DeadLine Exceeded exception

I have absolutely no load , one client. I am loading one record at a time , I have seen multiple times - i get error Deadline exceeded.

The error is random but it appears very regularly , it can come at query by key , simple query , upsert of single record or multiple record.

I have this error reported from cloud run and as well as local servers running admin sdk and connecting to datastore

Have other people seen this kind of scenario.

And if with almost 0 load, performance is like this , is it even ok to use datastore in production

There is nothing special about insert or read , its a simple api , and it fails quite randomly

1 9 430
9 REPLIES 9

The “"Deadline Exceeded" issue can be caused by several factors:

  1. Network Latency: Even with a single client and minimal load, network latency can sometimes cause requests to take longer than expected.

  2. Datastore Configuration: Ensure your Datastore indices, entity groups, and other configurations are optimized for your queries.

  3. Client Library or SDK Issues: The problem might be related to the version of the client library or SDK you're using. Check if there's an update or patch that addresses this issue.

  4. Resource Limits: Although you're running under low load, check if there are any resource limits or quotas being hit unexpectedly.

  5. Code or Query Optimization: Sometimes, the way the code is written or queries are structured can lead to inefficiencies, even with simple operations.

  6. Intermittent Service Issues: Google Cloud services sometimes experience intermittent issues that could cause these errors.

In terms of resolving this issue and determining if Datastore is suitable for production:

  • Monitoring and Logging: Use Google Cloud's monitoring and logging tools to diagnose the issue. Detailed logs might give you insights into what's happening when the deadline is exceeded.

  • Seek Community or Support Help: Check forums like Stack Overflow or Google's support channels to see if others have experienced similar issues and what solutions they might have found.

  • Test in Different Environments: Try replicating the issue in different environments to see if it's specific to a certain setup.

  • Consult Documentation: Google's documentation might have specific advice for dealing with deadline exceeded errors.

  • Review Architecture: Sometimes, the overall architecture of how you're using Datastore might need to be reviewed.

Regarding the use of Datastore in production, many companies do so successfully, but it's crucial to ensure that your specific use case aligns with its strengths and limitations. If these issues persist and severely impact your application, consider evaluating other Google Cloud storage solutions or databases that might be more suited to your needs.

Thanks, Can you please provide me an idea what logs I need to enable for google cloud datastore to understand whats causing the error.

You can use Cloud Monitoring and Logging to investigate the "Deadline Exceeded" errors in Datastore::

  1. Enable and Access Google Cloud Monitoring and Logging:

    • Ensure that Cloud Monitoring and Logging are enabled for your Google Cloud project.
    • Access logs through the Google Cloud Console, under the "Logging" and "Monitoring" sections.
  2. Key Logs to Examine:

    • Datastore Logs: Filter for Datastore-specific logs to review operations like reads, writes, and queries.
    • Application Logs: Analyze your application logs for any relevant information around the times the errors occurred.
    • Audit Logs: Check the audit logs for insights into administrative actions or configuration changes that might impact performance.
  3. Utilizing Cloud Logging:

    • Use advanced filtering in Cloud Logging to isolate relevant log entries.
    • Focus on log entries that correspond with the times when the Deadline Exceeded errors were reported.
  4. Performance Metrics in Cloud Monitoring:

    • Use Cloud Monitoring to track key performance metrics of your Datastore, such as latency, error rates, and request counts.
    • Consider setting up custom dashboards in Cloud Monitoring for real-time visualization of these metrics.
  5. Analyzing and Interpreting Logs:

    • Look for any patterns or anomalies in the logs that might be related to the errors.
    • Check for any operations or queries that consistently take longer to execute.
  6. Alerts and Notifications:

    • Configure alerts in Cloud Monitoring to get notified about specific conditions, like high error rates or latency issues.
  7. Logging Best Practices:

    • Adjust log levels as needed to capture essential details for troubleshooting.
    • Regularly review logs to proactively identify and address potential issues.
    • Consider exporting important logs for more detailed analysis or for compliance reasons.

Hello,

I am aware of the above things , but most of them are not applicable for cloud datastore.

There is just insight summary -which just tells me amount of data I have.

There is no internal datastore logs which i can see anywhere , which can help me troubleshoot the issue.

So can you please guide me about things specific to datastore.

 

 

Sorry for the confusion. You're right that Datastore, unlike some other Google Cloud services, has limited internal logging and monitoring capabilities that you can directly access. Here's a more specific approach considering the constraints of Datastore:

  1. Datastore Operational Metrics:

    • While detailed internal logs aren't available for Datastore, you can monitor operational metrics in Google Cloud Console. These metrics include read/write operations, latency, and error rates.
  2. Client-Side Logging:

    • Since Datastore doesn’t provide extensive internal logs, it’s important to implement robust client-side logging in your application. Log all Datastore operations including queries, entity reads/writes, transaction starts, and any exceptions or errors.
    • Capture the time taken for each Datastore operation in your logs. This can help identify if certain operations are consistently timing out.
  3. Error Handling in Application Code:

    • Implement detailed error handling around your Datastore operations. Catch exceptions and log them with as much detail as possible, including stack traces.
    • For Deadline Exceeded errors, log the specific operation that failed, the time it took, and the conditions under which it failed.
  4. Analyzing Application Logs:

    • Use your application logs to identify patterns or conditions leading to Deadline Exceeded errors. Look for correlations with specific Datastore operations, payload sizes, or times of day.
    • If your application is hosted on Google Cloud (e.g., App Engine, Compute Engine), you can view and analyze these logs in Cloud Logging.
  5. Optimizing Datastore Usage:

    • Review your Datastore schema and indexes to ensure they are optimized for the queries you are running.
    • If you notice specific operations are frequently timing out, consider whether they can be optimized, for example, by reducing entity sizes or simplifying queries.
  6. Network Analysis:

    • Since network latency can contribute to Deadline Exceeded errors, consider analyzing the network performance, especially if your application is running in a different region from your Datastore instance.

Hello,

Today i have cases where Entity Read by Key got deadline exceeded. Latency metrices is not giving me any meaningful information which i can utilize. 

The same request works If I try the next time , is there cold vs hot restart thing with google datastore.

 

The situation you're describing with Google Cloud Datastore – occasional Deadline Exceeded errors on entity read operations by key that succeed upon retry – is intriguing. While Datastore is designed to be highly available and doesn't have a traditional "cold start" issue like some compute services, there are a few factors that might be contributing to this behavior:

  1. Caching and Datastore: Unlike some other database systems, Datastore does not have a built-in caching layer that differentiates between "cold" and "hot" data access. However, the underlying infrastructure of Google's cloud services, including network components, may have optimizations that could indirectly influence performance.

  2. Occasional Latency Spikes: It's possible that you're experiencing occasional spikes in latency due to the distributed nature of Datastore. This can happen for various reasons like temporary network issues, Datastore performing its own maintenance tasks, or transient problems in the underlying infrastructure.

  3. Application-Specific Issues: If your application has intermittent network issues or if the instance running your application experiences temporary resource constraints, this might also lead to Deadline Exceeded errors.

  4. Datastore's Distributed Nature: Since Datastore is a distributed database, sometimes the data retrieval might involve complex operations under the hood, even for simple key-based reads. These operations might occasionally take longer than expected.

  5. Retries and Exponential Backoff: The fact that a retry often succeeds suggests that implementing a retry strategy with exponential backoff in your application might be beneficial. This approach involves retrying the failed operation with gradually increasing delays.

To further investigate, consider the following steps:

  • Enhance Logging: If not already doing so, log detailed information about each operation, including the time taken and any errors.
  • Review Configuration: Double-check the configuration of your Datastore client in your application. Ensure it's optimized for your use case.
  • Contact Google Cloud Support: For such intermittent and hard-to-diagnose issues, getting in touch with Google Cloud Support can be helpful. They might be able to provide insights based on internal metrics and logs that are not exposed to end-users.

Understanding the exact cause of these intermittent issues can be challenging, especially without direct visibility into the internal workings of Datastore. However, by combining careful monitoring, application-level logging, and perhaps Google Cloud's support, you should be able to better diagnose and mitigate these issues.

Hello,

I have tried all, but issue still persist. Get deadline exceeded , it can be on the first call or nth call, but its always there.

 

 

Here are some additional steps and considerations that might help in resolving or mitigating the issue:

1. Review Your Application's Architecture

    • Consider a Distributed Approach: If feasible, distributing Datastore operations across multiple services or instances could alleviate some pressure. This strategy can help isolate the issue or reduce the load on any single component interacting with Datastore.

    • Microservices for Targeted Troubleshooting: Breaking down your application into smaller, more manageable microservices (if you haven't already) can make it easier to identify exactly where the "Deadline Exceeded" errors are occurring, allowing for more focused problem-solving.

2. Analyze Application Patterns

    • Examine Traffic Patterns: Take a closer look at how traffic flows through your application, especially during peak times. Implementing a queueing mechanism or rate limiting could help manage loads more gracefully.

    • Optimize Data Access: Review how your application reads from and writes to Datastore. Simplifying queries or restructuring data might reduce complexity and improve performance.

3. Advanced Monitoring and Tracing

    • Utilize Google Cloud Trace: This tool can offer valuable insights into the latency of your application's API calls to Datastore, helping pinpoint operations that may be causing bottlenecks.

    • Implement Custom Metrics: Creating custom metrics for your Datastore operations can provide a clearer picture of operation timings, success rates, and other critical metrics that standard tools might miss.

4. Alternative Datastore Strategies

    • Implement Caching: Introducing a caching layer for frequently accessed data can significantly reduce direct read operations on Datastore. Google Cloud Memorystore or a custom caching solution could be effective here.

    • Evaluate Firestore in Native Mode: If you're currently using Firestore in Datastore mode, consider whether switching to Firestore's Native mode might offer better performance for your use case, thanks to its additional features and optimizations.

5. Consider Professional Services

  • Google Cloud Professional Services: If the situation is critical and continues to elude resolution, Google Cloud Professional Services is an option. Their team of experts can provide in-depth assistance tailored to your specific scenario.