We typically deploy REST APIs behind a HAProxy reverse proxy. We often need to enforce SLAs and protect those APIs from being flooded with too many concurrent requests. In this post, I’ll show you a straightforward way to do this with HAProxy’s max_conn setting. Furthermore, I’ll show you how you can quickly verify your rate-limiting strategy. We’ll create a simple test-bed consisting of two REST API instances fronted by a HAProxy instance and we’ll flood them with requests using the ab tool (Apache benchmark – which generates an arbitrary number of concurrent requests to an API). If a specific API gets too many concurrent requests, further requests will be rejected with a http 503 (service unavailable) and a message indicating[…]

Introduction We often need a simple web server as a Docker container to serve up static content (HTML or an Angular app etc). Most people are using lighttpd or nginx for this purpose (both are fast and lightweight). So in this post I’ll take you through the process of creating a minimal Docker container using lighttpd and then one using nginx. In each case, for demonstration purposes, we’ll just serve up a single index.html file. lighttpd nginx