

Efficient data transfer through zero copy in Java - mixmasteralan
https://www.ibm.com/developerworks/linux/library/j-zerocopy/

======
Rauchg
You might want to read this interesting (albeit slightly outdated) post about
leveraging `sendfile` in Node.JS by Peter Griess:

<http://blog.std.in/2010/09/09/using-sendfile-with-nodejs/>

~~~
mikeknoop
Is this still best practice? What's the more "up to date" method?

~~~
justincormack
splice and tee are the newer kernel interfaces, sendfile is now implemented
using them.

~~~
ntoshev
Apparently these primitives haven't found their way to the Node.js land yet...
and sendfile is still undocumented.

~~~
justincormack
Not really surprising given the cross platform focus in Node now.

------
rheide
It's a nice idea, but I wonder about the use cases. How often would a Java
webserver serve a file from disk without modifying it along the way? If
performance is an issue then you'd serve the really static files with nginx
(or a similar alternative), and every other file (jsp templates etc.) would be
read in memory before being sent on.

(Note that I'm not questioning the technique, I just don't entirely agree on
the way the article portrays the benefit of this method in webservers.)

~~~
jbri
Often you're serving big chunks of static content with a little bit of dynamic
content sprinkled in.

You can effectively concatenate stuff by just writing both to the same channel
- which means you can get the zero-copy performance benefits for the static
parts of your data if you know exactly how much static data there is before
you need to write out something dynamic.

~~~
virmundi
But how could we use this in a servlet container environment? Perhaps we'd
wrap the response with a special wrapper to take advantage of this? I'm not
sure.

I can see the use if one would recreate a server from the ground up. But that
would be a rather large task.

~~~
teraflop
Tomcat has supported zero-copy file transfers for years -- since before this
article was written, in fact.

[http://tomcat.apache.org/tomcat-6.0-doc/aio.html#Asynchronou...](http://tomcat.apache.org/tomcat-6.0-doc/aio.html#Asynchronous_writes)

