setting a new ReadTimeoutHandler for every single write?

brunodecarvalho kindernade at gmail.com
Tue Aug 24 04:15:14 EDT 2010


Joel,


In hotpotato, I took two approaches to support per-request timeout:
- An extremely precise timeout: for each request, launch a separate task on
a Executor (basically a timer-per-thread) and use a CountDownLatch (less
efficient for scenarios where you have tons of requests happening at the
same time), but extremely precise for timeouts;
- A not-so-precise timeout: using a HashedWheelTimer to submit timeouts (way
more efficient, but less accurate, since the intervals are wider).

It really depends on what you need, but if you're aiming for low resource
usage I'd go with a HashedWheelTimer.
Say you configure a HWT with 500ms interval, if you want to timeout a
request in 3 seconds, it can timeout anywhere from 3000ms up to 3500ms. Less
accurate, but nicer on resources (unless you configure a very small
interval...).

If you're raising exceptions, make sure you cache that exception, otherwise
the cost of creating and throwing a new exception for each timeout will
severely impact performance in your system.


Cheers,
  Bruno
-- 
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/setting-a-new-ReadTimeoutHandler-for-every-single-write-tp5455833p5455939.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list