# HTTP Keep-Alive analysis

**URL:** <https://discuss.httparchive.org/t/http-keep-alive-analysis/102>\
**Category:** Analysis\
**Created:** [November 13, 2013, 11:08am UTC](https://discuss.httparchive.org/t/http-keep-alive-analysis/102 "2013-11-13T11:08:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![igrigorik](https://yyz1.discourse-cdn.com/flex035/user_avatar/discuss.httparchive.org/igrigorik/32/925_2.png) [@igrigorik](https://discuss.httparchive.org/u/igrigorik)\
**Post date:** [November 13, 2013, 11:08am UTC](https://discuss.httparchive.org/t/http-keep-alive-analysis/102/1 "2013-11-13T11:08:22Z")

</div>

HTTP “Keep-Alive” header is an optional header which indicates server’s connection management policy: [http://tools.ietf.org/id/draft-thomson-hybi-http-timeout-01.html](http://tools.ietf.org/id/draft-thomson-hybi-http-timeout-01.html)

* * *

~22% of responses contain “timeout” attribute. The query and the distribution is as follows:

```sql
SELECT 
  REGEXP_EXTRACT(resp_keep_alive,r'max=(\d+)') timeout,
  COUNT(*) cnt
FROM [httparchive:runs.latest_requests] 
GROUP by timeout;

```

![](https://yyz1.discourse-cdn.com/flex035/uploads/httparchive/82/35843a8e841e6715.png)

That’s pretty aggressive! ~65% of responses specify a \<5s timeout - _yikes_. By the time we’re at 30s, we’re at 95%… I guess this is not surprising given that httpd 2.2 uses a 5s default… nginx defaults to 75s.

* * *

~19% of responses contain “max” attribute, with “100” being the most prevalent (85%) default. The query and the distribution is as follows (note that I’m rounding the buckets):

```sql
SELECT maxr, count(*) as cnt FROM (
  SELECT CEIL(INTEGER(REGEXP_EXTRACT(resp_keep_alive,r'max=(\d+)'))/100)*100 maxr,
  FROM [httparchive:runs.latest_requests]
)
GROUP BY maxr

```

![](https://yyz1.discourse-cdn.com/flex035/uploads/httparchive/80/ce32e5f672b318bd.png)

Wondering what max=0 means? Yeah, that doesn’t make much sense does it…

```sql
SELECT * from (
  SELECT pageid, resp_keep_alive, 
    HOST(url) as host, 
    INTEGER(REGEXP_EXTRACT(resp_keep_alive,r'max=(\d+)')) as maxr
  FROM [httparchive:runs.latest_requests]
) WHERE maxr = 0

```

Thankfully, it’s just one misconfigured server (all 300 urls):  
 ![](https://yyz1.discourse-cdn.com/flex035/uploads/httparchive/81/5aace377c31e4c7f.png)

* * *

- [http://en.wikipedia.org/wiki/HTTP\_persistent\_connection](http://en.wikipedia.org/wiki/HTTP_persistent_connection)
- [http://wiki.nginx.org/HttpCoreModule#keepalive\_timeout](http://wiki.nginx.org/HttpCoreModule#keepalive_timeout)
