Re: [httpapi] RateLimit Header client implementations

Alex Martinez <amr@redhat.com> Thu, 07 January 2021 10:01 UTC

Return-Path: <amartine@redhat.com>
X-Original-To: httpapi@ietfa.amsl.com
Delivered-To: httpapi@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 5104B3A0E2D for <httpapi@ietfa.amsl.com>; Thu, 7 Jan 2021 02:01:40 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -3.069
X-Spam-Level:
X-Spam-Status: No, score=-3.069 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.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 ZxDBBuxYNfgb for <httpapi@ietfa.amsl.com>; Thu, 7 Jan 2021 02:01:38 -0800 (PST)
Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id D98663A0E25 for <httpapi@ietf.org>; Thu, 7 Jan 2021 02:01:37 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610013696; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=WdLR2v81rgx20dRsGYUBZOI0uApiLuRilyBfn0ThxaU=; b=FxQ1yFOjqjz1zu7RdLsiZXnDJg0LiD27iPWdntbvM6OGbW8uSD0PYc0AQC53OmtGE5DjQ7 DRSpDN2iIkJiS/+WSxzsqy8IEy1bQIWZcMq/QtjTognj4cTb2Fd9vn2h0O+c+uEwZF+VCb /u8vBCUfT3FXc4lUtZn22TL1u3Tx9zY=
Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-261-LpxlPEzcOvyvFzYvMicDNg-1; Thu, 07 Jan 2021 05:01:34 -0500
X-MC-Unique: LpxlPEzcOvyvFzYvMicDNg-1
Received: by mail-yb1-f198.google.com with SMTP id e68so9345132yba.7 for <httpapi@ietf.org>; Thu, 07 Jan 2021 02:01:34 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WdLR2v81rgx20dRsGYUBZOI0uApiLuRilyBfn0ThxaU=; b=Nu2t/t9x6LBVsaCvXHZ+k5UAHwt2NNlDmRf9iiFE5uxe43tc/DigbBeRjhPEnaSC4c eSIIspXuhXshDFl8z/vE5MdEsEPvy6k4oqoNPbfZlkGbtD0YMnpsiqKJjPUI6oET+jyR bNE39j6Qqnlydjpaqczlf9pzGCyRJk+8i4r2OEg2g6gZ1iTAneUkGMTMUJUmFa32unv+ KW1kW2MlNRybBjRsdz0Vw7pRG0ucWZ3rRrnpD6VdO3ktARTyy5I6koY61onEA6rG8hkd e0IVawv1AlOaCj8tcAzlHfKhOvmvlld3CkCa5ol8TQ8y1YJVCWDNYxQ7dXYv3dRU5GI6 EhyA==
X-Gm-Message-State: AOAM533HeZC/LrduN+n2viBAD0cUksZ8DXZTa3kqszbhZBoyW6solInf zhT6DFN3k7p444iwVO7phrWtiuz1le+yQv18SP3b2qbSknljlWO1BvIGgf99iMKXpgKL3aemMaT s67ur7g3BR5wiQ6QTxRBXunH8
X-Received: by 2002:a25:bc41:: with SMTP id d1mr12419634ybk.100.1610013693821; Thu, 07 Jan 2021 02:01:33 -0800 (PST)
X-Google-Smtp-Source: ABdhPJzvj7+Po1BuwY7lf4Z9jc9w9csAE7CBuwKbMCY1nK5n7WZztvnS+2xpQajL6b9bG6178NKeOhTWhrvapO7F/ro=
X-Received: by 2002:a25:bc41:: with SMTP id d1mr12419607ybk.100.1610013693582; Thu, 07 Jan 2021 02:01:33 -0800 (PST)
MIME-Version: 1.0
References: <DM6PR01MB49370264EE9621D603FEAA81A3D70@DM6PR01MB4937.prod.exchangelabs.com> <CALmQWfiw+1DJ20=3A5JYNVziS9zvttEOTNFuEZE2y83AbZSrYQ@mail.gmail.com> <BY5PR00MB0837209B7CFF3687EFCD1580F0D19@BY5PR00MB0837.namprd00.prod.outlook.com>
In-Reply-To: <BY5PR00MB0837209B7CFF3687EFCD1580F0D19@BY5PR00MB0837.namprd00.prod.outlook.com>
From: Alex Martinez <amr@redhat.com>
Date: Thu, 07 Jan 2021 10:01:22 +0000
Message-ID: <CALmQWfimVnaf4T+bhF2ZjHM8A6pSFsPurt2gxkN41zWfYkr89Q@mail.gmail.com>
To: Darrel Miller <Darrel.Miller@microsoft.com>
Cc: "darrel@tavis.ca" <darrel@tavis.ca>, "httpapi@ietf.org" <httpapi@ietf.org>, "robipolli@gmail.com" <robipolli@gmail.com>
Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=amartine@redhat.com
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com
Content-Type: multipart/alternative; boundary="0000000000004a378805b84c8658"
Archived-At: <https://mailarchive.ietf.org/arch/msg/httpapi/nKPaDm5aOZBZMfpbKtfiYeVvkY0>
Subject: Re: [httpapi] RateLimit Header client implementations
X-BeenThere: httpapi@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Building Blocks for HTTP APIs <httpapi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/httpapi>, <mailto:httpapi-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/httpapi/>
List-Post: <mailto:httpapi@ietf.org>
List-Help: <mailto:httpapi-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/httpapi>, <mailto:httpapi-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 07 Jan 2021 10:01:40 -0000

Hi Darrel,

On Tue, Jan 5, 2021 at 4:17 PM Darrel Miller <Darrel.Miller@microsoft.com>
wrote:

>
> My assertion is that if we discouraged API providers from punishing
> consumer for reaching a rate limit, and we promote the use of the
> retry-after as a signal to the client to back-off before making another
> call, then there are fewer scenarios where a client is required to
> constantly monitor "the number of calls left before reaching the limit".
> Returning and monitoring "calls remaining" is potentially an expensive
> operation, especially when multiple clients can consume the same quota,
> e.g. in the case of calls per user that is using multiple applications.
>

That's a valid observation. That's why clients receiving these headers
should consider them a hint and the next request they perform could be
responded with new data in the headers that would make little sense if
taken in isolation without further knowledge of what could be consuming the
quotas. Service specific policies specified in the headers could help
reduce that uncertainty, but those are too broad and diverse, so there's
been little discussion on the topic other than allowing people to specify
those so service specific clients can make use of those extra bits of
information.


> > The immediate benefit of these headers to service providers is being
> able to signal expectations
> > to clients so they can adapt.
>
> The question I have is with the existing non-standard headers, how many
> people have actually bothered to write this adaptive client code?  Do we
> believe that lack of standardization has been sufficient to discourage
> people from writing that code?  Are the only people writing that code the
> ones who are trying to avoid punitive behavior?  If so, maybe a best
> practices document that recommends not doing that would be more
> constructive.
>

Yes, I believe that because there is no standardization there's been little
to no effort in writing such adaptive code in generic HTTP clients, but
this is pure speculation. I think it is very likely that most people doing
so are the ones writing service specific clients, and in many cases they
could be the same people that wrote the service in the first place, unless
the service happens to see lots of usage across the board with many
independent clients. At a minimum, retry-after could be used to signal
generic clients that no request should be performed for a while, but that
falls short of the minimum information that generic clients could use with
these headers.


> >  Sometimes it is just a matter of adjusting to some specific rate of
> > resource consumption. Some other times the only way to adapt is just to
> stop using a service
> > entirely for a while or use another endpoint, and that's more useful
> than just returning a 403
> > or 50X without further information, ie. during a maintenance window you
> can use the headers
> > to signal that window with 0 quota units and avoid useless traffic.
>
> Why would a 503 with a retry-after header with a period that matches the
> maintenance window not be sufficient here?
>

You are right, the immediate effect is the same. That said, you would be
lacking some extra information about the nominal quota units and duration
of the current window and the windows applying after this one is elapsed
(ie. after recovery you'd have information about the expected rates, and
those could also signal some sort of punitive policy), though that
information might be next to useless in the current window since the
intended effect is to stop traffic altogether for a while. Yet it would not
work in a closely related scenario in which you would have some partial
maintenance work but keeping the ability to serve clients in a degraded
service manner -- that is, unless you kept giving clients shorter
no-service windows interleaved with service responses as usual, hence
generating a lot more wasteful traffic.

Cheers,
  Alex