Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 25th, 2005, 06:22 PM
noslenj123 noslenj123 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Phoenix, AZ
Posts: 484 noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level)noslenj123 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 22 h 6 m 30 sec
Reputation Power: 30
Efficient application logging design in multi-threaded apps

In an application that has to do a tremendous amount of logging to disk, we are trying to understand techniques for multi-threaded apps.

In our first design, each thread would call a logging function which blocks other threads from calling until it's complete. This slows down not only the thread that is writing but all others waiting to write.

So we implement a logging queue in memory where threads would lock a resource just long enough to copy the logging information to the memory table and then continue on. A seperate logging thread would cycle, locking that same resource long enough to copy a message out of the table, and then it could take it's time writing to disk. The problem now is that the other threads enter new messages faster than the logger thread and it gets way behind and as the queue grows we consume large amounts of memory.

Does anyone have any thoughts on an efficient design or know where to look for articles on it?

Tx for your thoughts!
__________________
There are only 10 kinds of people in this world. Those who understand binary, and those who don't!

Reply With Quote
  #2  
Old September 10th, 2005, 11:12 PM
eworley eworley is offline
Cypher
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: La Jolla, CA
Posts: 121 eworley User rank is Lance Corporal (50 - 100 Reputation Level)eworley User rank is Lance Corporal (50 - 100 Reputation Level)eworley User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 57 m 6 sec
Reputation Power: 5
Quote:
Originally Posted by noslenj123
In an application that has to do a tremendous amount of logging to disk, we are trying to understand techniques for multi-threaded apps.

In our first design, each thread would call a logging function which blocks other threads from calling until it's complete. This slows down not only the thread that is writing but all others waiting to write.

So we implement a logging queue in memory where threads would lock a resource just long enough to copy the logging information to the memory table and then continue on. A seperate logging thread would cycle, locking that same resource long enough to copy a message out of the table, and then it could take it's time writing to disk. The problem now is that the other threads enter new messages faster than the logger thread and it gets way behind and as the queue grows we consume large amounts of memory.

Does anyone have any thoughts on an efficient design or know where to look for articles on it?

Tx for your thoughts!


I would recommend using a syncronized logging method that will spawn a new thread for each log activity and assign a low priority to that thread to perform it's job. This way the only lag in this method will be the spawn of a new thread, which should be insignifigant. Hopefully this will remove delay that could be apparent to calling threads.

Cheers,
Cypher

Reply With Quote
  #3  
Old September 19th, 2005, 03:22 PM
ryanwarren ryanwarren is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 20 ryanwarren User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 5 m 53 sec
Reputation Power: 0
log4j from apache is really fast.

Reply With Quote
  #4  
Old September 20th, 2005, 04:20 AM
lazy_yogi lazy_yogi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 325 lazy_yogi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 58 m 36 sec
Reputation Power: 6
If you are talking serious performance issues, you might want to have this on a seperate box.

Your application could send the log over a web service (or remoting if .Net, or RMI if Java using binary formatter).

On the server, it would place the log message in a queueing component so the comsumer of the service doesn't have to wait for it to be processed before returning to them.

It just means your infrastructure team has an extra box to take care of. It's really not that hard, and it's a scalable solution, since you have a new layer there for logging.

Regards,
Eli

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > Efficient application logging design in multi-threaded apps


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT