Search squid archive

ICAP Persistent Connections vs Retries (with code review)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Mi name is Juan, I am a Software Engineer from Uruguay. I think this message is more suited to the squid-dev mailing list due to the developer-oriented nature of the message but, given that the development list is for people who actually contributes code to Squid, I chose to post here.

I started using Squid a few days ago in order to test its content-adaptation capabilities. The plan was to test the ICAP implementation first and then maybe try the eCAP API as well.

In order to test ICAP, I based my code in the open source PYICAP project, I also ran some tests using the C-ICAP server.

It came to my attention that, even when persistent connections is enabled, Squid closes the ICAP connection everytime a new request arrives, like this:

1. A new request arrives
2. Squid creates a connection to the ICAP server
3. Content is adapted and returned to the client
4. Squid returns the connection to the connection pool
5. A new requests arrives
6. Squid closes the active connection
7. Squid opens a new connection to the ICAP server

Note: I am using only the RESPMOD method.

This tests was performed using Squid 3.5.x. I downloaded the last available tarball (squid-4.0.19), and run the same test, which gave the same results.

So I started digging into the source code and found something interesting:

File:
    /src/adaptation/icap/ServiceRep.cc
Function: 
    Adaptation::Icap::ServiceRep::getConnection(bool retriableXact, bool &reused)

Code:
    if (retriableXact)
        connection = theIdleConns->pop();
    else {
        theIdleConns->closeN(1);
    }

The connection is taken from the set of idle connections  ONLY if retriableXact is set to true.

File:
    /src/adaptation/icap/Xaction.cc
Function:
    Adaptation::Icap::Xaction::openConnection()

Xaction uses the member variable 'isRetriable' as parameter for ServiceRep::getConnection.

The function Xaction::disableRetries() is called from a lot of places, but in my test case was called only two times (per request):

   1. In the function Adaptation::Icap::Xaction::noteCommRead, when Comm::ReadNow returns Comm::OK.

   2. In the function Adaptation::Icap::Xaction::closeConnection, because reuseConnection is set to true.

I am not sure if Xaction objects are reusable, it seems that they are because setting isRetriable to false is affecting the way connections are reused.

Anyway, I think the concept of retriability shuld not be confused with the concept of reusability, but I haven't gone deep enough in order to ensure that.

I appreciate your comments on this. Don't hesitate to contact me should any additional information be needed.


--
Juan
:wq

_______________________________________________
squid-users mailing list
squid-users@xxxxxxxxxxxxxxxxxxxxx
http://lists.squid-cache.org/listinfo/squid-users

[Index of Archives]     [Linux Audio Users]     [Samba]     [Big List of Linux Books]     [Linux USB]     [Yosemite News]

  Powered by Linux