Return-Path: X-Original-To: apmail-lucene-solr-user-archive@minotaur.apache.org Delivered-To: apmail-lucene-solr-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A95359970 for ; Fri, 7 Sep 2012 02:23:56 +0000 (UTC) Received: (qmail 39726 invoked by uid 500); 7 Sep 2012 02:23:53 -0000 Delivered-To: apmail-lucene-solr-user-archive@lucene.apache.org Received: (qmail 39676 invoked by uid 500); 7 Sep 2012 02:23:53 -0000 Mailing-List: contact solr-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: solr-user@lucene.apache.org Delivered-To: mailing list solr-user@lucene.apache.org Received: (qmail 39664 invoked by uid 99); 7 Sep 2012 02:23:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Sep 2012 02:23:53 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FSL_RCVD_USER,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of daubman@gmail.com designates 209.85.215.48 as permitted sender) Received: from [209.85.215.48] (HELO mail-lpp01m010-f48.google.com) (209.85.215.48) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Sep 2012 02:23:46 +0000 Received: by lagr15 with SMTP id r15so1846978lag.35 for ; Thu, 06 Sep 2012 19:23:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=1O/rzeJ/E9S74QyKbRqi+/96bYplh65+WbdbpDH4O9U=; b=dCoITPI+btCGFNKw0CnLX2J1b5AUT3VAjh69RPz4Makh/nLqBcFVe0rXd77Vd7fgY1 6AVWvNOZXutv2VPuBIf3Vd/Sy+kM0FmhwUP1AnT0/iIRlAPLE9M8G/eIEAltDjUu58H/ 86A/U5us/t3Rvj0iNseLlTJEnhxKSpniAmv0OWFa5AMaSAiTKQaDu88Xw67Y4DilPtfJ UMh4heKiuKYK1TX3/tCOlhsOAfSYME55y5fz75Zk7RsFYgtIA/i9SmOXct4xjAcz3xiE SVe/Z8a4cSyi1m5yFv3mswjEHgSOvBfXORQtCMTgJFlVd+zl/wlF+pDEr2xCKy5TIIgy U7dw== MIME-Version: 1.0 Received: by 10.152.108.206 with SMTP id hm14mr3636536lab.53.1346984605359; Thu, 06 Sep 2012 19:23:25 -0700 (PDT) Received: by 10.152.124.19 with HTTP; Thu, 6 Sep 2012 19:23:25 -0700 (PDT) In-Reply-To: References: Date: Thu, 6 Sep 2012 22:23:25 -0400 Message-ID: Subject: Re: Solr request/response lifecycle and logging full response time From: Aaron Daubman To: solr-user@lucene.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org I'd still love to see a query lifecycle flowchart, but, in case it helps any future users or in case this is still incorrect, here's how I'm tackling this: 1) Override default json responseWriter with my own in solrconfig.xml: 2) Define JSONResponseWriterWithTiming as just extending JSONResponseWriter and adding in a log statement: public class JSONResponseWriterWithTiming extends JSONResponseWriter { private static final Logger logger = LoggerFactory.getLogger(JSONResponseWriterWithTiming.class); @Override public void write(Writer writer, SolrQueryRequest req, SolrQueryResponse rsp) throws IOException { super.write(writer, req, rsp); if (logger.isInfoEnabled()) { final long st = req.getStartTime(); logger.info(String.format("Total solr time for query with QTime: %d is: %d", (int) (rsp.getEndTime() - st), (int) (System.currentTimeMillis() - st))); } } } Please advise if: - Flowcharts for any solr/lucene-related lifecycles exist - There is a better way of doing this Thanks, Aaron On Thu, Sep 6, 2012 at 9:16 PM, Aaron Daubman wrote: > Greetings, > > I'm looking to add some additional logging to a solr 3.6.0 setup to > allow us to determine actual time spent by Solr responding to a > request. > > We have a custom QueryComponent that sometimes returns 1+ MB of data > and while QTime is always on the order of ~100ms, the response time at > the client can be longer than a second (as measured with JMeter > running on the same server using localhost). > > The end goal is to be able to: > 1) determine if this large variance in response time is due to Solr, > and if so where (to help determine if/how it can be optimized) > 2) determine if the large variance is due to how jetty handles > connections, buffering, etc... (and if so, if/how we can optimize > there) > ...or some combination of the two. > > As it stands now, where the second or so between when the actual query > finishes as indicated by QTime, when solr gathers all the data to be > returned as requested by fl, and when the client actually receives the > data (even when the client is on the localhost) is completely opaque. > > My main question: > - Is there any documentation (a diagram / flowchart would be oh so > wonderful) on the lifecycle of a Solr request? So far I've attempted > to modify and rebuild solr, adding logging to SolrCore's execute() > method (this pretty much mirrors QTime), as well as add timing > calculations and logging to various different overriden methods in the > QueryComponent custom extension, all to no avail so far. > > What I'm getting at is how to: > - start a stopwatch when solr receives the request from the client > - stop the stopwatch and log the elapsed time right before solr hands > the response body off to Jetty to be delivered back to the client. > > Thanks, as always! > Aaron