liveBook · Manning

Reliability

As explained in Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform

The capability of a system to perform its required functions consistently under stated conditions for a stated period.

Reliability measures how long a system performs correctly within a stated period. In infrastructure changes, it limits disruption by keeping a working backup environment ready to receive production traffic. section 9.1.2

Implement reliability during infrastructure changes by:

  • Create an active environment and an idle passive environment in separate regions. section 9.1.2
  • Keep resource names, regions, network ranges, and labels distinct in the passive configuration. section 9.1.2
  • Reduce the active load-balancer weight to zero and set the passive weight to 100 during failover. section 9.1.2
Listing 9.2 Failover to passive sundew environment in us-west1
import blue                                                       #1
import passive                                                    #1
 
services_list = [
   {
       'version': 'blue',                                         #2
       'zone': blue.zone,
       'name': f'{shared_name}-blue',
       'weight': 0                                                #3
   }, {
       'version': 'passive',                                      #2
       'zone': passive.zone,
       'name': f'{shared_name}-passive',
       'weight': 100                                              #4
   }
]
 
 
def _generate_backend_services(services):                         #5
   backend_services_list = []
   for service in services:
       version = service['version']
       weight = service['weight']
       backend_services_list.append({
           'backend_service': (                                   #6
               '${google_compute_backend_service.'                #6
               f'{version}.id}}'                                  #6
           ),                                                     #6
           'weight': weight,                                      #6
       })
   return backend_services_list
 
 
def load_balancer(name, default_version, services):
   return [{
       'google_compute_url_map': {                                #7
           TEAM: [{
               'name': name,
               'path_matcher': [{
                   'name': 'allpaths',
                   'path_rule': [{                                #8
                       'paths': [                                 #8
                           '/*'                                   #8
                       ],                                         #8
                       'route_action': {                          #9
                           'weighted_backend_services':           #9
                               _generate_backend_services(        #9
                                   services)                      #9
                       }                                          #9
                   }]
               }]
           }]
       }
   }]

Shows the traffic-control configuration that switches requests from the failed active environment to the passive region. section 9.1.2

How Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform covers it

How deep it goes
Defines reliability and works through regional standby construction and load-balancer failover, but only previews active-active refactoring.
Examples
Uses Python configuration files, separate regional environments, and weighted load-balancer services as concrete examples.
What you can do after
Operate/configure an active-passive deployment and redirect all production traffic to its standby environment after failure.
How it connects
Connects reliability with active-passive configuration, failover, infrastructure as code, regions, and global load balancing.

Also explained in

Compare how 13 books explain reliability →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform. The section links point to the parts of the book it draws on.