Return-Path: X-Original-To: apmail-logging-log4j-dev-archive@www.apache.org Delivered-To: apmail-logging-log4j-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 84B5D18151 for ; Wed, 3 Jun 2015 14:37:27 +0000 (UTC) Received: (qmail 777 invoked by uid 500); 3 Jun 2015 14:37:27 -0000 Delivered-To: apmail-logging-log4j-dev-archive@logging.apache.org Received: (qmail 727 invoked by uid 500); 3 Jun 2015 14:37:27 -0000 Mailing-List: contact log4j-dev-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Developers List" Reply-To: "Log4J Developers List" Delivered-To: mailing list log4j-dev@logging.apache.org Received: (qmail 717 invoked by uid 99); 3 Jun 2015 14:37:27 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Jun 2015 14:37:27 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id D46C2C0729 for ; Wed, 3 Jun 2015 14:37:26 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.902 X-Spam-Level: *** X-Spam-Status: No, score=3.902 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_REPLY=1, HTML_MESSAGE=3, MIME_QP_LONG_LINE=0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id SyL8skUnSqp4 for ; Wed, 3 Jun 2015 14:37:14 +0000 (UTC) Received: from mail-pd0-f181.google.com (mail-pd0-f181.google.com [209.85.192.181]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id AC9FA43ACE for ; Wed, 3 Jun 2015 14:37:13 +0000 (UTC) Received: by pdbnf5 with SMTP id nf5so8877418pdb.2 for ; Wed, 03 Jun 2015 07:35:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:references:from:content-type:in-reply-to:message-id:date:to :content-transfer-encoding:mime-version; bh=zDgw92e3kdXdO+dO/w2AOvXsMcLWSFo2CMnkEubyHHQ=; b=zZuTXoQWU83DNCgG+BOUXk+x5vAoq/05q+lnE8T7nEWZO3FZhVnwi3tbmp+Cumknyt Z+q+AME3vaDtp4EINtyd4yi9g44yukQgBy1Q/dSZdXekTuL/rmRfBJlXydEpZYyITcdK FVntIZz5D32VptEZb2zGQ8+AjWQ4CsUCqyNavgKjo7qQr8IANa22QsHBXz5aBPy6FAPk 2aRQjPw3mepRtlOM3mr9LrfJhAYFLn6TdSks2Me3yxWreo4JGRQbnuQcWRfOw2nYP6bI T3HZP8VmIHtVbYSMxSqvLHPYyQOrH2oHepPl3xwQuWqf7YIPJlex8dSTFzzxbWufhksE 8t9A== X-Received: by 10.68.94.193 with SMTP id de1mr22582135pbb.153.1433342137189; Wed, 03 Jun 2015 07:35:37 -0700 (PDT) Received: from [10.72.0.135] (pw126253160002.6.panda-world.ne.jp. [126.253.160.2]) by mx.google.com with ESMTPSA id v9sm993249pdr.96.2015.06.03.07.35.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Jun 2015 07:35:36 -0700 (PDT) Subject: Re: Fastest appender for local structured storage References: From: Remko Popma Content-Type: multipart/alternative; boundary=Apple-Mail-2B488209-3A6D-4FF0-A523-4790C689C7A5 X-Mailer: iPhone Mail (11D257) In-Reply-To: Message-Id: <7D929D35-9E49-4833-8681-153887EFAEE0@gmail.com> Date: Wed, 3 Jun 2015 23:35:30 +0900 To: Log4J Developers List Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (1.0) --Apple-Mail-2B488209-3A6D-4FF0-A523-4790C689C7A5 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable MBs per minute should not be a problem for a modern HDD.=20 See http://www.eecs.berkeley.edu/~rcs/research/interactive_latency.html Disk seeks are expensive though, so you'll want to buffer your I/O. Big sequ= ential writes are relatively cheap.=20 Log4j's RandomAccessFileAppender (optionally async to ensure bursts don't sl= ow down your app) should be sufficient.=20 For your data structure you could consider fixed length binary records. This= is blazingly fast.=20 In a low-latency trading app I was logging ~100MB/sec (slightly overdoing it= , ahem). This wrote fixed length binary records to a memory mapped file. Wor= ked very well.=20 Sent from my iPhone > On 2015/06/03, at 17:21, Gary Gregory wrote: >=20 > I have a use case where I want an appender to write to local storage (a fi= le), the file should be structured, such that I can query it later (or load i= t into a database). Since I will log a lot of data very fast (possibly MBs a= minute), I might or might not use log4j in async mode. But the bottom line i= s that I'd like to log to local structured storage without paying the cost o= f going through a database layer (NoSQL, JDBC) or a socket. This makes me wo= nder if I should create a CSV file appender... which would be easy enough. >=20 > Does anyone here have experience with a use case like this? I'm not crazy a= bout running MongoDB on the side just to gather logging, but maybe that's wh= at I'll need to do... >=20 > Thoughts? >=20 > Gary >=20 > --=20 > E-Mail: garydgregory@gmail.com | ggregory@apache.org=20 > Java Persistence with Hibernate, Second Edition > JUnit in Action, Second Edition > Spring Batch in Action > Blog: http://garygregory.wordpress.com=20 > Home: http://garygregory.com/ > Tweet! http://twitter.com/GaryGregory --Apple-Mail-2B488209-3A6D-4FF0-A523-4790C689C7A5 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
MBs per minute should not be a problem= for a modern HDD. 


Disk seeks are expensive though, so you'll want to buffer your I/O. B= ig sequential writes are relatively cheap. 

Lo= g4j's RandomAccessFileAppender (optionally async to ensure bursts don't slow= down your app) should be sufficient. 

For you= r data structure you could consider fixed length binary records. This is bla= zingly fast. 
In a low-latency trading app I was logging ~100= MB/sec (slightly overdoing it, ahem). This wrote fixed length binary records= to a memory mapped file. Worked very well. 

Sent from my= iPhone

On 2015/06/03, at 17:21, Gary Gregory <garydgregory@gmail.com> wrote:

<= /div>
I have a use case where= I want an appender to write to local storage (a file), the file should be s= tructured, such that I can query it later (or load it into a database). Sinc= e I will log a lot of data very fast (possibly MBs a minute), I might or mig= ht not use log4j in async mode. But the bottom line is that I'd like to log t= o local structured storage without paying the cost of going through a databa= se layer (NoSQL, JDBC) or a socket. This makes me wonder if I should create a= CSV file appender... which would be easy enough.

Does an= yone here have experience with a use case like this? I'm not crazy about run= ning MongoDB on the side just to gather logging, but maybe that's what I'll n= eed to do...

Thoughts?

= --Apple-Mail-2B488209-3A6D-4FF0-A523-4790C689C7A5--