Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Synchronize or go for object pooling

 
Devesh H Rao
Ranch Hand
Posts: 687
Hibernate jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
i am using a user defined exception in my project to indicate whether the operation done by a particular method is a success or a failure.
A large no of components are goin to use this exception for signalling of the failure thru a log writer which will throw the exception
the flow is somewhat like this
Component.method(fails)>>LOGWriter.StaticMethod()>>MyException.
* the LOGWriter is a class having a static method
which writes the errormesg to a file as well as throw the error.
now the question b4 me is when the traffic gets heavy i think the LOGWriter may not be able to handle the flow even with synchronisation.
pls suggest any solution for the scenario keeping heavy traffic as the primary requirement.......
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are likely to get scalability problems, but not where you think - it might well be the exception handling that's going to bite you. Please realise that throwing an exception is a heavyweight operation. Exceptions should be just that: ways to handle exceptional cases that are not part of the normal program flow. If you expect a sizeable number of operations to fail then arguably that should not be handled using an exception.
- Peter
 
Zakaria Haque
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure why you are throwing the exception from the LOGWriter's method, not the component's method. However, for high traffic it would be best to keep the method threadsafe without using synchronization, that is by using local variables only.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic