Retries and replays

If your server is down or slow, KnownVisitors keeps trying for about 8½ hours. After that you can send any failed delivery again from the app.

What counts as delivered

A delivery succeeds when your server answers with any 2xx status within 10 seconds. Everything else counts as a failure:

Retry schedule

A failed delivery is tried again on this schedule, 6 tries in all:

TryWhen
1Right away
2About 1 minute after try 1
3About 5 minutes after try 2
4About 30 minutes after try 3
5About 2 hours after try 4
6About 6 hours after try 5

The X-KV-Delivery-Attempt header tells you which try a request is. After the 6th try fails, the delivery is marked as failed and we stop.

Replay a failed delivery

Open the address in the app and find the delivery in Recent deliveries. Fix the problem on your server, then click Replay to send it again.

Handle duplicates

You can receive the same event more than once, for example when your server saved an event but answered too late. Every try of an event carries the same id, also sent as the X-KV-Event-Id header.

  1. Record the IDs you have processedStore each event id after you save it.
  2. Skip ones you have seenIf an id arrives again, answer 200 and do nothing else.

Use person_id as the key for the person in your system. The same person always has the same ID, so a duplicate updates a record instead of creating a second one.

Order of events

Retries mean events can arrive out of order. Do not rely on the order requests arrive in. Use the created time on the event if you need to know which came first.

Answer quickly

Save the event and answer 200 first, then do slow work such as calling other services in the background. Slow handlers are the most common reason deliveries time out and get retried.