Archive for October, 2017

Negative queue depths in ActiveMQ

For quite some time we battled with negative and sometimes false positive queue depths in ActiveMQ and the commercial AMQ equivalent. Apparently there is a race condition somewhere in the broker. It is usually easy to see when it has happened in the graphs, as the number of messages on a queue suddenly jumps up or down dramatically in an instant. It does play havoc with monitoring, though. How can you set alarms if you can’t trust the reported queue depth? Restarting the broker fixes the counter, but that is not a viable solution.

Fortunately there is a configuration option that solves this. Define a policyEntry for the affected queues/topics and set useCache="false". That is a fairly large change, but it works.

Categories: Java

VMWare vs VirtualBox vs Parallels for DevOps

What is the best virtualization engine for Mac OS X? The answer depends on who you are. As always these days, I started by checking what Google has to say. After some reading I decided on VMWare. Solid with a long track record, the best support for uncommon guest platforms and the best performance. However, after a short time I realized it was not for me.

Most comparisons focus on users with limited IT experience who want to run Windows as seamlessly as possible. They want Windows programs to work as if they were Mac programs. VMWare and Parallels both beat VirtualBox with ease on that score, but I really don’t care.

What I’m looking for as a DevOps (not part of my job description, but in practice that’s what I’ve been doing for as long as I can remember) is good support for running multiple servers with other operating systems (mostly Linux) with full control over the finer details. There VirtualBox shines.

A simple example is port forwarding for NAT. With VirtualBox I can open a new tunnel into a machine with a few clicks without restarting. With VMWare on Mac that is not possible at all through the user interface. It seems to be supported by editing a hidden configuration file, but then it seems to be global rather than limited to a specific machine? Not sure, didn’t go that route. Options for hard disks are also much richer in VirtualBox.

In short I found that the free VirtualBox engine beats the commercial alternatives for my use cases. What do you think?

Categories: Virtualization

Native memory leaks in Java

By request, here is the presentation I held at JavaForum on native memory leaks in Java.

Categories: Java

Shrink VirtualBox VDI files with TRIM

Historically I have always tried to keep virtual disks small by defragmenting, clearing unused space and compacting. It works, but it is tedious and takes time. Now there is a much better option, as VirtualBox has TRIM support!

Stop the image if it is running, then open the configuration file with a text editor. Locate the virtual disk and add discard and nonrotational:

<AttachedDevice discard="true" nonrotational="true" type="HardDisk" ... >

The nonrotational setting can be edited in the user interface (Solid-state drive), but my version of VirtualBox still doesn’t expose the discard option.

I’m often using Linux Mint as a guest. Start it and verify that TRIM is available for the disk:

sudo hdparm -I /dev/sda | grep TRIM

Provided that TRIM is in fact supported, add discard support to LVM if it is used. Edit /etc/lvm/lvm.conf and make sure that issue_discards is set:

devices {
    issue_discards = 1

Also edit /etc/fstab and add discard to the file systems, for example:

UUID=somevalue / ext4 discard,errors=remount-ro 0 1

Reboot and delete something big. You should see the vdi file shrink in real time. Is that cool or not? You can also discard unused data manually:

sudo fstrim /

With a file system that has been used for a while that can reduce the size of the vdi file a lot.

Categories: Virtualization