Plack for staff interface in 3.10: why you will want it !

Now that 3.10 is almost here and Plack for the staff interface is stable, I wanted to measure the benefit of Plack for Koha.

To achieve this goal, I made 2 different tests :

  • The first one was to record the same actions made on the same database for both cases, directly in Firefox, recording my screen with RecordMyDesktop application (
  • The second one was to develop a Perl script that does some actions on Koha using the wonderfull Test::WWW::Mechanize library. This library let you manipulate web pages exactly as if you were running them with your mouse and keyboard.

Both tests are pursuing different goals.

  • the first one will show the end-user gain in productivity. Even if the software is faster on the server, there are others channels and actions involved that will reduce the global gain : time to render the page on the browser, the time needed for the user to enter data, move the mouse and click
  • the second one will show the server side gain only : the test suite don’t render anything, immediatly click, fill forms,…

Test 1 : recording Firefox

I did a screencast of the following scenarii :

  • log-in to staff interface
  • check-out 5 books
  • check-in those 5 books
  • check-out 5 books to another customer that had fine, so I had to confirm the check-out
  • search a biblio
  • place a hold on it
  • check-in the 5 books

I’ve choosen check-in and check-out because that’s what public libraries do the most, and that must be done as fast as possible, because patrons are in front of the desk and want those books quickly !!!

The screencast show the durations of this test when you run it under plack and under cgi mode.

    • with plack, the duration is 123s
    • with cgi, the duration is 166s

It means you can be 25% more productive when you run Koha under Plack than under CGI. It means that if you worked 8 hours a day at the circulation desk, you’ll have to work only 6 hours to do the same things. Or, if you prefer, you can leave for coffee 15 minuts every 45 and still do the same job (coffee producers will enjoy that, your health probably won’t, you can do something else with those 15 minutes 😉 )

If you look at the screencast (plack) the timing is:

      • seconds 0 to 6 : login (this includes typing the login & password test/test)
      • seconds 6 to 9 : reaching checkout page
      • seconds 9 to 33 : doing 5 checkouts (entering patron cardnumber, entering 5 barcodes)
      • seconds 33 to 52 : doing 5 checkins (entering 5 barcodes)
      • seconds 52 to 84: doing 5 checkouts (entering patron cardnumber, entering 5 barcodes and confirming the 1st one because the patron has fines)
      • seconds 84 to 91 : doing a search on the catalogue, (entering terms, getting results)
      • seconds 91 to 103 : placing a hold (reaching the place-hold page, entering patron, validating hold)
      • seconds 103 to 123 : doing 5 checkin (entering 5 barcodes)

This test was entirely made on my laptop (that acts as server and workstation). it’s a 2 years old Lenovo thinkpad, Intel core i3, 4GB RAM, 320GB harddrive, Ubuntu 12.04, default mysql & Apache configurations (no optimization)

Test 2 : using Test::WWW::Mechanize
For this test, I’ve written a Perl script that :

      • log-in to staff interface
      • reach circulation page
      • checkout 5 items
      • checkin the same 5 items

Then, this script is run with

export PERL5LIB=/path/to/koha;export KOHA_CONF=/path/to/koha-conf.xml; export KOHA_INTRANET_URL=http://localhost:5001/; export KOHA_USER=test;export KOHA_PASS=test;time ./

The results are:

      • with Plack: 0m12.271s
      • with CGI mode: 0m31.533s

In this case, the number says the server work is reduced by more than 70% ! Yes, it’s not a typo: Koha with Plack will divide your server load by an astonishing 2.58 ! Or you will be able to manage a library 2.58 times larger with the same hardware. Or you’ll be able to have 2.58 times more librarians using Koha without changing your server.

Additional numbers
I also wanted to see if there was any difference on MySQL side.
I measured the number of SQL queries run by the script with this simple command:

mysql -e 'SHOW global status'|grep -E "Com_select|Com_insert|Com_update"

This command return the number of select, insert, update and delete that have been executed

With Plack mode:

      • 6 deletions
      • 68 inserts
      • 723 select
      • 25 updates

With CGI mode:

      • 6 deletions
      • 74 inserts
      • 1114 select
      • 25 updates

The biggest difference is on select (that’s not a surprise to me). I think it mostly comes from the fact that systempreferences are read only once with Plack, while they are read on each page in CGI mode (except if you have memcache activated, that I hadn’t)

Anyway, my main conclusion here is that we’re doing too much SQL read, CGI or Plack: the test load 16 pages, so it’s an average of 45 SELECT for each page. Most of them should be parameters (like branches, itemtypes,…) and that should be our next goal to continue improving speed and reducing server load !


The conclusion is clear = you should want Koha to run with Plack !

However, there are some counterparts I’ll try to list:

      • Plack is not (yet) shipped with Koha. To setup Plack, you’ll have to deal with command line configuration files editing. Fortunately, Dobrica (from Croatia) wrote a lot of usefull things on Koha wiki: And even if this documentation is long, you can expect some difficulties. Nothing impossible to solve for a system admin, but some tricky problems/questions
      • The price for speed is memory consumption. If you’re really low on memory, you may need to do some testings to check how it behaves !
      • possible nasty side effects: in CGI mode, everything is dropped once the page you request has been provided. With Plack, everything is kept in memory, to be ready if you need it again. It means that an error, a memory leak, a variable badly set, could stay wrong, and you won’t understand why Koha behaves suddenly strangely. Don’t over-estimate this risk, we tested a lot Plack, but it could happen, and you could be confused by those un-understandable problems

Those counterparts should not prevent you to try Plack, because it’s really a big improvement for Koha.

PS :


Leave a Reply

Your email address will not be published. Required fields are marked *