concept invariant in category microservice

This is an excerpt from Manning's book The Tao of Microservices.
A given business process is encoded by an expanding set of messages generated from an initial triggering message. Thus, message-flow rates are related to each other by ratios. For example, for every message of a certain kind, you expect to see two messages of another kind. These ratios don’t change, no matter what the load level of the system or the number of services present. They’re invariant.
Invariants are the primary indicator of health. When you deploy a new version of a microservice using the Canary pattern, you check that the invariants are within expected bounds. If the new version contains a defect, the message-flow ratios will change, because some messages won’t be generated. This is an immediate indicator of failure. Invariants, after all, can’t vary. We’ll come back to this topic in chapter 6 and examine an example in chapter 9.
Invariants are time series–based data. You calculate the ratio at a point in time (representing some previous time window). You’ll have lots of invariants, so you’ll again run into the problem of reviewing large numbers of time series charts. As before, you can use a current-behavior scatterplot to solve this problem.
Each business requirement that’s encoded by a message flow establishes an invariant. Consider the microblogging system. When posting a new entry, it generates a synchronous message to the entry store and an asynchronous announcement message about the entry (see figure 6.16). Thus the flow-rate ratio between the post:entry message and the two messages it causes (info:entry and store:save,kind:entry) is 2.
Starting from the basic approach to microservice system design—the decomposition of business rules into message flows—you can build this set of invariants to validate the system under continuous change. This allows you to make changes quickly and safely without breaking things. When one or more invariants deviate, you can roll back the last change.
Invariants also let you check the health of the live system. Between deployment changes, many other things can go wrong: bugs can be triggered, load thresholds can be reached, memory leaks can push systems over the edge, poison messages can cause progressive degradation, and so on. You can use invariants to monitor the system for any failure to operate as designed. A problem, by definition, impacts the correct functionality of the system and breaches the invariants.
You should consider automating the configuration of invariants derived from business rules. Because the business rules are expressed directly as message flows, you can do this for every business rule.