Return-Path: Received: from fg-out-1718.google.com ([72.14.220.156] verified) by mx.softsearch.ru (CommuniGate Pro SMTP 5.1.14) with ESMTP id 63982294 for talk@openhack.ru; Thu, 21 Feb 2008 23:20:22 +0300 Received: by fg-out-1718.google.com with SMTP id 22so129869fge.24 for ; Thu, 21 Feb 2008 12:20:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:received:date:from:to:subject:message-id:references:mime-version:content-type:content-disposition:in-reply-to:user-agent; bh=HYBam7jwjatXpEjv83gVpMlZ/9Q/XFFzc/CewOSIk4s=; b=NZiEkMcafYyttPEg3oujqqN/ZlAfvcqG35VJtC/Yf/w1oMTj6AWbykQFlL8L1FpKIB4LKyqftbwSfjxOBMsKJoPeTMTEZ3cbD9mHHbHbcwbCocRdwb0Akhk0gm8ORqv4jtbxQn76r6acdtBqp0RzbZeoYCdOwEzKyWDo8Nd5NUQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:references:mime-version:content-type:content-disposition:in-reply-to:user-agent; b=mUS+68SsORNI21tO0B+ItG4bbz98vNS1/JsqixDqFsoYwRndXy8QQ6N4vBezmRyojzbqvMAUQg63AdVEQNl6xCa1B10HcSQrgYD+ax6UB+82usa/yBeJMgNKikCv48Ud6neOBBe7xDXO4yQf+ubHuC3+gJCwOj652f1dh7S9p18= Received: by 10.86.96.18 with SMTP id t18mr9934404fgb.13.1203625220166; Thu, 21 Feb 2008 12:20:20 -0800 (PST) Return-Path: Received: from moonlight.home ( [80.246.71.156]) by mx.google.com with ESMTPS id 4sm473569fge.3.2008.02.21.12.20.18 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 21 Feb 2008 12:20:19 -0800 (PST) Received: from moonlight.home (localhost.localdomain [127.0.0.1]) by moonlight.home (Postfix) with ESMTP id 026463A7D5; Thu, 21 Feb 2008 23:20:17 +0300 (MSK) Received: (from tomash@localhost) by moonlight.home (8.13.1/8.13.1/Submit) id m1LKKG4H018964; Thu, 21 Feb 2008 23:20:16 +0300 Date: Thu, 21 Feb 2008 23:20:16 +0300 From: Tomash Brechko To: talk@openhack.ru Subject: Re: Reconnections and mod_perl Message-ID: <20080221202016.GA4821@moonlight.home> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i On Thu, Feb 21, 2008 at 20:31:52 +0100, Kostas Chatzikokolakis wrote: > I'd like to ask wether Cache::Memcached::Fast keeps connections to > memcached servers open, and if so, does it reconnect in case a > connection drops? Yes for both questions. Upon the request to a particular server (which servers will be used depends by requested keys), if there's no connection to the server yet, C::M::F connects to it (or gives up after connect_timeout seconds). The module doesn't close the connection until either: - C::M::F is destroyed. - server sends error CLIENT_ERROR, SERVER_ERROR, ERROR, and close_on_error is set (default). These errors are very unlikely to happen, but when they do, it's better to close the connection to avoid out-of-sync protocol state. - connection drops. Connection drop is detected during request processing. In this case C::M::F closes it's local endpoint, and request processing is continued unless all requested servers are dead. Then everything starts from the beginning: when the new request comes C::M::F again sees that there's no connection to the server, and tries to reconnect. You will likely want to set max_failures => 1, failure_timeout => 5, where 5 is number of seconds after failure during which no reconnect attempt will be maid in order to not waste all the time trying to reconnect to dead memcached over and over again. As said above, failure of one server does not affect the requests to other servers. In particular multi-key request will succeed for all keys but those dispatched to the failed server. > I want to use the module under mod_perl, and the natural thing to do is > to keep a pool of C::M::F objects in a global hash, to avoid creating a > new object in each request (similarly to what Apache::DBI does for DBI). AFAIK some people use it exactly this way. -- Tomash Brechko