explaingit

moritzheiber/apprentice

Analysis updated 2026-07-09 · repo last pushed 2013-09-18

2RubyAudience · ops devopsComplexity · 2/5DormantSetup · moderate

TLDR

A small health-check tool for MySQL and MariaDB databases that tells your load balancer whether a database server is truly ready for live traffic by checking replication lag and cluster integrity.

Mindmap

mindmap
  root((repo))
    What it does
      Checks database health
      Exposes HTTP endpoint
      Returns 200 or 503
    What it checks
      Replica lag in seconds
      Replication is running
      Galera cluster status
    Use cases
      HAProxy integration
      Multi-replica setups
      Prevent stale data
    Tech stack
      Ruby
      MySQL
      MariaDB
    Audience
      Ops and DevOps
      Infrastructure engineers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Add health checks to HAProxy so it stops routing traffic to lagging MySQL read replicas.

USE CASE 2

Monitor Galera cluster node health and automatically pull unhealthy nodes out of rotation.

USE CASE 3

Prevent users from reading stale data by detecting replication lag beyond a configurable threshold.

What is it built with?

RubyMySQLMariaDB

How does it compare?

moritzheiber/apprenticemastodon/webpushgargron/pghero
Stars221
LanguageRubyRubyRuby
Last pushed2013-09-182025-01-132019-02-07
MaintenanceDormantStaleDormant
Setup difficultymoderatemoderateeasy
Complexity2/52/52/5
Audienceops devopsdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires a running MySQL or MariaDB server with replication or Galera cluster setup, plus a load balancer like HAProxy to make use of the health signal.

No license information is provided in the repository, so default copyright restrictions apply and you should contact the author before using it.

In plain English

Apprentice is a small health-check tool for MariaDB and MySQL databases. It tells your load balancer whether a specific database server is actually ready to handle live traffic, so you never accidentally send users to a database that's broken or falling behind. Here's the problem it solves: when you run multiple database servers, a load balancer usually just checks whether the server responds at all. But a database that's "alive" might still be unhealthy. It might be lagging behind the primary server by several minutes, serving stale data. Or in a cluster setup, it might have disconnected from the other nodes. Apprentice connects to the database and runs actual integrity checks, then exposes a simple HTTP endpoint: a 200 response means the server is healthy and ready, a 503 means stay away. The tool checks different things depending on your setup. For a standard MySQL/MariaDB replica, it verifies that replication is actively running and measures how many seconds behind the primary server the replica has fallen, with a configurable threshold (defaulting to 120 seconds). For a Galera cluster, it checks that the cluster has enough members, that replication is turned on, and that the node isn't in a bad state. You can optionally allow a "donor" state, where a node is sharing data with another cluster member, to still count as healthy. The typical user is someone running a multi-server database setup behind a load balancer like HAProxy. For example, if you have five read replicas handling user queries and one starts lagging behind by five minutes, Apprentice detects that and tells HAProxy to stop sending traffic to it until it catches up. This prevents users from seeing outdated data without you having to manually intervene. The project is notably minimal, weighing in at under 300 lines of Ruby code, and does one thing well. It doesn't load-balance connections itself or relay client traffic. It's purely a signal provider that helps your existing infrastructure make smarter routing decisions. The README notes that PostgreSQL support has been requested but not yet built.

Copy-paste prompts

Prompt 1
Write an HAProxy backend configuration that uses Apprentice's HTTP health check endpoint to route traffic only to healthy MySQL read replicas.
Prompt 2
Help me set up Apprentice to check a MariaDB replica with a replication lag threshold of 60 seconds instead of the default 120 seconds.
Prompt 3
Explain how to run Apprentice as a sidecar service next to my MySQL Galera cluster nodes and wire it into my load balancer for automatic failover.
Prompt 4
Generate a systemd service file for running Apprentice as a daemon that checks my MariaDB replica health and exposes the HTTP endpoint on port 8080.

Frequently asked questions

What is apprentice?

A small health-check tool for MySQL and MariaDB databases that tells your load balancer whether a database server is truly ready for live traffic by checking replication lag and cluster integrity.

What language is apprentice written in?

Mainly Ruby. The stack also includes Ruby, MySQL, MariaDB.

Is apprentice actively maintained?

Dormant — no commits in 2+ years (last push 2013-09-18).

What license does apprentice use?

No license information is provided in the repository, so default copyright restrictions apply and you should contact the author before using it.

How hard is apprentice to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is apprentice for?

Mainly ops devops.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.