HTTP Request Gateway Timeout in Linode instances

Recently I faced HTTP request timeout in one of my Linode instances, and this post will illustrate how I overcome it.

OK, to the last, this is not Linode issues, but my setting issues.

First, this is a Node JS Express System to generate report. One HTTP request came in, a backend quite long running process (over 30 seconds) is running to generate the report and return the result, and it faced HTTP request gateway timeout.

The first thing I do is to add in one Express middleware, to explicitly set the request connection timeout in every connection.


var requestTimeout=120000;
app.use(function(req, res, next) {
req.connection.setTimeout(requestTimeout);
next();
});

This code add an explicit request timeout at 120 seconds for each HTTP request to Node.JS Express system.

But this still not solving the issues, the gateway timeout still happening.

After googling, what I found this issues on Linode other people facing is related to Nginx. Then I just realized that my application frontend is using Haproxy. I quickly find the Haproxy configuration file, and modified the following line


backend domain_reporting_backend
mode http
option forwardfor
timeout server 120000
timeout connect 4000

I changed timeout server value as 120000, and restart Haproxy service. Then the request gateway timeout is gone.

The conclusion is, Linode is not putting on the request timeout limit to applications hosted on it, is not like Heroku explicitly putting 30 seconds timeout limit, which if your HTTP requests last over 30 seconds, Heroku will hang up your request and your browser will see this gateway timeout error.

Author: fyhao

Jebsen & Jessen Comms Singapore INTI University College Bsc (Hon) of Computer Science, Coventry University

Leave a Reply