Koha Hacks: 4 Tricks To Supercharge Koha Library System (Running On Ubuntu 20.04LTS)

Is your Koha server taking too long to catalog or checkout items? Before you break the bank and purchase a bigger server with bucket-loads of RAM and processing power, try out the following tune-ups instead – you might just save yourself a lot of time and money!

Koha Hacks: 4 Tricks To Supercharge Koha Library System (Running On Ubuntu 20.04LTS)

Is your Koha server taking too long to catalog or checkout items? Before you break the bank and purchase a bigger server with bucket-loads of RAM and processing power, try out the following tune-ups instead – you might just save yourself a lot of time and money!

Tweaking Your Koha Library Server

Pro Tip: You should regularly check Koha’s Home > About Koha page. It gives you a quick overview of your server information. If there are any errors, missing applications or dependencies that might be slowing down your server, they will show up here. Now, read on to find out how to make the most of Koha library system.

Koha ILS About Page

 1. Enable caching with Memcached

Memcached works by storing data in your server’s RAM and serving requests  from the memory cache instead of passing on queries to your database server. This speeds up your application (in this case, Koha) and reduces the load on your SQL database. To install Memcached on your Koha server, do the following (remember to backup your data before your start!):

1. Check if Memcached isn’t installed already

ps -A | grep memcached

If you get a response like 537 ? 00:10:52 memcached then Memcached is already installed and you can skip the installation. You can also go to Home > About Koha to check.

2. Install Memcached

sudo apt update

sudo apt upgrade

sudo apt install memcached

3. Configure Memcached in koha-conf.xml

Koha comes with the section for Memcached already configured but sometimes s!@% happens and you have to do it manually. Skip this section if the memcached section is properly configured.

sudo nano /etc/koha/sites/library/koha-conf.xml

where library is the name of your Koha instance. Around line 300 after the <!-- <zebra_loglevels>none,fatal,warn</zebra_loglevels> --> line, you should see the following

<memcached_servers>127.0.0.1:11211</memcached_servers>

<memcached_namespace>koha_library</memcached_namespace>

<template_cache_dir>/var/cache/koha/library/templates</template_cache_dir>

Add these lines if they are missing, replacing ‘library’ with your Koha instance name.

4. Enable and start Memcached

sudo systemctl start memcached.service

5. Check to see that Memcached is running.

Go to Home > About Koha page.

If you configured everything correctly, you should see the following highlighted in green line under Server Information:

Memcached: Servers: 127.0.0.1:11211 | Namespace: koha_demo | Status: running. | Config read from: koha-conf.xml

2. Install Plack

    Plack is “an interface between Perl web applications and web servers” and makes Koha’s modules persistant so that they don’t have to be loaded everytime they are needed. Plack makes Koha work faster – much, much faster. One test showed that it increased Koha’s processes by 25% and reduced the server load by 70% (this means Plack enables a server to handle the same computational processes with more than 2 times few resources as another server without Plack). 

    Plack is included in Koha by default but sometimes it may need to be enabled (again check your About Koha page to see if it’s running or not).  Do the following:

    sudo koha-plack --enable library
    sudo koha-plack --start library
    sudo systemctl restart apache2.service

    Then check your Home > About Koha page. You should have “PSGI: Plack (deployment)” under Server Information if Plack is running and configured correctly.

    3. Enable Apache Caching

      Just like Memcached, enabling Apache Caching will increase your Koha web server’s speed and reduce the overall load on your server.

      1. Install Apache Cache

      sudo apt update

      sudo apt install apache2-utils

      2. Enable Apache cache modules

      sudo a2enmod cache

      sudo a2enmod cache_disk

      sudo a2enmod expires

      sudo a2enmod headers

      3. Restart Apache Web Server

      sudo systemctl restart apache2

      4. Update Koha’s Virtual Hosts Configuration

      sudo nano /etc/apache2/sites-available/library.conf

      Scroll to the bottom of the file and add the following lines just before line </VirtualHost> in both your OPAC and staff virtual host sections.
      CacheQuickHandler off
      CacheLock on

      CacheLockPath /tmp/mod_cache-lock

      CacheLockMaxAge 5

      CacheIgnoreHeaders Set-Cookie

      CacheEnable disk
      CacheHeader on
      CacheDefaultExpire 800

      CacheMaxExpire 64000

      CacheIgnoreNoLastMod On

      ExpiresActive on

      ExpiresDefault A300

      Save and Exit the file.

      Note: You can set the CacheQuickHandler on or off. If it is set to on, then when requests are made to the server, the cache will be checked first without consulting Apache. This will make your server faster but it’s a bad idea if you need users to be logged in or authenticated first before they can access data (which I assume will be the case for most libraries). I recommend setting it to ‘off’ so that Apache can still authenticate users before serving content.

      5. Test Apache Configuration

      Test Apache configuration to check that there are no errors.

      sudo apachectl configtest

      6. Restart Apache Web Server

      If there are no errors, restart Apache web server to enable cache.

      sudo systemctl restart apache2

      7. Test Apache Cache

      You can test if the Apache cache is working by viewing the contents of directory where the cache is stored. The size of these directories and the number of files in them will grow with with time.

      ls -la /var/cache/apache2/mod_cache_disk/

      4. Setup A Content Delivery Network (CDN)

      The server on which are running your Koha instance is located in a single, specific geographic region, even if it is a “cloud” server. This means it will take users who are located in another different geographic location longer to access your Koha library. While this may not be an issue if you are hosting Koha on a local server or using a host who is in the same city or country as your patrons, it may be a bigger problem if you are using a cloud service like Amazon AWS.

      Say you are a library located in Zimbabwe and you choose to launch your server in the US-East (Ohio) region instead of the Africa (Cape Town) region, which would be the one closest to you. This saves you money since US-based servers are cheaper (a t3.xlarge server located in Cape Town costs $0.217 per hour vs. $0.1344 per hour for a comparable server in the US) but it comes at the cost of speed for your users. Instead of doubling your server costs and switching regions, you can use a content delivery network (CDN) to serve content faster.

      A CDN does the same thing as Apache and Memcached caching does, but on a much larger scale.  It uses proxy servers that are located closer to end users than origin (i.e. your main) servers. The CDN will cache the content from your Ohio-based server and distribute the cache to its own servers scattered around the world, which will likely include your own geographic location. So when a patron logs on to your OPAC, they will likely see cached content served from the CDN’s proxy servers than from your main server. This improves speed of access, security, and the overall reliablity of your servers. I recommend you use Cloudflare – it has a free tier which should be more than enough for most libraries. Setting up a Cloudflare CDN is beyond the scope of this article but I will write a separate one soon so make sure you subscribe to stay up to date with the latest tips and tricks!

      Speed is of the essence in today’s world so it’s important you optimize your Koha library system server to ensure your patrons and staff can do their work quickly and efficiently. Let me know how implementing these hacks went for you in the comments. And if you need help, don’t hesitate to get in touch. 

      Koha Support provides hassle-free Koha installation and cloud hosting as well as training, data migration, customization and technical support. Check out our packages and start your free trial today!

      7 Reasons Why You Need an Integrated Library Management System

      7 Reasons Why You Need an Integrated Library Management System

      Running a library isn’t as simple and straightforward as many people I have encountered think. It’s more than just checking out books and putting them back on the shelf when they are returned. Librarians have to deal other complex, time-consuming responsibilities like acquisitions, cataloguing, inventory, budgets, reports and interlibrary loaning. Pen and paper won’t cut it, and using an excel spreadsheet is only marginally better than digging a trench using a caviar spoon.

      read more

      What Is The Difference Between MySQL Plugins?

      The MySQL database management system provides different authentication plugins to authenticate users with the database. Three commonly used plugins are mysql_native_password, caching_sha2_password, and auth_socket. 1. mysql_native_password: The mysql_native_password...

      read more

      A Comparison Of Koha Library Management System vs Opals

      Koha Integrated Library System (ILS) and OPALS (Online Public Access Library System) are both open source solutions that have gained popularity in the library management world. While both systems have their pros and cons, Koha offers several advantages compared to...

      read more

      Top 10 Courses For Librarians Cost Duration

      Here is the average cost and duration for each of the top 10 courses or degrees for librarians: 1. Master of Library Science (MLS) – The cost varies depending on the institution and location, but on average, the cost is between $15,000 to $35,000. The duration is...

      read more

      Top 10 Courses For Librarians Cost Duration Links

      Here are the top 10 best courses or degrees for librarians, along with cost and average duration information and links to some programs: 1. Master of Library Science (MLS) - This is the most common and widely recognized degree for librarians. The average cost of a MLS...

      read more

      What Are Acquisitions In Library Management?

      Acquisition in Library Management refers to the process of acquiring materials and resources such as books, journals, e-books, databases, and other information sources to support the needs and objectives of a library's user community. This process is critical to the...

      read more

      Library Terminology Every Librarian Should Know

      Every librarian should be familiar with the following key terminologies: 1. Cataloging: The process of organizing, describing and classifying library materials. 2. Classification: The system used to arrange library materials into categories based on subject or genre....

      read more

      How To Classify Library Items Using Ddc Or Lcc

      Classifying an item in library management is the process of organizing books, journals, and other materials into categories, so that they can be easily retrieved and used by library patrons. The purpose of classification is to arrange materials in a systematic order...

      read more