What is a reverse proxy?
A reverse proxy is a server that forwards requests from the client to another server.
Why use reverse proxies
There are several reasons you might want to use a reverse proxy:
- Load balancing - a reverse proxy can be used to distribute requests across a number of servers.
- Caching - caching and serving content from a reverse proxy can increase performance.
- Security - using a reverse proxy will obscure architectural details of your backend infrastructure as well as server identities (the IP of the origin server for instance).
- Maintainability - in the event that your upstream server moves, you would only need to update the value of the upstream server in a single place.
- Request buffering - Minimizes upstream server execution time.
A closer look at request buffering
Let’s take the example of a client on a slow connection trying to upload a large file (an image for instance) to a server. When the server receives this request it will be blocked until it receives the entire request & processes it. Essentially, the servers execution time will be directly affected by the connection speed of the client.
A reverse proxy will wait to receive all of the request from the client before forwarding it to the upstream server. This means that the actual execution time on the server is greatly reduced, as this server-to-server request is much faster than the client-to-server request.
This pattern can be particularly useful when your upstream server has strict execution time limitations. For example, Netlify’s synchronous serverless functions have an execution limit of 10 seconds, which begins as soon as the http connection is opened. Using a reverse proxy in this case could decrease the risk of hitting that execution limit.
Top comments (0)