Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1

Whatever you do, when you are disabling modules, you should ensure that
you leave either mod_deflate or mod_gzip enabled, depending on your
Apache version. Your bottleneck is almost certainly going to be your
bandwidth rather than your processing power, and having one of these two
compressing your content usually turns 10KB of HTML into 3KB for
supported browsers (most of them).


Next, ensure that keepalives are turned off. Yes, you read that right: Turn off
keepalives. This adds some latency to people viewing your site because they
cannot download multiple files through the same connection. However, it
reduces the number of simultaneously open connections and so allows more
people to connect.


If you are serving content that does not change, you can take the extreme step
of enabling mmap support. This allows Apache to serve pages directly from
RAM without bothering to check whether they have changed, which works
wonders for performance. However, the downside is that when you do change
your pages, you need to restart Apache. Look for the EnableMMAP directive;
it is probably commented out and set to off, and you need to remove the
comment and set it to on.


Finally, if speed is your greatest concern, you should do all you can to ensure
that your content is static: Avoid PHP if you can, avoid databases if you can,
and so on. If you know you are going to get hit by a rush of visitors, use plain
HTML so that Apache is limited only by your bandwidth for how fast it can
serve pages.


TIP
Some people, when questioned about optimizing Apache, recommend that
you tweak the HARD_SERVER_LIMIT value in the Apache source code
and recompile. Although we agree that compiling your own Apache source
code is a great way to get a measurable speed boost if you know what you
are doing, you should need to change this directive only if you are hosting a
huge site. The default value, 256 , is enough to handle the Slashdot Effect,
and if you can handle that, then you can handle most things.

MySQL


Tuning your MySQL server for increased performance is exceptionally easy
to do, largely because you can see huge speed increases simply by getting
your queries right. However, you can tune various things in the server itself to
help it cope with higher loads, as long as your system has enough RAM.

Free download pdf