• ______@lemm.ee
    link
    fedilink
    arrow-up
    7
    ·
    edit-2
    1 year ago

    I never wrote an api that had a health system. Could you help me understand why that matters and how that helps ?

    • hansl@lemmy.world
      link
      fedilink
      arrow-up
      32
      ·
      1 year ago

      Just have an endpoint in your API (like /health) that doesn’t do anything but return “ok”.

      So if your database goes down, your filesystem is full, etc, that endpoint will always return “ok” with HTTP 200. That way you can setup a ping monitoring service that will trigger an alarm if the process itself is down.

      You of course need more pinging for the database server etc. But at least you know which service is down instead of “the whole website is down and we don’t know which parts”.

    • ExLisper@linux.community
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      That’s because you don’t write bugs. Health check are only needed when you’re planning on having bugs in your system. Instead of doing monitoring I prefer to spend a bit more time fixing all the bugs and then my systems never break so no monitoring is needed. Of course the downside is lack of job security. They can fire me and the system will just continue running forever, no support needed. If you add some bugs they cannot fire you because someone needs to keep fixing the broken system.