Jump to content

Question about KEEPALIVES...


allworknoplay

Recommended Posts

Ok I pretty much understand how keepalives work but I'm still confused about one thing...

 

 

 

If say I have an API that receives data, there is no images, and it connects to a mysql backend.

 

Diagram

---------

Apache/PHP <------ My Windows Application (connects once every 5 mins)

 

So let's say I turn off keepalives and when data reports in and connects to my API, if the data is 100K

in size, will the connection stay open until the 100K is all POST'ed?

 

My windows program does not make multiple connections, it only connects to my API once every 5 minutes.

 

Right now I have keepalives turned on with timeout of 2 seconds. I decided to give it a 2 second buffer just incase

but the truth is, if I really don't want it, then I'd like to turn off keepalives altogether...

 

But my concern is, I don't want the connection to DROP if my data hasn't all been POSTed yet...

 

Thoughts?

 

TIA

 

Link to comment
Share on other sites

A few thoughts. May depend on the fine details of what your app does. There may be missing information

in your question. However...

 

HTTP is a stateless transaction concept.

http://en.wikipedia.org/wiki/Stateless_server

Hence the many problems of trying to make HTTP work as if it were stateful (session strings, cookies etc.)

 

Keepalive should be there to keep the connection alive whilst idle not during active transmission

 

You can observe all of this yourself on the Windows end by running a copy of Sysinternals TCPView

http://www.sysinternals.com  (Now Microsoft and as always you can invariably not rely on bookmarks here)

Try http://technet.microsoft.com/en-gb/sysinternals/677683af-3f5e-42ea-8116-9c92acd2c271.aspx

 

Keepalive as far as I can remember is merely to improve the socket and process efficiency at the server end

Hence...

 

The Keep-Alive extension to HTTP/1.0 and the persistent connection feature of HTTP/1.1 provide long-lived HTTP sessions which allow multiple requests to be sent over the same TCP connection. In some cases this has been shown to result in an almost 50% speedup in latency times for HTML documents with many images.

 

Note highlighted... Once...

http://httpd.apache.org/docs/2.0/mod/core.html#keepalivetimeout

 

The number of seconds Apache will wait for a subsequent request before closing the connection. Once a request has been received, the timeout value specified by the Timeout directive applies.

 

Setting KeepAliveTimeout to a high value may cause performance problems in heavily loaded servers. The higher the timeout, the more server processes will be kept occupied waiting on connections with idle clients.

 

You may be more interested in this though...

http://httpd.apache.org/docs/2.0/mod/core.html#timeout

 

The TimeOut directive currently defines the amount of time Apache will wait for three things:

 

  1. The total amount of time it takes to receive a GET request.

  2. The amount of time between receipt of TCP packets on a POST or PUT request.

  3. The amount of time between ACKs on transmissions of TCP packets in responses.

 

We plan on making these separately configurable at some point down the road.

 

Link to comment
Share on other sites

Hmmm I'm mystified by these two quotes...

 

The number of seconds Apache will wait for a subsequent request before closing the connection. Once a request has been received, the timeout value specified by the Timeout directive applies.

 

 

1. The total amount of time it takes to receive a GET request.

 

 

 

So ok, I think what that means is, if my timeout is 2 seconds, then once a connection is received, it holds that connection for 2 more seconds?

 

So if my GET/POST takes 30 seconds to insert data, does that mean the other 28 seconds never gets input?

 

Sorry for all these questions, a quick primer on me, I am your typical admin that has to setup servers, switches, php, apache, mysql, firewalls...basically jack of all trades, master of none...

 

So that is my downfall, I unfortunately have a tough time REALLY getting good at one thing thing so when an issue occurs,

I scramble to try to figure it out and everything else is low priority..

 

But again, thanks Madmax for taking the time to try to help me out!!

 

 

 

Link to comment
Share on other sites

The nature of my application is very chatty. Basically here's data I need to post, put it in the DB and voila...that's it...

connection ends....

 

There are no sessions, I turned off keepalive on the second load balanced server and I saw no difference!

 

So I think I might as well globally turn off keepalive on the other server...

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.