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!

The cheapest, fastest way to send money internationally

Full disclosure: We may receive commissions through affiliate links contained on this page.

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!

The cheapest, fastest way to send money internationally

Full disclosure: We may receive commissions through affiliate links contained on this page.

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 [email protected]% 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

The cheapest, fastest way to send money internationally

Full disclosure: We may receive commissions through affiliate links contained on this page.

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.

    The cheapest, fastest way to send money internationally

    Full disclosure: We may receive commissions through affiliate links contained on this page.

    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/

      The cheapest, fastest way to send money internationally

      Full disclosure: We may receive commissions through affiliate links contained on this page.

      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!

      The cheapest, fastest way to send money internationally

      Full disclosure: We may receive commissions through affiliate links contained on this page.

      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
      The Top 10 Biggest Libraries in the World

      The Top 10 Biggest Libraries in the World

      Libraries comes in all types and sizes, from small community libraries that open for a few hours once a week to mega institutions that operate 24 hours a day, 7 days a week. So which are the biggest, most impressive libraries in the world - by catalog size of course;...

      read more
      Cage Match: Koha Library System vs Athenaeum

      Cage Match: Koha Library System vs Athenaeum

      If you are shopping around for a new library software, you may have come across Koha and Athenaeum in your web searches. I hope you will find this article helpful as you compare the two and try to make a decision. Despite the Greek sounding name of Athenaeum, both...

      read more
      Z39.50 Server Directory

      Z39.50 Server Directory

      Copy cataloging is one of the most useful tools your library system has (or should have). It works by importing ready made MARC records from external sources like the Library of Congress. This will make cataloging much faster and easier, saving you time and money in...

      read more

      0 Comments

      Submit a Comment

      This site uses Akismet to reduce spam. Learn how your comment data is processed.