DNS , file length, and other async issues.

Norman Maurer norman.maurer at googlemail.com
Tue Oct 18 03:35:52 EDT 2011


2011/10/18 Kevin Burton <burtonator at gmail.com>:
> Hey gang.
> A couple issues I noticed that aren't really specified anywhere.
> I the HTTP get example in netty you call file.length() which blocks.
> It may not seem like much but on a loaded server if your inodes aren't
> cached you're going to be stat()ing and this will kill performance.
> Is there an 'official' solution to this problem?
> Probably have all initial requests to into a "length" queue first which is
> bounded before serving them off disk.
> If you can keep this out of your event queue this means that files that are
> in the page cache can still be served without blocking.
> ...
> on another issue. I don't see a solution for dealing with DNS.
> I assume a similar pattern could/should be used.
> All initial requests would go into a queue, then A DNS request (caching it
> of course) is issued to resolve the name, then the request made and then all
> remaining IO handled by Netty.
> I'm using a similar pattern for HTTP PUT on JDK 1.6... requests go into a
> queue and then that queue is drained and the files written to disk.
>

Hi there,

you are right calling File.length this way is prolly not a good thing.
You would be better of to add an ExecutionHandler in front of it which
will offload the task to an other ThreadPool and so keep the
IO-Worker-Thread not blocked.

The same is true for DNS stuff.

There is also a async DNS provider called dnsjnio which use dnsjava.
This allows you todo DNS queries in a non-blocking manner.

Hope this helps,
Norman


More information about the netty-users mailing list