My Essential Software

I recently got a new laptop for work, and had to install a bunch of stuff. For what it’s worth here’s what made it in within the first couple of days:

  • 1Password
  • DropBox (these two together are literally the first thing I install)
  • Evernote
  • Quick Search Box (QuickSilver replacement; either is fine for what I do)
  • Skype (Needed for work, for personal IM I use Adium with the Skype plugin)
  • TextMate (with AckMate)
  • TinyAlarm
  • Xmarks
  • XSlimmer (because of my OCD)

Performance Testing – A Simple Plan

I was asked to outlline what I’d expect someone to decide before they started a performance test exercise. A quick look at StickyMinds shows this document, which looks very good. It is, however, 8 pages long, which is about 7.5 pages longer than I need if my target audience is going to bother with it. Here, then, is my simplified version. Slightly cryptic, perhaps, but workable (at least for a web server, which is what we’re dealing with).

Purpose?
*Performance Test – see what it will do
*Stress Test – see the most it will do
*Load Test – see what happens when it does more than that
*Sizing – Guide to customers on hardware requirements

Test platform?
*Number of machines
*Machine specs
*Network spec

Test Application?
*Low complexity to concentrate on platform
*High complexity to simulate real-life loads
*Think times emphasize load or real-life use.

Finally, how will results be measured?
*Throughput (or equivalents)
*Constraints (e.g. is app under test memory bound, CPU bound, network bound)
*Recommended hardware – e.g. X users per Y GB of memory and Z GHz of processor.

Busy

In case you hadn’t noticed, things have been rather quiet here. Work is busy, life too, culminating on Friday of last week when I spent 20 hours in Budapest – left home at 4:30am Friday, arrived back 11:30am Saturday, which on top of alcohol-based work socializing meant way too little sleep. More regular posting to come, promise!

Posted in Uncategorized
Tagged with

Solaris, NWAM and Static IPs

A new feature in OpenSolaris is NWAM, the NetWork Auto Magic, um, thingy. It’s a handy tool that automatically configures your network connection. Unfortunately it unhandily has no GUI at the moment, though one is in the works, so if it doesn’t work right first time you can quickly get lost in text files and Google searches. In my case I wanted it to do its normal magic, but to use a static IP address at all times. Here’s how I did it:

svcs svc:/network/physical This should show that ‘nwam’ is online and ‘default’ is disabled. If it doesn’t, off to Google with you!

Edit the file /etc/nwam/llp so that it says something like yukonx0 static 192.168.1.50/24yukonx0 is the name of your network adapter (mine is for a Mac Mini ethernet port), 192.168.1.50 is the IP you want to assign, and /24 shows that your subnet mask is 255.255.255.0. Your values will vary.

Edit the file /etc/nsswitch.conf and add dns to the hosts line, to give hosts: files dns.

Now delete the default route entry (this may well not exist, but it’s safest to remove and recreate): route delete default 192.168.1.1 (your default route may be different). Then add the entry back in permanently: route -p add default 192.168.1.1.

Finally restart nwam with svcadm restart svc:/network/physical:nwam and wait for a moment. It should tell you that it’s connected with IP 192.168.1.50 (or whatever you selected). Once that’s done you should be able to connect to the Internet, and more importantly be able to reboot and have it still work. Though it shouldn’t be necessary, if it’s not working immediately try rebooting.

Load Balancing Tomcat on Leopard with mod_jk

I’ve just had to setup a test system that load balances a site running on Tomcat across multiple computers. My test bed is 3 mac minis, one working as the ‘head’ running Apache, and the other two in the ‘farm’ handling the load. It was a less than painless exercise, so I thought I’d write up the instructions.

1. Install Tomcat
Download Tomcat from here.
On each farm machine rename the folder to be Tomcat, then move it to the /Library/ directory.
In Terminal:

cd /Library/Tomcat/bin
rm *.bat
rm *.exe
chmod +x *

(You don’t need .bat or .exe files, but you do need other files to be executable).

Edit the file /Library/Tomcat/conf/tomcat-users.xml so that it reads:

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="manager"/>
  <user username="tomcat" password="s3cret" roles="manager"/>
</tomcat-users>

(Note that the username and password are examples from Tomcat – you should probably change them).

Repeat the above for each farm machine.

2. Deploy your application
Open each of your farm machines in turn from your browser, e.g.

http://farm1:8080/

You should see a screen that looks something like this:

Welcome screen for a Tomcat installation

Click Tomcat Manager and enter the username and password you defined above. This should show the Tomcat Web Application Manager screen.

Upload the war file of the application you want to run. Once complete you should see a link on the manager page to your application. Click it and make sure it works OK.

Repeat the above for each farm machine.

3. Install mod_jk
Here’s the tricky bit. Mod_jk is the apache module that handles the load balancing. It’s available here, BUT none of the downloads there will work on Leopard. Apache on Leopard runs as 64 bit, which isn’t an option you can download from the Tomcat site. So you have two options:

  • Download the source code and build your own version. This isn’t too hard if you have the relevant tools already installed – look here for an excellent step-by-step on the changes you need to make to build a 64 bit version.
  • Use MacPorts
  • , which appears to have the facility to create a 64 bit version (I haven’t tested this).

  • Download the 64 bit version of mod_jk 1.2.26 that I created. I may update this as I go along, but no guarantees!

Once you have your mod_jk.so file (if it doesn’t end up with that name, change the name) copy it to the /usr/libexec/apache2/ directory of your head machine. It’s worth changing the ownership and permissions of the file to match the other modules using the commands sudo chown root:wheel mod_jk.so and sudo chmod 755 mod_jk.so.

4. Configure Apache
Edit the file /etc/apache2/httpd.conf and add the following lines:

#Added for Load Balancing
LoadModule jk_module libexec/apache2/mod_jk.so
# Path to workers.properties
JkWorkersFile /etc/apache2/workers.properties 

# Path to jk logs
JkLogFile /your-chosen-location/mod_jk.log

# Jk log level [debug/error/info]
JkLogLevel info

# Jk log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

# JkOptions for forwarding
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"

JkMount /your-application balancer
JkMount /your-application/* balancer
#End Added for Load Balancing

Note that you’ll need to set the location for your log file, and the name of your application. It’s a good idea to create the log file (e.g. use touch mod_jk.log in the directory you want it; this makes sure the file can be created, which would otherwise trip Tomcat up.

Now create a new file worker.properties in /etc/apache2 containing the following:

workers.tomcat_home=/Library/Tomcat
workers.java_home=/System/Library/Frameworks/JavaVM.framework/Versions/Current

worker.list=balancer
worker.maintain=5

worker.farm1.port=8009
worker.farm1.host=farm1-IP-address
worker.farm1.type=ajp13
worker.farm1.lbfactor=1

worker.farm2.port=8009
worker.farm2.host=farm2-IP-address
worker.farm2.type=ajp13
worker.farm2.lbfactor=10

worker.balancer.type=lb
worker.balancer.balance_workers=farm1,farm2
worker.balancer.method=Request

The worker.maintain setting helps determine how long one farm machine will be used before the load switches to another machine. For testing I used 5 (seconds); the default is 60.

5. Start Apache
Tomcat should still be running on each of the farm servers, so start Apache on your head machine by opening System Preferences…Sharing and checking the ‘Web Sharing’ box (if it was already checked then uncheck and recheck it to restart Apache).

6. Test it out
Browse to http://head/your-application – you should see your application!

Credits
This post was based on the excellent work found here