Urgent.News

What's breaking now, across thousands of outlets.

Tech

Make generation quotas safe to retry

Any web action that calls a slower service has to handle a familiar failure: the server may finish the work, but the response can disappear before the browser receives it. If a user retries and the backend treats the retry as a new operation, the same request may consume quota twice or create duplicate output. A button being clicked once does not guarantee one request reached the server. A useful…

Web applications that interact with slower services must manage a common issue: server responses may vanish from the browser before reaching it. If a user attempts to re-perform an action, the backend could treat the retry as a distinct operation, resulting in the same request using up quota or generating duplicate output. To prevent this, it's beneficial to assign each intended operation a stable idempotency key.

The server should record this key before starting any resource-intensive tasks. When faced with a repeated request featuring the same key, the server should return the current state of the operation instead of initiating a new one. An effective model for the state of operations could be: reserved - completed - failed. This reservation should be specific to the user and the operation in question.

Additionally, an alternate operation ID can enable the client to inquire about the operation's status after a certain timeout. The user interface can subsequently display "still processing," "completed," or "failed" depending on the state of the operation recorded by the server, rather than the user assuming it from the button click.

However, an upstream timeout is a particularly tricky scenario. A timeout does not always signify that the service provider did not perform any work. Before releasing a reservation or initiating a fresh provider request, it's crucial to ascertain whether the original operation can be discovered or safely retried using the identical idempotency key. Failing to do so could transform a timeout into a situation of duplicated work.

This approach is a design pattern, not an assertion about any specific product implementation. The appropriate quota rule hinges on the product's promise: whether a failed attempt incurs a charge, whether pending work reserves capacity, and how long an operation can remain unresolved without resolution. These choices must be explicitly stated, and then tested under various conditions such as concurrent starts, browser retries, provider timeouts, and delayed responses.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Cardinal vs Ordinal Numbers: Writing Them Correctly in Words

As developers, we write numbers in words more often than we realize. Release notes say "second major release," error messages say "the first argument must be a string," and our UI copy announces "you…

  • Cardinal numbers answer "how many?"
  • Ordinal numbers answer "in what position?"
  • Consistency in usage improves clarity and trust

Who Should Own a Client's Domain and Hosting? A Handover Checklist

If you build sites for clients, this is the setup I use on every project, and the one I'd want any client to insist on from any developer.

  • Domain name should be registered to client's business
  • Hosting should be in client's name and billed to their credit card
  • Client should have control over email, analytics, and Google Business Profile accounts

Kandinsky 6.0 in a pipeline: offload, the untimed default and what to measure

Say your product manager wants "generate a short video with sound" in the app. Kandinsky 6.0, which Kandinsky Lab put on GitHub on 6 October under MIT for both code and weights, is a candidate: text…

  • Kandinsky 6.0 generates short videos with sound from text or text+images.
  • Two model sizes: Lite (3B params) and Pro (29B params).
  • Lite requires much memory, Pro takes 561s for 5s clip.

Multi-Tenant SaaS: Shared Database or One Per Tenant?

If you are building a SaaS product for more than one customer, you will have to answer one early question: how do you separate each customer's data?

  • Shared database with tenantid column offers low cost and simplicity.
  • Separate database per tenant provides strongest data isolation for compliance.
  • Starting with shared model minimizes upfront costs while establishing data separation safeguards.

More from Saturday 17 October →