RHEL標準の機能のみで、外から追加のモジュール等を導入することなしに採用可能な方法の候補を列挙してみた。また商用JavaEEサーバの場合は専用の機能があるケースもありそうだが、Tomcatの場合に使える方法の候補も調べてみた。
制御箇所の候補
- TCP/IPレベルで制御する
- APIゲートウェイで制御する
- Webサーバで制御する
- アプリケーションサーバで制御する
- アプリケーション内で制御する
- クライアント側に協力してもらう
- レスポンスにrate limitの情報を含める*13
評価の必要な観点
- CGNを考慮した流量制御が可能か(リクエスト送信元ポート番号が考慮可能か)
- 同様に、RFC 6302を考慮してログが残せるか
- URLパスごとの制御が可能か
- 「最大○リクエスト」に加えて「N秒間に最大Mリクエスト」という制御が可能か
- リクエスト数での制御が可能か
- ネットワーク帯域での制御(最大○Mbpsまで許可)が可能か
*1:https://tldp.org/HOWTO/Linux+IPv6-HOWTO/ch21s02.html
*2:https://firewalld.org/documentation/man-pages/firewalld.richlanguage.html#idm140021570236992
*3:https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/8/html/securing_networks/getting-started-with-nftables_securing-networks#blocking-ip-addresses-that-attempt-more-than-ten-new-incoming-tcp-connections-within-one-minute_assembly_using-nftables-to-limit-the-amount-of-connections
*4:https://docs.aws.amazon.com/ja_jp/apigateway/latest/developerguide/api-gateway-request-throttling.html
*5:https://stackoverflow.com/a/20356408/3902663
*6:http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass
*7:https://www.kimullaa.com/entry/2017/12/30/113814
*8:https://stackoverflow.com/a/40117700/3902663
*9:例: http://itdoc.hitachi.co.jp/manuals/link/cosmi_v0870/APKW/EU050103.HTM
*10:https://guava.dev/releases/22.0/api/docs/index.html?com/google/common/util/concurrent/RateLimiter.html
*11:https://github.com/vladimir-bukhtoyarov/bucket4j
*12:例: https://techblog.bozho.net/basic-api-rate-limiting/
*13:例: https://developer.twitter.com/en/docs/twitter-ads-api/rate-limiting