ActionHero Gzip support

36 views
Skip to first unread message

Stephen Mabry

unread,
Oct 9, 2015, 6:44:55 PM10/9/15
to actionHero.js
Hi,

Evan Tahler asked me to post my question to this site, so ...

Our Action Hero server needs to support our clients by minimizing the response body with gzip.  I've read the Topology Example and agree with that architecture.  Unfortunately, we are using Amazon load balancer and I'm told ( no access for me ) that it doesn't handle gzip response body [and proper header].  I was told to have Action Hero perform that task.

I know the "request" module provides a flag to turn on gzip support, but it seems that Action Hero server is based on the "http/s" module ( node_modules/actionhero/servers/web.js#server.start() ).  Is there a recommended way to implement gzip support in Action Hero?  I'm kind of expecting to be able to override a file ( one above maybe? ) and only the necessary functions.

Any help would be great.  Btw, I really appreciated the quick response from Mr. Tahler before.

Thanks,

Stephen

Evan Tahler

unread,
Oct 9, 2015, 7:22:23 PM10/9/15
to actionHero.js
And copying the response from before:

Node has all the tools needed to implement gzip streams per request [[ https://nodejs.org/api/zlib.html ]] however, it is very CPU intensive and the node docs themselves warn you not to do this within node.  Something like NGINX is far better suited to this task, as it is threaded and can fan out the CPU demands of gzip compression.  I would recommend you run both actionhero and ngixn on each 'web' server you have. 


However, if enough folks want this in the core, we can have a disabled-by-default option for it. 

Stephen Mabry

unread,
Oct 12, 2015, 10:10:37 AM10/12/15
to actionHero.js
Hi Evan,

I appreciate your prompt reply.  Your suggestion is what I in turn suggested to the guys in our office who make decisions.  Even though performing the gzip operations in the load balancer is a superior architecture and I demoed a functional POC, my marching orders are to make it work in ActionHero.  So, now I'm left with making a maintainable implementation and not sure where to aim. I don't want to modify anything under node_modules and I'm betting I can just override something ( maybe node_modules/actionhero/servers/web.js? ).  This shouldn't affect [web]sockets.  Any ideas?

Thanks,

Stephen

Evan Tahler

unread,
Oct 12, 2015, 2:03:33 PM10/12/15
to actionHero.js
Something like this (which isn't working yet) would be the direction to take then: https://github.com/evantahler/actionhero/pull/689

Stephen Mabry

unread,
Oct 13, 2015, 9:46:43 AM10/13/15
to actionHero.js
Omg, you're the best!  Thanks for the gzip toggle in new release.  The config and web.js#sendMessage were the places I was changing as well.  I really appreciate you incorporating the gzip/deflate support.

Thanks,

Stephen
Reply all
Reply to author
Forward
0 new messages