Awesome! I finally finished learning the microservices actual documentation compiled by Ali P8 architects for 7 years.

In the past 5 years, the microservice architecture style (organizing applications through a series of fine-grained, loosely coupled, and independently deployable services) has become more and more popular. Regardless of the size of the company, microservices are becoming more and more feasible for the engineering team alone.

This article mainly introduces the content related to the development and deployment of microservices, supplemented by practical examples to guide readers through the whole process from design to deployment of microservices.

By studying the content of this article, readers will understand how to develop and deploy microservice applications, how to achieve effective continuous delivery through microservices, and how to develop examples using Kubernetes, Docker, and Google Container Engine.

This article is suitable for intermediate developers and architects who understand enterprise-level application architecture and cloud platforms (such as AWS and GCP), and is also suitable for readers who are interested in microservices.

Contents of this article

 

main content

There are a total of 13 chapters in this article, leading you to thoroughly interpret the actual combat of microservices. Because there is too much content, only part of the knowledge points can be introduced to you. I hope you can understand and like it! !

Chapter 1 Design and Operation of Microservices;

  • (1) Microservices are not only an architectural style, but also a collection of a series of cultural habits. It is supported by five core principles, which are autonomy, recoverability, transparency, automation, and consistency.
  • (2) Microservices reduce development conflicts and realize autonomy, technical flexibility and loose coupling.
  • (3) The design process of microservices is very challenging, because it not only requires a wealth of business domain knowledge, but also requires developers to balance priorities among teams.
  • (4) The service exposes the contract to other services. A well-designed contract is concise, complete and predictable.
  • (5) In long-running software systems, complexity is inevitable, but developers can reduce conflicts and risks through some decisions, and then continue to deliver value in these systems.
  • (6) Automated and verifiable release operations can make the deployment process more reliable and "no accidents", thereby reducing the risk of microservices.
  • (7) The container technology abstracts the differences between the services in the operating environment and simplifies the large-scale management of different types of microservices.
  • (8) Failure is inevitable: For the team, microservices need to be transparent and easy to observe, so that the team can actively manage, understand, and truly own the service operation and maintenance; vice versa.
  • (9) The team that adopts microservices needs to be mature in operation and maintenance, and focus on the entire life cycle of the service, not just the design and development phase.

 

Chapter 2 SimpleBank’s microservices;

  • (1) Microservices are very suitable for systems with multi-dimensional complexity, such as the scope of product supply, global deployment and regulatory pressures.
  • (2) When designing microservices, it is important to understand the product business area.
  • (3) Service interaction can be of orchestration type, or orchestration type. The latter will increase the complexity of the system, but can reduce the degree of coupling between services in the system.
  • (4) API Gateway is a common mode, which encapsulates and abstracts the complexity of the microservice architecture, so front-end or external consumers do not need to consider this part of the complexity.
  • (5) If the developer fully trusts his service to handle the traffic pressure in the production environment, it can be said that the service is production-ready.
  • (6) If developers can reliably deploy and monitor a service, they can have more confidence in this service.
  • (7) Service monitoring should include log aggregation and service-level health checks.
  • (8) Microservices will fail due to hardware, communication and dependencies. It is not only the defects in the code that cause the failure to occur.
  • (9) Collecting business indicators, logs, and link tracking records between services is essential for understanding the current and past performance of microservice applications.
  • (10) As the number of microservices and support teams continues to increase, technical disagreements and isolation will increasingly become challenges for technical teams.
  • (11) Avoiding technical disagreement and isolation requires the adoption of similar standards and best practices among different teams, regardless of the technical basis used.

 

Chapter 3 Microservice Application Architecture;

  • (1) Individually, the internal and monolithic applications of microservices are similar.
  • (2) A microservice application is like a block: its final appearance is not specified, but is guided by a series of guidelines and high-level summary models.
  • (3) The guidelines that guide the microservice architecture will reflect the organization's goals and have an impact on the team's practice.
  • (4) Architecture planning should promote sound development, rather than forcibly specifying the entire application program.
  • (5) Microservice application is composed of four layers: platform layer, service layer, boundary layer and client layer.
  • (6) The platform layer provides a series of tools and infrastructure to support the development of production-oriented services.
  • (7) In microservice applications, synchronous communication is usually the first choice, and it is very suitable for command-based interaction, but it also has shortcomings that increase coupling and instability.
  • (8) Asynchronous communication is more flexible and can adapt to rapid system evolution, at the cost of increased complexity.
  • (9) Common asynchronous communication modes include queues and publish-subscribe.
  • (10) The boundary layer is a facade of microservice applications, which is very suitable for external consumers.
  • (11) Common boundary layer patterns include API gateways and consumer-driven gateways (such as GraphQL).
  • (12) Client applications, such as websites and mobile applications, interact with the mobile backend through the boundary layer.
  • (13) The client is at risk of becoming more and more bloated, but now it is also beginning to appear-some technologies that apply microservice principles to front-end applications.

 

Chapter 4 New Function Design;

  • (1) Understand the business problem-identify the entity and use case-divide the service responsibility, we can use this process to delimit the service scope.
  • (2) Services can be divided in different ways: by business function, by use case, and by volatility. Readers can use these methods comprehensively.
  • (3) A good division decision can make the service meet the three key characteristics of microservices: only responsible for single-responsibility, replaceable and independently deployable.
  • (4) The bounded context usually corresponds to the service boundary. This is a very effective method when thinking about the future development of the service.
  • (5) Through in-depth thinking on changeable fields, developers can encapsulate those fields that will change to improve the ability to adapt to future changes.
  • (6) If the service division is not good, the cost of post-modification is particularly high, because by then, developers need to refactor multiple code bases, and the resulting workload will become particularly large.
  • (7) We can also encapsulate technical functions into a service, which can simplify business capabilities, provide support for business functions, and maximize service availability.
  • (8) If the service boundary is not clear enough, we would rather choose coarse-grained services, but take the initiative to adopt modular solutions within the services to prepare for future splits.
  • (9) Service offline is a particularly challenging task, but with the continuous development of microservice applications, we will need to do this one day in the future.
  • (10) In large organizations, it is necessary to split ownership among multiple teams, but this will introduce new problems: weak control, limited design, and inconsistent development speed.
  • (11) Open code, clear interfaces, continuous communication, and relaxation of the requirements of the DRY principle can all ease the tension between teams.

 

Chapter 5 Microservices and queries;

  • (1) It is very difficult to implement ACID characteristics in cross-service interaction, and microservices need to adopt different methods to achieve consistency.
  • (2) Coordination schemes like two-phase submission will introduce locking operations, and the scalability is not good.
  • (3) The event-based architecture can release the coupling between individual components, and lay the foundation for the scalability of the business logic and query of microservice applications.
  • (4) Prefer high availability rather than consistency, which will make the architecture more scalable.
  • (5) Saga is a global operation composed of independent local transactions driven by group messages. They roll back the wrong state through compensation operations to achieve consistency.
  • (6) When building microservices that reflect the real-world environment, foreseeing failure scenarios and preparing for it is a very important part of the content, but the isolation of operations is not so critical.
  • (7) We usually realize the query function across multiple microservices by combining the results of multiple APIs.
  • (8) Efficient compound queries should use CQRS mode to implement a set of independent read data models, especially when those query modes need to use another data storage system.

 

Chapter 6 Designing Highly Reliable Services;

  • (1) In complex distributed systems, failures are inevitable. When designing these systems, developers must consider fault tolerance.
  • (2) The availability of each service will have an impact on the availability of the entire application.
  • (3) Develop appropriate strategies for each application to reduce the risk of failure, which requires careful consideration of the frequency and impact of failures, and reducing the increased costs of these rare failure events.
  • (4) Most failures occur in 4 areas: hardware, communication, dependencies, and internal.
  • (5) Cascading failures caused by positive feedback is a very common failure form in microservice applications. Usually, most of the cascading failures are caused by service overload.
  • (6) Retry and timeout strategies can be used to reduce the impact of failures in service interactions. When using the retry method, developers should be extra cautious to avoid aggravating the failure of other services.
  • (7) Back-up schemes (fllback) such as caching, candidate services, and default values ​​can be used to return successful results, even if the service dependency is unavailable.
  • (8) The timeout period should be propagated to downstream services in the service interaction, so as to not only ensure that the timeout period is consistent throughout the system, but also reduce wasteful work.
  • (9) When the amount of errors reaches a certain threshold, the circuit breakers between services will fail quickly to avoid cascading failures.
  • (10) The service can use a current limiting strategy to protect it from sudden peak load requests that exceed the capacity of the service.
  • (11) Each service should open a health check interface for the load balancer and monitoring system for its use.
  • (12) The recoverability of the system can be effectively verified through stress test and chaos test.
  • (13) Some standards can be adopted—whether through frameworks or agents—to help engineers quickly ("flall into the pit of sccess""") develop fault-tolerant services by default.

 

Chapter 7 Build a reusable microservice framework;

  • (1) The microservice base can speed up the startup of new services, expand the field of experimentation and reduce risks.
  • (2) Using the service base allows developers to extract code implementations related to certain infrastructure.
  • (3) Service discovery, observability, and different communication protocols are all the content of the service base, and the service base needs to provide these functions.
  • (4) If suitable tools exist, we can quickly develop prototypes for complex functions such as placing orders and selling stocks.
  • (5) Although the microservice architecture is often associated with the possibility of using any language to develop systems, in a production environment, these systems need to ensure and provide mechanisms to make operation and maintenance manageable.
  • (6) The microservice base can achieve the above guarantees, and at the same time allow developers to quickly start and develop to verify the correctness of the idea. If the verification passes, it can be deployed to the production environment.

 

Chapter 8 Microservice Deployment;

  • (1) The deployment of new applications and changes must be standardized, simple and clear, so as to avoid friction in the microservice development process.
  • (2) Microservices can run anywhere, but the ideal deployment platform needs to support a series of functions, including security, configuration management, service discovery, and redundancy.
  • (3) The developer deploys a typical service as a set of identical instances and connects to a load balancer.
  • (4) Instance groups, load balancers and health checks can enable the deployed services to realize self-healing and automatic expansion.
  • (5) Service artifacts must be immutable and predictable to minimize risk, reduce cognitive difficulty, and simplify deployment abstraction.
  • (6) Developers can package services as language-specific packages, operating system packages, virtual machine templates, or container images.
  • (7) Adding/removing a single instance of a microservice is a basic primary operation, which can be combined into a higher-level deployment by developers.
  • (8) Developers can use canary deployment or blue-green deployment to reduce the impact of unexpected defects on usability.

 

Chapter 9 is based on the deployment of containers and schedulers;

  • (1) Packaging microservices as immutable and executable artifacts allows developers to orchestrate the deployment process through basic operations (adding or removing containers).
  • (2) In order to facilitate service development and deployment, the scheduler and container will extract the underlying machine management concept.
  • (3) The job of the scheduler is to try to match the resource requirements of the application with the resource usage of the cluster machines, and to perform health checks on the running services to ensure that they are running correctly.
  • (4) Kubernetes has the ideal features of a microservice deployment platform, including password credential management, service discovery, and horizontal expansion.
  • (5) Kubernetes users define the desired cluster service state (or specification), and Kubermetes will continuously perform the "observation-comparison execution" cycle operation to calculate how to achieve the desired state.
  • (6) The logical application unit of Kubernetes is a pod: a container or multiple containers executed together.
  • (7) The replication set manages the life cycle of the pod group. If an existing pod fails, the replication set will start a new pod.
  • (8) The deployment objects in Kubernetes are designed to maintain service availability by performing rolling updates to the pods in the replication set.
  • (9) Developers can use service objects to group the underlying pods and provide access to other applications inside and outside the cluster.

 

Chapter 10 Building a Microservice Delivery Pipeline;

  • (1) The microservice deployment process should meet two major goals: rhythm security and consistency.
  • (2) The time it takes to deploy a new service is usually a major obstacle in microservice applications.
  • (3) Continuous delivery is an ideal deployment practice for microservices. It reduces risks by quickly delivering small versions of verified change sets.
  • (4) A good continuous delivery pipeline can ensure the visibility of the deployment process, the correctness of the deployment results, and the ability to feed back rich information to the engineer team.
  • (5) Jenkins is a very popular automated build tool. It uses a scripting language to link different tools together and combine them into a delivery pipeline.
  • (6) The pre-release environment is very valuable, but when faced with a large number of independent changes, maintaining the pre-release environment also faces huge challenges.
  • (7) Readers can reuse declarative pipeline steps on various services; actively promoting standardization can improve the predictability of the deployment process among different teams.
  • (8) In order to provide fine-grained control over release and rollback, readers should separate the deployment of this technical activity from the business activity of function release.

 

Chapter 11 Building a monitoring system;

  • (1) A reliable microservice monitoring system includes metrics, link tracking and logs.
  • (2) Collecting rich data from microservices helps developers find faults, investigate problems, and understand the performance of the entire application.
  • (3) When collecting metrics, developers should focus on the four golden signs: latency, error volume, communication volume (throughput), and saturation.
  • (4) Prometheus and StatsD are two common and language-independent tools for collecting metrics from microservices.
  • (5) Developers can use Grafana to display metric data in the form of charts, create human-readable dashboards and trigger alarms.
  • (6) If the alarms based on metric indicators reflect the symptoms of system abnormalities rather than the causes, then these alarms are more durable and maintainable.
  • (7) A well-defined alarm should have a clear priority, be able to be upgraded to the corresponding personnel level by level, be operable and contain concise and valuable information.
  • (8) The data collected and aggregated from multiple services allows developers to associate and compare completely different metrics, so as to have a more comprehensive understanding of the system.

 

Chapter 12 uses logs and link tracking to understand system behavior;

  • (1) Readers can use Elasticsearch, Kibana and Fluentd to build a log infrastructure, and use Jaeger to build a distributed link tracking system.
  • (2) The log infrastructure can generate, forward and store indexed log data to facilitate retrieval and correlation of different requests.
  • (3) Distributed link tracking enables developers to track the execution process of requests between different microservices.
  • (4) In addition to the collection of metrics, link tracking allows developers to better understand the operation of the system, discover potential problems and review the system at any time.

 

Chapter 13 Microservice Team Building;

  • (1) The construction of excellent software is not only related to the implementation of the selected solution, but also related to effective communication, coordination and collaboration.
  • (2) Application architecture and team structure have a symbiotic relationship. You can use the latter to change the former.
  • (3) If you want the team to become efficient, they should be organized to maximize autonomy, ownership, and end-to-end responsibilities.
  • (4) In terms of microservice delivery, cross-functional teams are faster and more efficient than traditional functional teams.
  • (5) Larger engineering organizations should establish a hierarchical model with infrastructure, platform, and product teams. Lower-level teams provide services to higher-level teams to ensure that they can work more effectively.
  • (6) Community practices (such as associations and branches) can share functional knowledge.
  • (7) It is difficult for all microservice applications to be installed in the human brain, which brings challenges to global decision-making and engineers on duty.
  • (8) The architect should guide and influence the evolution of the application, rather than dominate the direction and results of the application.
  • (9) The internal open source model can improve cross-team collaboration, weaken possessiveness, and reduce the risk of bus factors.
  • (10) Design review can improve the quality, accessibility and consistency of microservices.
  • (11) The microservice documentation should include an overview, operation manual, metadata, and service contract.

 

This [microservices actual combat] document has a total of 331 pages. If you need a full version, you can forward this article and follow the editor, scan the code below to get it! !

 

Guess you like

Origin blog.csdn.net/bjmashibing001/article/details/113265907