Micro-service monitoring of the five principles

I. Background

And the emergence of micro-container services and large number of applications, changing the composition and operation mode application system fundamentally. With the developers started to use the system to manage the scheduling and deployment of containers, further rules have changed. A simple application on the host in the past, has now become a complex, dynamic choreography, architecture and more container, which is also monitoring the application of the proposed new challenges.
Sysdig, is focused on system troubleshooting and monitoring tools company, its products Sysdig Cloud is located in troubleshooting and monitoring of the container system platform. In JFrog SwampUp user conference held this year on, Sysdig company proposes five key principles for monitoring container and building on its micro-services. These principles take full account of the differences and micro-container services and traditional architecture on the operation and maintenance of the way.
This article is based on Sysdig gathered from company video presentations at the conference on.

Second, what is micro-services

To properly monitor micro-services, we must first properly understand what is micro-services.
Micro-service monitoring of the five principles

Martin Fowler first speech cited the definition of micro services (Martin Fowler is an internationally renowned expert in the analysis of object-oriented design, UML, patterns and so on, one of the founders of agile development, is now chief scientist for ThoughtWorks. A lot of people understand micro services architecture is the beginning of this article from Martin Fowler's), or "micro services architecture" describes a particular way of software applications designed to deploy a set of independent services. Among them, "characteristics around operational capacity", that is, not based services division of micro size of the program, but to split the operational capacity as a reference. After this service business segments, as well as automated deployment, endpoint intelligent, decentralized control these four concepts, time is needed to consider how to design micro-monitoring services.
Micro-service monitoring of the five principles

传统架构下,应用的所有功能都实现在同一进程下,应用的扩展就是在多个服务器上复制整体的进程。而在微服务架构下,应用功能被拆分成了粒度更小、相互独立的服务,而这些服务都能够被独立地管理和部署。这样,应用的扩展和修改都可以按需只针对部分服务进行,而不会影响其他正在运行的服务。
Micro-service monitoring of the five principles
微服务并不是SOA(Service-Oriented Architecture,面向服务架构), 微服务相比SOA里的服务而言具有更小的关注点。这种全新的架构理念也带动了基础架构等多个领域的创新,其中就包括了针对应用的监测。

三、容器是什么

当前很多微服务都是运行在容器的基础之上的,那么设计针对微服务的监测同样要考虑容器的特性。
Micro-service monitoring of the five principles

首先需要强调的是,容器(Container)并不是轻量级的虚机,它不像虚机一样拥有独立的虚拟化的操作系统,而是直接构建和运行在主机的操作系统之上。
Micro-service monitoring of the five principles

容器除了镜像(image),也就是我们分层构建出来的目标应用之外,还包括了主机操作系统提供的进程沙盒(sandbox)。进程沙盒保证了容器之间的隔离,使得每个容器都像是运行在一台独立的虚机之上。
进程沙盒包括以下几个部分:
Micro-service monitoring of the five principles

• 控制组(Cgroups):规定了可以使用的资源的数量,如CPU、内存、网络等;
Micro-service monitoring of the five principles

• 命名空间(namespaces):规定了可以使用哪些控制组提供的资源;
Micro-service monitoring of the five principles

• 安全模块(Seurity Modules)实现了容器之间的隔离。
在实际应用的过程中,容器的开发者和使用者都关注在镜像上,感觉不到进程沙盒的存在。进程沙盒的这些部分是由容器的运行态程序自动和镜像加载在一起的。
Micro-service monitoring of the five principles

四、微服务与容器

从以上针对微服务和容器概念的回顾和分析来看,二者的特性是非常匹配的。利用容器的各种特点能够便捷地实现微服务架构的各种设计需要。
Micro-service monitoring of the five principles

Micro-service monitoring of the five principles

因此,虽然微服务架构刚刚出现时也是运行在虚机之上的,但目前大多数的微服务都是基于容器来实现的。那么设计针对微服务的监测也同样要考虑到容器的特性。
Micro-service monitoring of the five principles
在我们的设计和印象当中,微服务应该是按照上图这样清晰的架构运转的。然而实际情况并非如此。随着微服务和容器规模的扩大,我们真正面对的是如下图一样的场景。显然,在这样的场景下,要全面、准确、有效地实现对微服务的监测,是一个巨大的挑战。
Micro-service monitoring of the five principles

五、监测微服务的五大关键原则

微服务和容器的出现和大量应用,带动了架构、开发、部署、运维等多个领域的创新,也对应用的监测提出了新的要求。在传统架构中,监测关注的是虚机或主机上运行的单体应用。而在微服务+容器的架构下,应用已经分解为更细粒度、相互隔离、独立运行的进程。那么针对微服务的监测也就需要转向针对这些进程的关注。
Micro-service monitoring of the five principles

Sysdig在此次大会上介绍了监测微服务应用需要遵循的五大关键原则:
Micro-service monitoring of the five principles

1、监测容器,同时也要监测容器内运行的应用

Micro-service monitoring of the five principles

针对于容器内运行的进程,监测要格外关注针对其使用资源的限制,以防止单个容器占用和消耗主机的所有资源,从而影响到主机上其他容器的运行。同样,针对编排器同样要监测和限制对主机资源的占用,尤其是在应用规模自动调整的时候,要保证合理地使用主机资源。
Micro-service monitoring of the five principles

同时,我们不能把容器当成黑盒,必须监测到容器内运行的各种应用,如各种服务进程、数据库等。监测要收集这些应用运行的各种度量指标,如JVM的各种参数等。当然,监测也应该收集那些开发者自己定义的,针对容器内应用运行的各种度量指标。

2、监测业务自身的性能,而不是容器的性能

Micro-service monitoring of the five principles

在实际运行当中,每一个容器的生命周期通常都不会特别的长。容器的编排系统会随时关注容器的运行状态,当发生异常时,编排系统会自动的进行调整,如删除有问题的容器,重新部署一个同样的容器加以代替;或者根据容器运行的状态自动地进行规模上的调整等 。而开发者和运维者应该集中关注容器内业务应用的运行状态。

3、监测具有弹性,以及多地部署的服务

Micro-service monitoring of the five principles

微服务的部署特性驱使我们在设计的阶段就要考虑到规模性的问题。当服务的规模从10扩展成20,扩展成50,甚至于扩展成100的时候,针对服务的监测要如何自动调整去覆盖和适应这些自动扩展的规模。同样,针对多地部署的服务,我们又该如何根据不同的组织和分类,如站点、位置、区域等,来汇聚和统计服务的整体性能。这些都是在设计监测方案之初就要重点考虑的。

4、监测API

Micro-service monitoring of the five principles
在微服务的架构当中,原有的单体应用被拆解成为多个层面、更小粒度、独立运行的服务。而API是这些服务暴露给其他服务的唯一组件。同时,API也是访问微服务的首要通讯方式。
Micro-service monitoring of the five principles

对API的运行、响应状态的有效监测,对微服务的整体监测是十分重要的:
• 能够捕获特定方法、功能或端点的运行瓶颈;
• 能够监测各个方法、功能或端点的调用频率;
• 能够跟踪用户业务在多个系统之间的交互行为。

5、微服务的监测体系要匹配组织架构

提到架构,我们就不得不关注康威定律,即任意一个软件都反映出制造它的团队的组织结构,如下图所示:
Micro-service monitoring of the five principles

康威定律同样适用于微服务的监测体系。要允许团队根据自己的设计和理解来定义自身提供服务的监测指标、报警原则,以及监测数据的展示方式,毕竟他们是对这些服务最了解的人,也是最终为服务的质量负责、解决服务问题的人。
Micro-service monitoring of the five principles

五、总结

Emergence of micro-services architecture and extensive use of container combined with technology has changed the application development, deployment, operation and maintenance of the original model, but also for monitoring applications put forward higher requirements. Sysdig brought five key principles that can help us for the characteristics of the micro-services and container design more comprehensive, more targeted monitoring system.
Of course, with the continuous evolution of the micro-service architecture and container technology, systems and principles will continue to be monitored is adjusted. Recognizing this shift sooner, earlier and more easily will be able to accommodate new architecture and technology.
References
• Principles of Monitoring microservices
https://www.youtube.com/watch?v=tVdp5355xbA&index=50&list=PLY0Zjn5rFo4OuGDcUEgb48JcObItA4TLW

• The Five Principles of Monitoring Microservices
https://thenewstack.io/five-principles-monitoring-microservices

Guess you like

Origin blog.51cto.com/jfrogchina/2465034
Recommended