You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.4 KiB

  1. # Pinging Reliability Tips
  2. Sending monitoring signals over public internet is inherently unreliable.
  3. HTTP requests can sometimes take excessively long or fail completely
  4. for a variety of reasons. Here are some general tips to make your monitoring
  5. code more robust.
  6. ## Specify HTTP Request Timeout
  7. Put a time limit on how long each ping is allowed to take. This is especially
  8. important when sending a "start" signal at the start of a job: you don't want
  9. a stuck ping prevent the actual job from running. Another case is a continuously
  10. running worker process which pings SITE_NAME after each completed item. A stuck
  11. request would block the whole process, so it is important to guard against.
  12. Specifying the timeout depends on the tool you use. curl, for example, has the
  13. `--max-time` (shorthand: `-m`) parameter:
  14. ```bash
  15. # Send a HTTP, 10 second timeout:
  16. curl -m 10 PING_URL
  17. ```
  18. ## Use Retries
  19. To minimize the amount of false alerts you get from SITE_NAME, instruct your HTTP
  20. client to retry failed requests several times.
  21. Specifying the retry policy depends on the tool you use. curl, for example, has the
  22. `--retry` parameter:
  23. ```bash
  24. # Retry up to 5 times, uses an increasing delay between each retry (1s, 2s, 4s, 8s, ...)
  25. curl --retry 5 PING_URL
  26. ```
  27. ## Handle Exceptions
  28. Make sure you know how your HTTP client handles failed requests. For example,
  29. if you use a HTTP library which raises exceptions, decide if you want to
  30. catch the exceptions, or let them bubble up.