August 1, 2008

Java Magic Trick: The Ball Is Everywhere

Tom @ 7:04 pm

As keen Java programmers we’re always on the lookout for interesting tidbits about the language, how it is being used and where it is heading. Just the other day Matt brought in a copy of Java Puzzlers to test our knowledge. So it was something of a coincidence that the guys over at Atlassian came out with their own Java puzzler.

The puzzle is a Java version of the shell game (AKA ‘thimblerig’), where the onlooker must choose which shell the ball is under (after the con artist has shuffled them around).

The puzzle and the included solutions are interesting, and well worth a read if you’re a programmer. Chris came up with the ’static block’ method almost immediately, but I must admit that my thinking was just along the lines of “err, with reflection somehow?” before we looked up the answers.

Four solutions were presented on Atlassian’s blog post, but I have a fifth: The terms of engagement were “you can only modify the class representing the ball”. But what about a solution that doesn’t involve modifying the ball either? What if you could alter the onlookers’ perception so that when the cup is raised they see a ball, despite there not being a ball at all?

Using the Force and with a wave of the hand, we get:

aspect YouWillBeEqual {
    boolean around(): call(boolean String.equals(Object)) {
        return true;
    }
}

Now there is a ball under every cup, always. At least, it appears that way. Actually, everything around here appears to have a ball under it…

Made possible with a little AOP ;)

Support case study: Optimizing the account selection popup

Matt @ 12:31 pm

When we’re not working on new features, we’re often working on improving PaperCut to ensure it works well in a large variety of situations.  Sometimes customers use PaperCut in ways we never intended, or encounter scenarios which we never envisioned.  We take pride in listening to our customer experiences, and making improvements to ensure we meet their needs.  The result is a better product, and everyone benefits.

Today I’ll explain an issue raised recently by one of our largest PaperCut ChargeBack customers, and then describe how we designed and implemented the solution.

The Problem

This customer was running PaperCut in a challenging environment:

  • Around 2,000 users all running the user client to charge printing to shared accounts;
  • Users are located at a number of remote sites over slower network connections;
  • Printing is charged to over 30,000 shared accounts;
  • All users could charge printing to any of the 30,000 accounts;
  • Each night an automated process added, removed or modified hundreds of accounts.

They reported the following problems:

  • The user clients on remote sites were slow to popup when first printing.
  • A large amount of bandwidth was used communicating with the primary PaperCut server.
  • The PaperCut server was slow to respond in the mornings.

Analysis

It was clear that the cause of all these symptoms was the large amount of account data downloaded by each of the user clients.   The user client will only download the account list from the server when it detects accounts have changed.  But at this customer the account list was changed nightly.  This caused the client software to re-download the large account list when the user first printed each day.

The client software communicates with the server using XML web services.  After some analysis we found that the the XML representation of the 30,000 accounts was about 7.5 MB.  On a fast local network this size is not a problem, but with 100’s of clients running on remote sites over slower WAN connections this starts to be an issue.  It causes congestion on the network, the popup is slow to appear, and the server becomes overloaded.

After a few brainstorming sessions and consulting with the customer we approached the solution from two angles.

  1. Reduce the size of the account download;
  2. Allow the account data to be efficiently distributed to remote sites.

Solution Part 1: Reducing the download size

To reduce the size of the data downloaded we changed the account file format in two ways:

  1. Change from verbose XML to a much more efficient binary format;
  2. Compress the binary data

The net result was a reduction of approximately 25 times!   In the case of this customer the 7.5MB download was reduced to around 250KB. Quite an improvement!

This change alone dramatically reduced the popup speed, and bandwidth used over the WAN connections.  But we could do better!

Solution Part 2: Efficient distribution

We realized that it was very inefficient for multiple clients at the same remote site to download the identical account list.  What if we could only download the list once per site?

We implemented a server-side tool to save the account list to a file (in the identical format described above).  We added a new option to the client software to allow it to load the account list from a file instead of downloading from the server directly.  Then all that this customer need to do was:

  1. Schedule a task to create the account file each night (after the accounts were modified), then copy the account file to a file share on each of the remote sites.
  2. Configure the clients at each site to load the local account list file.

The result was that only a single 250KB transfer was required to delivery the new account list to all clients at a given remote site.

Conclusion

The result of these changes was dramatic.  Previously, on a site with 20 users the daily account download would consume around 150MB of bandwidth.  After these changes it was reduced to only 250KB.  What an improvement!

Not only was this a great result for this customer, but the product is improved for everyone.

I hope this gave you a little insight into the work we do behind the scenes.  This change wasn’t glamorous or exciting.  It will only be a single bullet point in our version 8.4 release notes.    However it’s often many of these small improvements that make the overall product great.

July 24, 2008

We’re hiring!

Chris @ 5:37 pm

Many companies have a Jobs/Employment section on their website. We’re a small company with very low staff turn over and hence rarely advertise positions. We do however have one going right now! Quite a few people subscribe to our blog, so I thought we’d do some shameless self promotion and post the position here:

Read the rest of this entry »

July 16, 2008

Who’s using PaperCut? PepsiCo, HP and Dad!

Chris @ 11:45 am

Since we release our free print logging program a few years back its been a hit with hundreds of thousands of downloads. Every now and then we receive a thank you email or a short story about how people are finding it useful. One user recently wrote to us to thank us for helping him track down why his ink was disappearing. He had no explanation as to why his home printer ran out of ink every few weeks. Print Logger to the rescue! A quick audit of print activity shows that his kids did a lot of printing before he got home from work. Now printing in his household is restricted to homework use only and he’s happy again!

There are also plenty of other examples at the big end of town. Today I received an email from PepsiCo and HP outlining their use of PaperCut Print Logger. It’s great to see that this little free program has uses ranging from small homes to the largest corporates.

For us, PaperCut Print Logger serves two purposes:

1) It’s a great test bed for our printer page analysis technology. With hundreds of thousands of users, we quickly get reports about incompatibility with new drivers. The program actively encourages users to report incompatibilities and in turn this ensures that all our applications offer the widest range of support.

2) It’s also a fantastic way to get a “taste” of our applications. Many schools for example will install PaperCut Print Logger to get a quick view of what’s going on on their networks. It’s then only a small jump to move to PaperCut to implement print control, quotas, reporting, and of course monitor the environmental impact of printing.

If you’re running print logger, please take a few moments to send us an email and share your stories.

June 5, 2008

Jetty - the web server that powers PaperCut

Chris @ 10:58 am

The other day I sent a quick email to the Jetty HTTP Server development team thanking them for all their hard work. We struck up a bit of a conversation and they wanted to know more about how we’re using Jetty in PaperCut and asked us if we’d like to write up a short Case Study for their website. I’ve decided to post this on the blog as it will also give some of our users an interesting look at the “internals” of PaperCut.

Our use of Jetty is quite a bit different to most. Instead of treating Jetty like Apache or a stand-alone server, we’re using Jetty as an embedded component. It’s deployed with our print accounting application, PaperCut (tour here for those interested). As a result, Jetty is running on tens-of-thousands of servers in over 60 countries and the vast majority of users are completely unaware that it’s there. The measure of a good embeddable component is not who’s using it, but who’s not aware that they’re using it! Jetty is fantastic in this regard - zero config and zero maintenance, working away flawlessly for years on end.

Jetty is hosting PaperCut’s web application interface. This is a web application based on Tapestry, Spring, Hibernate and Apache Derby. Jetty’s embeddability has allowed us to deploy this stack in a standard setup.exe type installer targeting all major platforms (Windows, Linux and Mac). Our users don’t need to know anything about web servers or their setup and configuration. All they need to do is run the installer! Jetty’s scalability has also been an advantage. In some cases PaperCut is installed on a small business server supporting 5 workstations, while on other sites it’s running in University environments on clustered servers supporting 100,000+ users. Jetty has prove equally adaptable at both ends of the scalability spectrum.

Choosing components for a project is always difficult - often too much choice! Obviously Jetty has been a great choice but was one we carefully considered back in 2005. Technical functionality was one criteria, but another important consideration was the strength of the team behind the project. We’ve seen too many Open Source projects start out with enthusiasm only to run out of puff and “age” early. What grabbed us about Jetty was the future looking team. In 2005 AJAX was very new and there was big questions about how to handle server-push events in a scalable fashion. We had an immediate need for this, not with AJAX, but with our web services API (client software receiving web-services push events from the server). The Jetty development team members such as Greg Wilkins, were openly discussing “long polling” and the issues around this. Jetty was one of the first servers to present working and more importantly “workable” solutions to the scalability problems.

We can’t recommend Jetty more highly. It’s a great web server, a great component, and is backed by a switched-on forward looking and innovative team - make sure you check out the open source Jetty and the team!

May 29, 2008

PaperCut Print Logger now in Spanish

Chris @ 4:09 pm

Wow! On the back of the Italian translation of PaperCut Print Logger, Alessia and her team have translated PaperCut Print Logger into Spanish. The translation has been done by a Spanish girl in her class under the supervision from their teacher who can also speak Spanish. On behalf of all the Spanish users of PaperCut, we’d like to send a big thank you to Alessia and her team at San Pio V University in Italy.

May 12, 2008

If an infinite number of monkeys…

Chris @ 12:50 pm

A PaperCut user recently reported an unfortunate situation. The PaperCut Pre-Paid/TopUp Card Wizard generated a card with an inappropriate random card number. The first reaction of our developers was to have a bit of a laugh – what are the chances of that? – followed by some serious discussions on the best way to fix the “bug”.

Censored Bad Word TopUp Card
The offending card censored to protect the innocent!

The situation reminded me of the Infinite monkey theorem. We calculated that the probability of this, or any other four letter work appearing in any one card, is approximately 1 in 800,000. That’s very low, but given a large enough number of administrators generating a large enough number of cards, it was bound to happen some day.

We considered a number of solutions including Black Listing words. The only problem with this approach was that it’s hard to know what constitutes a “bad” word in all the 9 languages we support. Also, maybe some legit words may be inappropriate in some cases. Our final solution was to simply drop vowels which in turn prevents word formation - a simple but elegant solution. Anyone know any bad four letter words without vowels?!

April 4, 2008

New Site Search

Chris @ 4:22 pm

A number of visitors have suggested we implement an improved search system for the Knowledge Base and Manual. This project is now complete and we have a new unified site search that searches over the KB, manual, blog, and the site as a whole (check out the search link on the top right-hand corner of the home page). The search is AJAX based and works by overlaying the existing page – no popups, or losing your position on the site. For the technical people interested, it’s driven by Google Custom Search.

We have a rapidly growing KB and we hope this will help PaperCut users find answers they’re after. Please give it a test run and let us know if you have any comments/suggestions.

March 6, 2008

A turning point – students now want PaperCut too!

Chris @ 4:23 pm

One of the students at Colchester Royal Grammar School in the UK emailed me last week to fill me in on one of their recent projects – making their school greener. One component of the project addressed printing and they used PaperCut and its environmental impact feature to draw attention to consumption. You can read a little bit more about their project here. It’s been very easy to convince school administrators about the need for PaperCut, but it’s always an up-hill battle convincing students that there are good reasons to control their printing. It now looks like we have a new generation of students that actually are embracing PaperCut!

The website also has an interesting survey (XLS file). Almost 40% of respondents didn’t use double-sided duplex printing because it was “too awkward”. Another good reason to deploy PaperCut – so you can enforce duplex on all printers that support it!

February 11, 2008

PaperCut Print Logger now in Italian

Chris @ 10:40 am

A big thanks to Alessia and her team for their work in translating PaperCut Print Logger into Italian. Alessia and her team undertook the work as part of a software localization course at San Pio V University in Italy. It’s great to see Universities focusing some of their attention on real-world projects. Practical projects where you can “make” something are so much more satisfying. Most of my course work during my University days was theoretically based. I acquired my practical skill” outside of course while working part-time as a system administrator and of course “playing” with computers at home. The theoretical skills in computer science are important, and more importantly for Universities with aging lectures, they never go out of date (e.g. algorithms, data structures, etc.). Practical skills on the other hand need constant updating - which Web 2.0 framework do you what to learn this week!

A number of Italian universities are using PaperCut NG for their print control, and they have coordinated to translate this application into Italian. It’s now great to offer our free print logger in Italian as well. Thanks again to Alessia and team.