Chapter 11

  1. A microservice-based architecture brings a lot of benefits to the table. However, at the same time, it adds a lot of complexity to a system and requires additional effort to make it resilient against network issues, to monitor its internal state, and to debug issues when something goes wrong. Consequently, selecting this pattern for an MVP or PoC is often considered to be a form of premature optimization that likely introduces more issues than it solves.
  1. When the number of errors from a particular downstream service exceeds a particular threshold, the circuit breaker is tripped and all future requests automatically fail with an error. Periodically, the circuit breaker lets some requests go through and after a number of successful responses, the circuit breaker switches back to the open position, thereby allowing all the requests to go through.
  2. Being able to trace requests as they travel through a system allows us to do the following:
    • Figure out how much time the request spends in each service and identify potential bottlenecks
    • Understand and map the dependencies between services
    • Pinpoint the root cause of issues that affect production systems
  1. Log entries may contain sensitive information such as credit card numbers, security credentials, customer names, addresses, or social security numbers. Unless we actively sanitize these entries, this information will end up in the logs and could be potentially visible to entities (employees or third parties) that are not authorized to access this kind of information.
  2. To collect logs from the pods running in a Kubernetes cluster, we can use one of the following strategies:
    • Use a daemon set to run a log collector on each Kubernetes node. The log collector digests the log files from each pod running on the node and ships them to a centralized log storage location.
    • Deploy a sidecar container in the same pod as the application whose logs we want to collect. The sidecar digests the application logs (which could be a single file or multiple files) and ships them to a centralized log storage location.
    • Ship logs directly from within the application.