Multi-tenancy is a key feature in Hyku, one of the enhancements on base Hyrax. Many potential adopters might not fully understand what multi-tenancy brings to the table or how it is achieved. Rob Kaufman, Senior Partner at Notch8, spoke on the topic at Virtual Connect 2019. His presentation, which serves as the basis for the following, can be found here.


What is Multi-Tenancy?

Multi-tenancy provides the ability to stand up multiple discrete digital repositories within one instance of an application – a functionality currently built into Hyku. There is one code base and one set of application instances implemented, but it allows for many data sets and many unique user interface portals, each with a different theme and branding. These discrete repositories have their own permissions, allowing for their own individual users. An example of this in practice is a Hyku instance for a library consortium, inside which several member libraries have their own branded repository with collections available only to their users.


The Apartment Gem

Hyku is built on Hyrax, and in utilizing the multi-tenancy feature, each tenant acts like an individual instance of Hyrax. This functionality is powered by the Apartment Gem, a ruby gem incorporated into Hyku. The Apartment Gem allows different subdomains to be different tenants, isolating the data so that there is no cross-contamination between them.

The Apartment Gem provides several functions that are essential to realize multi-tenancy. It has the ability to take a request and figure out which tenant to load via Rack Middleware. It is also programmed to connect to a given tenant, providing commands to switch between tenants. Helpers and ActiveRecord extensions are employed to allow maintenance of tenants and isolates/protects them from each other. Finally, it provides the ability to create non-tenant tables, allowing for data to be available across all tenants.

The Apartment Gem powers multi-tenancy in Hyku by interacting with the essential building blocks of the application. On the back-end, Postgres uses schemas that allow multiple data sets within a single data structure, which facilitates faster switching and better performance (Mysql and Sqlite create different databases per tenant). It integrates with Fedora, Redis, and Solr by changing the connection url for every tenant, which means no shared data across tenants. Different Fedora instances can be used to split the load without it becoming necessary for those instances to be aware of each other.

Further information on how the Apartment Gem functions in Hyku can be found here.


Challenges of Multi-Tenancy

Multi-tenancy is a powerful feature, but comes with a few challenges. Developers and administrators have to be made decisions on what to isolate versus what to share among tenants. Maintaining backups can be a challenge with multi-tenancy. Administration of various tenants requires individual rules and handling. When upgrades roll out, they are automatically across all tenants. An internal team with enough knowledgeable tech guidance can educate themselves and navigate these challenges. However, for users without those resources, additional developmental support can be helpful. A provider of a Hyku solution bundle like HykuUP can assist in leading an adopter to success.