tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark H. Wood" <mw...@IUPUI.Edu>
Subject Re: sendFiles vs. compression
Date Wed, 19 Apr 2017 13:05:30 GMT
On Tue, Apr 18, 2017 at 02:03:19PM -0400, Chris Gamache wrote:
> I had any frame of reference to base a decision on, I wouldn't have asked
> the question. Ask any front-end engineer what the single best thing to do
> to make a user's experience better when accessing a single-page web
> application, they will say "enable compression" so why it isn't turned on
> by default was a mystery, and that it plays second fiddle to serving static
> file from the file system in an efficient manner was a double mystery.
> Perhaps if my fellow tomcat users would share their thought processes in
> their particular situations for selecting one method over the other, that
> might help me look at my own situation and make a good decision.

Well, why does one want to use sendfile()?  Why does one want to use

sendfile() can be more efficient on the server end, by reducing the
number of context switches when sending large files:  one switch into
kernel mode is all that is needed to get the file sent.  So if you
have a lot of concurrent users and fairly large files, this economy
might dominate the user experience.

OTOH compression can make more efficient use of lower-bandwidth links,
because it sends fewer bits in fewer packets to accomplish the same
task.  So if you have a lot of users on slow links then this economy
might dominate the user experience.  Note that compression uses more
CPU at both ends, so a server already running flat-out or a large
community of low-powered clients may eat up any savings, and then

How to know which is most important?  Measure!  The simplest approach
would be to try it each way and ask users how they experienced the
result.  If you have a lot of information about the distribution of
bandwidth and CPU power across your user community, the amount of
data to be sent per request, and the shape of traffic over time, you
can make some shrewd guesses, but in the end the best solution is the
one that does the job best, and the only way to know that is to test
and see.

Mark H. Wood
Lead Technology Analyst

University Library
Indiana University - Purdue University Indianapolis
755 W. Michigan Street
Indianapolis, IN 46202

View raw message