Gzip compression/decompression in Netty

1,310 views
Skip to first unread message

Guillaume Bort

unread,
Dec 4, 2012, 9:40:35 AM12/4/12
to play-fram...@googlegroups.com
Hi all,

I just noticed that we still have this gzip compression enabled in Netty:


It was introduced by a pull-request, but we shouldn't have it enabled at this level.

If you want it in the JVM, it should be possible to enable at the application level (via a Gzip Filter). And if you want it at the server level, it is better to handle it at the reverse proxy, or network infrastructure level.

I propose to remove this. 

(Actually we found strange bugs with this compression on one of our application. Not sure what is the cause, but having if hard-wired by default without any option to disable it, or to enable it for sone Actions only, makes it painful).

--
Guillaume Bort, http://guillaume.bort.fr

Guillaume Bort

unread,
Dec 4, 2012, 9:44:28 AM12/4/12
to play-fram...@googlegroups.com
Erratum:

We should handle 'decompression' to be able to receive gzip encoded requests. But not compress automatically the response. So I propose to remove only the 'compressor' handler.

Sadek Drobi

unread,
Dec 4, 2012, 10:05:39 AM12/4/12
to Guillaume Bort, play-fram...@googlegroups.com
I agree.


--
 
 

James Roper

unread,
Dec 10, 2012, 10:56:27 PM12/10/12
to Sadek Drobi, Guillaume Bort, play-fram...@googlegroups.com
I agree too.  Over the weekend I wrote gzip/gunzip enumeratees.  They can easily be used on a per action basis, and it wouldn't be hard to write a filter that used it automatically if people wanted.



--
 
 

Guillaume Bort

unread,
Dec 11, 2012, 3:09:06 AM12/11/12
to James Roper, Sadek Drobi, play-fram...@googlegroups.com
Cool! Would it make sense to create a Filter from this and to have it built-in in the play-filters project?

Ivan Meredith

unread,
Dec 11, 2012, 3:18:46 PM12/11/12
to play-fram...@googlegroups.com, James Roper, Sadek Drobi
+1 to that.

Compression is an especially huge deal when you have high latencies between server and client, and filters seem like the right place to use this. Of course if the iteratee was exposed it could be reused per action too.

Sadek Drobi

unread,
Dec 11, 2012, 4:09:00 PM12/11/12
to James Roper, Guillaume Bort, play-fram...@googlegroups.com
Great. What about having Enumeratee[A,Array[Byte]] having and implicit of Writeable[A]

def gzip[A:Writeable](...):Enumeratee[A,Array[Byte]]


On Tue, Dec 11, 2012 at 4:56 AM, James Roper <james...@typesafe.com> wrote:

Sadek Drobi

unread,
Dec 11, 2012, 4:09:44 PM12/11/12
to Ivan Meredith, play-fram...@googlegroups.com, James Roper
On Tue, Dec 11, 2012 at 9:18 PM, Ivan Meredith <iv...@ivan.net.nz> wrote:
+1 to that.

Compression is an especially huge deal when you have high latencies between server and client, and filters seem like the right place to use this. Of course if the iteratee was exposed it could be reused per action too.

It is exposed, you can send an Enumerator to play.

Ivan Meredith

unread,
Dec 11, 2012, 4:59:01 PM12/11/12
to Sadek Drobi, play-fram...@googlegroups.com, James Roper
Err sorry I meant that the impl of the enumator is not private for the
filter it could be reused.

James Roper

unread,
Dec 11, 2012, 8:12:37 PM12/11/12
to Sadek Drobi, Guillaume Bort, play-fram...@googlegroups.com
On Wed, Dec 12, 2012 at 8:09 AM, Sadek Drobi <s...@zenexity.com> wrote:
Great. What about having Enumeratee[A,Array[Byte]] having and implicit of Writeable[A]

I feel like this should be a separate enumeratee, ie

def transformWriteable[A](writeable: Writeable[A]) = Enumeratee.map(writeable.transform _)

and then composed with the gzip enumeratee.  We could also provide the following helper function:

def writeable[A](content: A*)(implicit writeable: Writeable[A]) = Enumerator(content) &> transformWritable(writeable)

then, using it in an action, you can:

return Ok.stream(writeable(myContent) &> gzip())
 
Or we could even provide a gzip method on Status:

return Ok.gzip(Enumerator(myContent))

--
 
 

James Roper

unread,
Dec 11, 2012, 8:18:06 PM12/11/12
to Guillaume Bort, Sadek Drobi, play-fram...@googlegroups.com
I guess it depends on whether we want to support it or not yet.  I can tell you this enumeratee works fine with trivial tests in memory, but I've got no idea if there are any performance issues or other bugs.  It feels like it's a bit late to include this in 2.1 for me.  I've created this iteratees extras project because I've written a few iteratees that people might find useful, with the outlook that once an iteratee/enumeratee has proved itself stable and useful enough, it could be moved into Play.  The really nice thing about iteratees is that they are so easy to compose, so even if we don't include it in Play, it will still be really easy for people to use it.
Reply all
Reply to author
Forward
0 new messages