Skip to content

Sync 0.3.0: Requests per minute are enforced and previews load on demand

Sync 0.3.0 starts applying each connection’s requests-per-minute limit, has the receiving site wait and retry when it hits that limit, and stops spending a download on a preview nobody asked for.

Requests per minute

A connection’s rate_limit_requests_per_minute was stored before, but nothing read it. Now every REST call from the other site, the WebSocket upgrade and each request on an open socket count against it, once the request has passed the other checks. A wrong download password counts too, so guessing it is bounded. Over the limit, the sender answers 429 with a Retry-After. The default is 600 a minute, 0 means no limit, and the count is kept per node.

The receiving site waits the time it was given and sends the same request again, and its sync page says it is rate limited and retrying in so many seconds. Each wait is capped at 60 seconds, and a request gives up after 300 seconds of waiting in all, which fails that table as rate limited. Both values can be changed with rate_limit_max_wait_seconds and rate_limit_wait_budget_seconds.

A full sync makes one request for the table list and one per page of each table, so at 600 a minute a site with some 200 small tables syncs within the minute. A connection set lower is slowed, not refused.

Previews only on request

Every preview of a sender’s rows counts as a download on the sending site. The sync page used to load one by itself; now it asks for one only when you click Preview rows, and says next to the button: A preview counts as one download on the sending site.

New connections say they are pending

After you create a connection, the message now says that it is pending and must be approved in the list before the other site can use it. The connection form can no longer set a status: only the status buttons, such as Approve, change it.

Upgrading

Requirements are unchanged. Connections saved before this release hold 60 requests a minute, the old column default. Core’s migration V218 raises every connection still at 60 to 600. On a core without V218, raise the value with Connections.update_connection/2 for connections that sync many tables, or their syncs pause every 60 requests.

 

 


Sync 0.3.0. Install or update: {:phoenix_kit_sync, "~> 0.3"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.