atc » apache http://blog.alexcollins.org Musings of technology, sport, life et al Thu, 10 Jun 2010 10:24:24 +0000 en hourly 1 http://wordpress.org/?v=3.0.5 Ant TODO Update http://blog.alexcollins.org/2010/01/02/ant-todo-update/ http://blog.alexcollins.org/2010/01/02/ant-todo-update/#comments Sat, 02 Jan 2010 21:34:38 +0000 atc http://blog.beplacid.net/?p=111 Quick update regarding Ant TODO: there’s now a JAR available for download, so you can get it running even quicker!

]]>
http://blog.alexcollins.org/2010/01/02/ant-todo-update/feed/ 5
Ant Task for TODOs http://blog.alexcollins.org/2009/12/31/apache-ant-task-todo/ http://blog.alexcollins.org/2009/12/31/apache-ant-task-todo/#comments Thu, 31 Dec 2009 15:58:35 +0000 atc http://blog.beplacid.net/?p=108 I often felt the need to scratch an itch when it comes to source code and a little fragment called //TODO. It’s scattered everywhere; I’m sure you’ve seen it. Yet no matter what codebase you’re looking at, there’s never any real exposure to them.

I therefore decided to implement an Ant Task for parsing TODOs in source code. You can read more about it over on the Google Code project. Please feel free to review code, suggest features or try it out and report a bug.

Happy new year to all; many happy returns.

See you in 2010!

]]>
http://blog.alexcollins.org/2009/12/31/apache-ant-task-todo/feed/ 0
Server Benchmarking Diary – Debian, Apache 2 and MySQL http://blog.alexcollins.org/2008/09/05/server-benchmarking-tips-debian/ http://blog.alexcollins.org/2008/09/05/server-benchmarking-tips-debian/#comments Fri, 05 Sep 2008 20:32:16 +0000 atc http://blog.beplacid.net/2008/09/05/server-benchmarking-tips-debian/ This blog took nearly 7 thousand hits yesterday. At its peak, it took 1.8 thousand an hour. That’s a decent amount of traffic. This was all brought about when I submitted a link to reddit.com regarding a way to crash Google Chrome instantly. Coincidentally, I had spent an hour or so the night before testing the stability of my Slicehost Xen virtual machine (more info here) just out of curiosity. I was using wget, ab (Apache benchmarking tool) and htop to mirror, send concurrent requests and monitor respectively. I’m going to document my findings here.

What I’m Running

Here’s a rundown of what sites I’m running and the software used.

Wget – the Swiss army knife of HTTP command line tools

Wget’s one of those tools you really take for granted. It’s versatile, reliable, simple and most importantly – it does its job very well. One of its nicest features is the –mirror option. This allows you to…mirror a given website. I initially thought of running multiple instances of wget at the same time. I started small at first: one instance running to mirror the entire site. I ran the following in a shell:

alex@prometheus:/tmp$ wget –mirror beplacid.net/

It’s simple: mirror beplacid.net. Watching the processes and CPU usage on the server, it became apparent that  this wasn’t going to do much. The CPU usage didn’t exceed 5% on its first core. I had to rethink. Then ab sprung to mind.

ab – Apache benchmarking tool

This is another useful tool. It’s simple to use and allows you to quickly and easily hit a given hostname with HTTP requests, all tailored to your specific needs. To do all this, however, you need to be running as root. A noble security measure.

I wanted to generate some traffic that would put the server under some strain, so I started with 50 requests and 5 at a time:

prometheus:/root$ ab -n 50 -c 5 beplacid.net/

Now things started to get fun. This peaked CPU usage to 94% on one core, the others were between 60 and 80. I was starting to see some real stats. I doubled things – 100 with 10 per request:

 prometheus:/root$ ab -n 100 -c 10 beplacid.net/

This was a little more representative of a heavy amount of traffic. Perhaps akin to slashdot or a reddit. Put simply, that’s 100 requests with 10 each sent each time. Still nothing major, so I went all out:

Concurrency Level:      10
Complete requests: 1000
Total transferred:      4856792 bytes
HTML transferred:       4687792 bytes
Requests per second:    4.99 [#/sec] (mean)
Time per request:       2002.453 [ms] (mean)
Time per request:       200.245 [ms] (mean, across all concurrent requests)
Transfer rate:          23.69 [Kbytes/sec] received

To summarise, the server took 1000 requests with an average of 5 per second, each returning just over 2 seconds. Not bad, considering what I’m running.

I’m pleased with my setup. It can take a punch and it’s still running. My next task is to hit both beplacid.net and the blog, with perhaps some traffic mirroring readingbeerfestival.org.uk too.

]]>
http://blog.alexcollins.org/2008/09/05/server-benchmarking-tips-debian/feed/ 4
HOWTO: Apache 2, Tomcat 5.5.25 and mod_jk and Debian http://blog.alexcollins.org/2007/11/20/howto-apache-2-tomcat-5525-and-mod_jk-under-debian/ http://blog.alexcollins.org/2007/11/20/howto-apache-2-tomcat-5525-and-mod_jk-under-debian/#comments Tue, 20 Nov 2007 10:58:12 +0000 atc http://blog.beplacid.net/2007/11/20/howto-apache-2-tomcat-5525-and-mod_jk-under-debian/ Update: It’s been said that this howto will also work for Tomcat 6. I’ve not tested it, but I’d assume it would work considering the manual aspects of the installation and the unlikely event that Tomcat 6 would’ve changed its directory structure considerably. If you find evidence to the contrary, please let me know.

Introduction
This HowTo explains the installation and configuration of Apache 2.2.3, Tomcat 5.5.25 and the Apache Jakarta module — a connector/proxy for Apache & Tomcat — under Debian Etch. It is geared towards those who already have experience configuring Apache and Tomcat and are aware of the basic principles behind Apache modules.

Prerequisites
A working installation of Debian GNU/Linux that has an internet connection, or valid CD-ROM apt packages disc.

Step 1: Installing Apache
If you don’t already have Apache installed, you will need to run the following in a shell as root:

Shell:
apt-get install apache2

This will install Apache 2 and any relevant dependencies. Configuration files for Apache can be found under /etc/apache2, and host-specific configuration are found under /etc/apache2/sites-available/. This is where you should configure your individual Virtual Hosts, as opposed to placing the configuration in /etc/apache2/apache2.conf.

Step 2: Install mod_jk
Using apt, you need to install the Apache Jakarta module by executing the following in a shell as root:

Shell:
apt-get install libapache2-mod-jk

The module may need enabling via ‘a2enmod jk’, but it is not necessary at this time. Go ahead and execute the following as root:

Shell:
a2enmod jk

Running the above should return a message similar to ‘Module enabled, now run /etc/init.d/apache2 force-reload’. I do not recommend reloading Apache’s configuration until everything has been installed and setup. This will ensure Apache remains usable while you setup Tomcat in the next step.

Step 3: Download and Extract Apache Tomcat 5.5.25
There’s a reason I installed Tomcat manually: Debian’s Tomcat package is a mess. The default package splits, amongst others, the webapps and conf folders. Whilst the conf folder is situated in a respectable location (/etc/tomcat5), the webapps directory is symlink’d under /var/, which tends to cause problems with Apache->Tomcat configuration. Therfore, I have chosen to manually install Tomcat using the .tar.gz from tomcat.apache.org; as well as this being a recommendation from various people in the #tomcat channel on irc.freenode.net. In short, it’s a configuration and administration nightmare.

Download Apache Tomcat 5.5.25 from here: http://tomcat.apache.org/download-55.cgi (select a mirror) and extract it to one of the following locations (I used /usr/share/):

  • /usr/local/
  • /usr/share/

To do the above, execute these commands as root:

Shell:
mv apache-tomcat-5.5.25.tar.gz /usr/share/; cd /usr/share
tar zxvf apache-tomcat-5.5.25.tar.gz; mv apache-tomcat-5.5.25 tomcat-5.5.25

Now, let’s setup a user and group so we can provide safe permission control over the conf and webapps directories.

Step 4: Add a tomcat user and group

Shell:
adduser tomcat && addgroup tomcat; cd /usr/share/tomcat-5.5.25

We’ve just created the tomcat user & group, so let’s apply the ownership permissions to the webapps directory:

Shell:
chown -R tomcat:tomcat webapps; chmod -R 775 webapps

This now means that any user who’s in the tomcat group can read, write and execute files under the webapps directory.

Note: if you use a specific user and group such as www-data for Apache ownership and execution, which is the default in Debian, you will need to add ‘tomcat’ to the www-data user’s groups:

Shell:
usermod -aG tomcat www-data

The following is optional, as it sets the group permissions of the server.xml to writable by the tomcat group. This may not be what you want, so be careful!

Shell:
cd conf; chmod g+w server.xml

Now that we’ve setup the most important directories, let’s make the tomcat startup and shutdown bash scripts executable, ready for starting it up:

Shell:
cd /usr/share/tomcat-5.5.25/bin/; chmod 755 shutdown.sh startup.sh

Step 4: Create the workers.properties File
Create the following file, as root, under /etc/apache2 or a directory of your choice (/usr/share/tomcat-5.5.25/conf would also be fine), but make sure it’s readable by the tomcat user and/or group.

File:
#
# This file provides minimal jk configuration properties needed to
# connect to Tomcat.
#
# We define a worker named ‘default’
#workers.tomcat_home=/usr/share/tomcat5.5/
workers.java_home=/usr/lib/jvm/java-1.5.0-sun/
ps=/
worker.list=default
worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1

The ‘worker.list’ parameter defines the names for the ajp13 connector(s). This is what Apache talks to. You can specify a name of your choice, but make sure you remember it for later, and ensure you’ve changed all parameters beginning with ‘worker.default’ to the name you’ve set.

Step 5: Configure an Apache to Talk To Tomcat and add a Virtual Host
This step is the most important part. It assumes that you’re using virtual hosts for Apache (you may not be), so if that isn’t the case, just place the JkMount configuration lines in the Virtual Host section along with the config. below in your main apache file (/etc/apache2/apache2.conf).

File:
# mod_jk config
# Where to find workers.properties
JkWorkersFile /etc/apache2/workers.properties# Where to put jk logs
JkLogFile /var/log/apache2/jk.log# Set the jk log level [debug/error/info]
JkLogLevel info# Select the log format
JkLogStampFormat “[%a %b %d %H:%M:%S %Y] “#JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories# JkRequestLogFormat set the request format
JkRequestLogFormat “%w %V %T”

For my virtual host, I created the following configuration file under /etc/apache2/sites-available:

File:
<VirtualHost *:80>
ServerName abc.myhost.com
ServerAdmin webmaster@abc.myhost.com
JkMount /* default
JkMount /*.jsp default
DirectoryIndex index.jsp index.html
# Globally deny access to the WEB-INF directory
<LocationMatch ‘.*WEB-INF.*’>
AllowOverride None
deny from all
</LocationMatch>
</VirtualHost>

The most important lines in the above quote are the following:

Shell:
JkMount /* default
JkMount /*.jsp default

These two lines specify the URL paths that should be handed to mod_jk and thus Tomcat. The ‘default’ section of the line specifies the JK worker identifier. This must match the name you specified in the workers.properties file!

That’s the configuration done, let’s fire this baby up!

Step 5: Unleashing the Beast; Starting Apache & Tomcat
To ensure a clean start up, I recommend stopping Apache entirely, and then starting up Tomcat, then Apache. Do so by executing the following commands (as root, see the note blow otherwise)::

Shell:
/etc/init.d/apache2 stop
/usr/share/tomcat-5.5.25/bin/startup.sh
/etc/init.d/apache2 start

Note: if you want tomcat to run as a separate user but keep ownership as root, use jsvc and the -user flag to specify the user it should change to at startup.

Both Tomcat and Apache should startup without error, and you should now be able to connect to Apache and the Tomcat via the specified Virtual Host.

]]>
http://blog.alexcollins.org/2007/11/20/howto-apache-2-tomcat-5525-and-mod_jk-under-debian/feed/ 12