Sobes.tech
Senior

What are the differences in scenarios when reading and writing to an inaccessible external service?

sobes.tech AI

Answer from AI

When interacting with an unavailable external service, read and write scenarios differ in approach and consequences:

  1. Reading:
  • If the service is unavailable, data cannot be retrieved.
  • Caching can be used (for example, caching the last successful data) and serving stale data with a warning.
  • Fallback logic can be implemented, such as returning default values or data from a backup source.
  • It is important to handle timeouts and errors correctly to avoid system blocking.
  1. Writing:
  • When the service is unavailable, writing cannot be performed immediately.
  • Reliable data storage should be ensured for subsequent re-sending (for example, a message queue, a database with a "not sent" flag).
  • A retry mechanism with exponential backoff should be implemented.
  • Operations should be idempotent to avoid duplication on retries.

Thus, for reading, data availability and the ability to serve stale or alternative data are important, while for writing, ensuring data integrity and delivery upon service recovery are crucial.

What are the differences in scenarios when reading… - sobes.tech