FreeBSD and Apache on a $5/month DigitalOcean Droplet (VPS)

Datetime:2016-08-22 22:47:13          Topic:          Share

I recently merged dalescott.net and swiftconstructioncompany.net onto a $5/month DigitalOcean droplet. After everything was up and running, I wanted to check server performance and investigated some free online load testing tools.

Here are the tools I tested with. There are more, but these will be enough for now.

  1. Load Impact . Load Impact claims to be “The leading on-demand load and performance testing software-as-a-service.”
  2. Neustar . Neustar claims “We started it all. And we continue to shape the industry.”
  3. WebPageTest . The focus of WebPagetest is how fast an individual page is served. It was reportedly created by AOL for internal use before being released as open source, and is now primarily developed and supported by Google as an open analysis tool for the industry.

I had wanted to include Blitz.io , referenced in a  blog post by Ryan Frankel on using Apache on a small DigitalOcean droplet. However, Blitz’s free demo is hard-coded to use only a Blitz demo site which removed it from consideration.

Load Impact

The free Load Impact test loads 25 Virtual Users in 5 minutes, and displays results in a nice time-based graph. The test results appear to be stored indefinitely, and you can see the full results of my test (additional metrics appear to be available, but require a free Load Impact sign-up which then allows five free tests).

Neustar

Neustar queued three servers for testing, but the Washington server never ran. Here are the results when I gave up waiting.

Web Page Test

Web Page Test concentrates on measuring how fast it takes a page to load, and gives lots of information for digging into the load times for each aspect of the page. I was looking for more of a general load or stress test, to see if the server will fail, but valuable information none the less.

Tuning the Server

It may just be me, but I seem to get a large number of daily hits looking for a backdoor or trying to post advertising using my blog’s contact form. This sets off a firestorm of activity, with Apache using all available RAM, then all available swap, and eventually the server stalls due to page thrashing. From web research, it seems 512MB of RAM is now considered low and Apache must be tuned for optimum behavior.

KeepAlive

KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5

The FreeBSD apache24 port already sets these as defaults in /usr/local/etc/apache24/extra/httpd-default.conf  (the default MaxKeepAliveRequests is even lower than the recommended 200).

References

  • http://serverfault.com/questions/110207/running-out-of-swap-space-on-web-servers-what-to-do

MPM-Prefork

Although Event is reportedly the default MPM in Apache 2.4, the FreeBSD port uses Prefork if not specified otherwise for compatibility with non-thread safe modules.

<IfModule mpm_prefork_module>
    StartServers 3
    MinSpareServers 3
    MaxSpareServers 5
    ServerLimit 50
    MaxClients 50
    MaxRequestsPerChild 700
    # MaxRequestWorkers cannot be greater than ServerLimit
    MaxRequestWorkers 50
    MaxConnectionsPerChild 700
</IfModule>

References

  • http://ryanfrankel.com/run-wordpress-digital-ocean-512mb-vps/
  • https://www.narga.net/optimizing-apachephpmysql-low-memory-server/
  • https://wordpress.org/support/topic/how-to-optimize-apache-for-wordpress
  • https://www.devside.net/articles/apache-performance-tuning
  • https://www.linode.com/docs/websites/apache-tips-and-tricks/tuning-your-apache-server
  • https://httpd.apache.org/docs/2.4/misc/perf-tuning.html

Server Performance

Here are the result of top, running while performing a test with Load Impact. Although the server can by no means be considered fast , and responded very slowly to a browser hit during the Load Impact test, it also is not exhausting swap so I’m pleased for now. I will be back later when time permits.