Re: Appropriate use of HTTP status codes for application health checks

Matthew Kerwin <matthew@kerwin.net.au> Thu, 23 February 2017 09:40 UTC

Return-Path: <ietf-http-wg-request+bounce-httpbisa-archive-bis2juki=lists.ie@listhub.w3.org>
X-Original-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Delivered-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id CC40212969B for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Thu, 23 Feb 2017 01:40:50 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -6.4
X-Spam-Level:
X-Spam-Status: No, score=-6.4 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_HI=-5, RCVD_IN_SORBS_SPAM=0.5, RP_MATCHES_RCVD=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UeZQOrAARpOR for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Thu, 23 Feb 2017 01:40:48 -0800 (PST)
Received: from frink.w3.org (frink.w3.org [128.30.52.56]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 2EAF11295F3 for <httpbisa-archive-bis2Juki@lists.ietf.org>; Thu, 23 Feb 2017 01:40:47 -0800 (PST)
Received: from lists by frink.w3.org with local (Exim 4.80) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1cgpq3-0000eV-Ku for ietf-http-wg-dist@listhub.w3.org; Thu, 23 Feb 2017 09:37:27 +0000
Resent-Date: Thu, 23 Feb 2017 09:37:27 +0000
Resent-Message-Id: <E1cgpq3-0000eV-Ku@frink.w3.org>
Received: from titan.w3.org ([128.30.52.76]) by frink.w3.org with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from <phluid61@gmail.com>) id 1cgppv-0000ci-Ps for ietf-http-wg@listhub.w3.org; Thu, 23 Feb 2017 09:37:19 +0000
Received: from mail-it0-f46.google.com ([209.85.214.46]) by titan.w3.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <phluid61@gmail.com>) id 1cgppn-0002oX-Rm for ietf-http-wg@w3.org; Thu, 23 Feb 2017 09:37:14 +0000
Received: by mail-it0-f46.google.com with SMTP id 203so168577886ith.0 for <ietf-http-wg@w3.org>; Thu, 23 Feb 2017 01:36:50 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=uMfM0GdCWE7/jkaoRcUOPCIAy6fgInmScBlm9Rg5WFU=; b=rCuM4URqs5cpIRftTF+h1z8XzWe6nAFDH2l0CHFYxvPJuN0u0sXNtqICWBIIx8bKVF PB7ovCPA3zbsUBh73oHieoaiqbb/eLUofjrM3q6us/YnTN6FbcE3J5rrDyjb9x1xHUQy RcGSHijlbjHgMoMt545JA6qpKLSCS8Y+aQCxXhh26foWYP1KkqQDkD7YiU0wM/v3Be7k TOgf3e7vNXyPBCZsFoe23+/x8svEAFp+00jAXjSY/xA03YY+f4y/3/hgz09fK65JZ192 fGowpJsg9Bixkxm0oKPawEK17MgW0djMu3Px3Rp8YsP/egAVQbm+Vzbaa9QwPpsrOKUd rRzg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=uMfM0GdCWE7/jkaoRcUOPCIAy6fgInmScBlm9Rg5WFU=; b=mdHgm+SL3nVRgRP6eK/o1mULYSBfP8BzmoO45r6/pjS6clGhCi+vxr8iGR3wGk+yKg t+nS4xkFQ8IpYcMdNRDWW+K3TjAu/Auwk/bB2QwsF67dS2yDHAt71zbrO+oJ2+jF04Pn cUHo5qSBFl9ptvvExqJE5qzHaDGqNf7cC47rjiloc8vhy4WCs1xA39p91+7bO3g9VYSd BQXADY7eyuKWZVtaVkz4vxIQpiVIRi6h98ZG4gRTWplTv8cGGlALta6Vwr6IIqQ+yiYS P4O9Qio7zJRYsXMVti631b0ZM5r2DaXneSrsB1vjTL7QbE1ghPpurvm5SKH80ft2wBfC t39w==
X-Gm-Message-State: AMke39m0nD1nGUwl6NLZsq8UMTkt7eXR/LLiMGMaX/KkU8SkrkLlzXxNS6W6hoIMfKlnuY0YyM32XpZzvErYNg==
X-Received: by 10.36.143.10 with SMTP id k10mr2019056itd.55.1487842605173; Thu, 23 Feb 2017 01:36:45 -0800 (PST)
MIME-Version: 1.0
Sender: phluid61@gmail.com
Received: by 10.107.154.145 with HTTP; Thu, 23 Feb 2017 01:36:44 -0800 (PST)
In-Reply-To: <CADfyV-Pa0fu2SDwLYzMrUe4D0Tv0wu27pmHpLjCxQXR3ev4mmA@mail.gmail.com>
References: <CADfyV-Pa0fu2SDwLYzMrUe4D0Tv0wu27pmHpLjCxQXR3ev4mmA@mail.gmail.com>
From: Matthew Kerwin <matthew@kerwin.net.au>
Date: Thu, 23 Feb 2017 19:36:44 +1000
X-Google-Sender-Auth: vMtllh4CdZCner_TjA4rEYDog1Y
Message-ID: <CACweHNAXEYcx2t5XgaGAmjz2tOok1j1-r1QB+Up8fV1umGJoCw@mail.gmail.com>
To: matt <drbearded@gmail.com>
Cc: "ietf-http-wg@w3.org" <ietf-http-wg@w3.org>
Content-Type: multipart/alternative; boundary="001a1143a574f692fb05492f598f"
Received-SPF: pass client-ip=209.85.214.46; envelope-from=phluid61@gmail.com; helo=mail-it0-f46.google.com
X-W3C-Hub-Spam-Status: No, score=-4.8
X-W3C-Hub-Spam-Report: AWL=-1.101, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FORGED_FROMDOMAIN=0.198, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, W3C_AA=-1, W3C_WL=-1
X-W3C-Scan-Sig: titan.w3.org 1cgppn-0002oX-Rm 49696198b869e508b4606d019599f81b
X-Original-To: ietf-http-wg@w3.org
Subject: Re: Appropriate use of HTTP status codes for application health checks
Archived-At: <http://www.w3.org/mid/CACweHNAXEYcx2t5XgaGAmjz2tOok1j1-r1QB+Up8fV1umGJoCw@mail.gmail.com>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/33592
X-Loop: ietf-http-wg@w3.org
Resent-Sender: ietf-http-wg-request@w3.org
Precedence: list
List-Id: <ietf-http-wg.w3.org>
List-Help: <http://www.w3.org/Mail/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>

Hi Matt,

On 23 February 2017 at 10:54, matt <drbearded@gmail.com> wrote:

> Hello,
>
> My colleagues and I are involved in a debate about the proper usage of
> HTTP return codes for application health pages.
>
> For instance, you have a /health page that returns JSON listing your
> application’s dependencies as either “Up” or “Down”
>
> Some suggest that it is acceptable for your /health page to return an
> unassigned 5xx or 503 if the /health page returns successfully, but the
> page results indicate the application is not healthy. Spring Boot
> <https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-1.1-Release-Notes#healthindicators> has
> done this. Although I have reservations about 503 since your request for
> the page was handled successfully.
>
> Other contend that your /health page should *always* return a 200
> regardless of whether the page results is indicative of application health
> or not.
>
> As a layman I can see the argument for both sides, and it seems both
> practices have been used in the past. I perused the RFCs but I don’t feel
> like I found the ‘silver bullet’ answer on this.
>
> Kindly,
>
> Matt
>

The trick with REST (assuming that's what you're going for here) is
defining the resources.

If the resource is a status page, then it can return 200 to say that
the *status
*is available, even if the available status is "unavailable".

If the resource is the dependency itself (or a model or representation
thereof), it can return a 5xx or whatever to say that the *dependency* is
unavailable.

In general, I say: do what feels right, and document it clearly.

Of course, I'm the biggest REST expert on this list, so I'm 100% correct.

Cheers
-- 
  Matthew Kerwin
  http://matthew.kerwin.net.au/