views:

318

answers:

1

I am deploying a mod_wsgi application on top of Apache, and have a client program that uses Curl.

On the CURL api on the user side, I have it attempt to reuse connection, but looking at the connections from wireshark, I see that for every HTTP request/response, a new connection is made.

At the end of every HTTP request, the HTTP response header has "Connection: Close"

Is this the same as Keep-Alive? What do I need to do on the Apache/Mod_wsgi side to enable connection re-use?

+1  A: 

You would not generally need to do anything to Apache as support for keep alive connections would normally be on by default. Look at the KeepAlive directive in Apache configuration to work out what it is set to.

On top of that, for keep alive connections to work the WSGI application must be setting a content length in the response, or returning a list for the response where the list contains only a single string. In this latter case mod_wsgi will automatically add a content length for the response. The response would generally also need to be a successful response as most error responses would cause connection to be closed regardless.

Even having done all that, the issue is whether the ability of curl to fetch multiple URLs even makes use of keep alive connections. Obviously separate invocations of curl will not be able to, so that you are even asking this questions suggests you are trying to use that feature of curl. Only other option would be if you were using a custom client linked to libcurl and using its library and so you meant libcurl.

Do note that if access to Apache is via a proxy, the proxy may not implement keep alive and so stop the whole mechanism from working.

To give more information, need to know about how you are using curl.

Graham Dumpleton