See also: How to manage units

In Juju, a unit is a deployed charm.

An application’s units occupy machines.

Simple applications may be deployed with a single application unit, but it is possible for an individual application to have multiple units running on different machines.

All units for a given application share the same charmed operator code, the same relations, and the same user-provided configuration but one of them called the leader unit is different and is responsible for managing the lifecycle of the application. For example, one may deploy a single MongoDB application, and specify that it should run three units (with one machine per unit) so that the replica set is resilient to failures. Internally, even though the replica set shares the same user-provided configuration, each unit may be performing different roles within the replica set, as defined by the charm. This is represented in the diagram below:


A unit is always named on the pattern <application>/<unit ID>, where <application> is the name of the application and the <unit ID> is its ID number or, for the leader unit, the keyword leader. For example, mysql/0 or mysql/leader. Note: the number designation is a static reference to a unique entity whereas the leader designation is a dynamic reference to whichever unit happens to be elected by Juju to be the leader .

I would add a more concrete scenario at the end to better explain the three mongodb units. I saw somewhere else an example where unit1 is the ‘main db’, unit2 does backup, and unit3 does hot storage caching. (but I’m not sure this is correct) I think this would make the explanation much more useful.

Thanks for your suggestion, @ppasotti. Made a note to update. PS Do you remember by any chance where you saw that other example?

No… If it comes back to mind I’ll let you know.

1 Like