x射线mas

For larger organizations microservice architectures have become de facto standard. Admittedly, such architectures usually come with a set of trade offs. One of these trade offs is a level of complexity that such systems introduce. A single http request may trigger a web of services working together to satisfy it. As you can imagine, this can result in a significant operational complexity.

对于大型组织而言,微服务架构已成为事实上的标准。 诚然,这样的体系结构通常需要权衡取舍。 这些折衷之一是这种系统引入的复杂度。 单个http请求可能会触发一个服务网络以共同满足该请求。 可以想象,这会导致很大的操作复杂性。

Observability tools like distributed tracing have become a critical component in observability. They allow us to trace a lifecycle of the request through the entire system. AWS X-Ray is one such tool. In this post, I will show you how you can set up X-Ray distributed tracing for your services that run in ECS. Here is what the result should look like:

诸如分布式跟踪之类的可观察性工具已成为可观察性的关键组成部分。 它们使我们能够跟踪整个系统中请求的生命周期。 AWS X-Ray就是这样一种工具。 在本文中,我将向您展示如何为在ECS中运行的服务设置X-Ray分布式跟踪。 结果如下所示:

ECS的X射线跟踪如何工作? (How does X-Ray tracing for ECS work?)

AWS documentation does a good job explaining how tracing with X-Ray works, but let’s summarize some of the concepts here. Our goal is to assemble a big picture of what request lifecycle looks like. In order to accomplish this goal, we just need every request through the system to carry some context that would group them as the part of the same lifecycle. This is done through a tracing header id. With that in place, each time the request comes in, we can parse the context from the header and add our own context to the header for downstream requests.

AWS文档在解释X-Ray跟踪的工作原理方面做得很好,但是让我们在这里总结一些概念。 我们的目标是汇总请求生命周期的概况。 为了实现此目标,我们只需要通过系统的每个请求都携带一些上下文,这些上下文会将它们分组为同一生命周期的一部分。 这是通过跟踪标头id来完成的。 有了适当的位置,每次请求进入时,我们都可以从标头中解析上下文,并将自己的上下文添加到下游请求的标头中。

Having tracing header id to support context passing is only one part of the puzzle. The other thing that is necessary is for us to collect all the traces within the same lifecycle and put them together. This part is known as reporting. Each component needs to report its own trace info to a single entity that would build the big picture for us. The reporting within AWS X-Ray is done using X-Ray API.

具有跟踪标头ID以支持上下文传递只是难题的一部分。 另一件事是我们需要收集同一生命周期内的所有痕迹并将它们放在一起。 这部分称为报告 。 每个组件都需要向一个实体报告其自己的跟踪信息,这将为我们构建全局。 AWS X-Ray中的报告是使用X-Ray API完成的

This implies that we must send traces to X-Ray API every time there is a request in the system, having a potential of adding an unnecessary overhead. The way that AWS solves this problem is by introducing a notion of an X-Ray Daemon. X-Ray Daemon is a process that runs along side your service. The job of X-Ray Daemon is to collect the traces and send them to the API in a performant manner. Instead of sending an http request to an X-Ray API in a service, the instrumentation will report tracing info to the daemon using a lighter protocol (UDP) and that daemon in turn handles reporting to X-Ray API in an optimal manner.

这意味着,每次系统中有请求时,我们都必须向X-Ray API发送跟踪,这可能会增加不必要的开销。 AWS解决此问题的方法是引入X-Ray Daemon的概念。 X-Ray守护程序是一个与您的服务一起运行的过程。 X-Ray守护程序的工作是收集跟踪并将其以高性能的方式发送到API。 该工具不会向服务中的X-Ray API发送http请求,而是使用更轻量的协议(UDP)将跟踪信息报告给守护程序,然后该守护程序又以最佳方式处理向X-Ray API的报告。

Interestingly, this is how AWS handles reporting internally for other AWS resources. For example, if we turn tracing on for a lambda function, then lambda function will report traces to an X-Ray Daemon that AWS runs internally for that service.

有趣的是,这是AWS内部处理其他AWS资源报告的方式。 例如,如果打开对lambda函数的跟踪,则lambda函数会将跟踪报告到AWS在内部为该服务运行的X-Ray守护程序

This is what all of this looks like in practice:

在实践中,这就是所有这些:

  1. Instrument our code to collect metrics. Instrumentation simply means that we parse incoming requests for external context and wrap outgoing requests with our own context. This is done using a AWS X-Ray SDK. The SDK would automatically emit data on UDP port 2000.

    检测我们的代码以收集指标。 检测只是意味着我们解析外部上下文的传入请求,并使用自己的上下文包装传出的请求。 这是使用AWS X-Ray SDK完成的 。 SDK会自动在UDP端口2000上发出数据。

  2. Set up X-Ray Daemon as a side car to our service. It will listen to UDP port 2000, collect the traces and pass them to AWS X-Ray API.

    X射线守护程序设置为我们服务的辅助工具。 它将监听UDP端口2000,收集跟踪并将其传递给AWS X-Ray API。

  3. Make sure that role executing the tasks has permission to write to AWS X-Ray API.

    确保执行任务的角色具有写入AWS X-Ray API的权限

让我们看一下代码 (Let’s see the code)

Just a reminder that this article primary concerns itself with how to do this in CDK + Typescript. How ECS works and how to set it up is out of scope. For a full example, however, refer to the repo here. But please remember that it is just an example and needs refinement to be used in production.

提醒一下,本文主要涉及如何在CDK + Typescript中执行此操作。 ECS的工作方式和设置方式超出了范围。 有关完整示例,请参阅此处的回购 。 但是请记住,这只是一个示例,需要改进才能用于生产中。

步骤1:检测我们的代码 (Step 1: Instrument our code)

The process of instrumentation depends on language of your service. In this article I will show you how to instrument a node service. Look through the docs to see if instrumentation is available for your language.

检测过程取决于您的服务语言。 在本文中,我将向您展示如何检测节点服务。 查看文档,以了解您的语言是否可用。

Node application is really easy to instrument. We just need aws-xray-sdk to do the heavy lifting. More info on it here. The code below is a very simplistic example of how a node express service can be set up.

节点应用程序确实很容易检测。 我们只需要aws-xray-sdk即可完成繁重的工作。 更多信息在这里 。 下面的代码是如何设置节点快递服务的非常简单的示例。

import * as express from 'express';
import * as AWSXRay from 'aws-xray-sdk';
import * as AWS from 'aws-sdk';const AWSSdk = AWSXRay.captureAWS(AWS);
AWSXRay.captureHTTPsGlobal(require('http'), true);
AWSXRay.captureHTTPsGlobal(require('https'), true);import axios from 'axios';const PORT = process.env.PORT || 80;
const HOST = process.env.HOST || 'localhost';const app = express();
const sns = new AWSSdk.SNS();app.get('/', (req, res) => {console.log('Healthy!');res.status(200);res.send({ status: 'Ok' });
});app.use(AWSXRay.express.openSegment('MyApp'));app.get('/pokemon', async (req, res) => {console.log('Received request...processing');try {const response = await axios.get('https://pokeapi.co/api/v2/pokemon/');console.log('Finished processing. Response: ', response.data);await sns.publish({Message: JSON.stringify(response.data),TopicArn: 'arn:aws:sns:us-east-2:<ACCOUNT>:x-ray-example-topic',}).promise();res.send(response.data);} catch (err) {res.send(err.message);}
});app.use(AWSXRay.express.closeSegment());app.listen(PORT);
console.log(`Running on http://${HOST}:${PORT}`);

From the above, line 5, sets up X-Ray SDK to trace every call to an AWS SDK. We therefore see that on line 15, we create an SNS client using our wrapper. Line 6 and 7, wrap http and https globally to handle tracing of any outgoing requests for axios.

从上面的line 5 ,设置X-Ray SDK来跟踪对AWS SDK的每次调用。 因此,我们在line 15看到,我们使用包装器创建了一个SNS客户端。 Line 67 ,全局包装http和https以处理对axios的所有传出请求的跟踪。

步骤2:设置X射线守护程序 (Step 2: Set up an X-Ray Daemon)

Setting up a side car with X-Ray Daemon is super simple. Assuming we run in ECS and have our node app define a task. then all we need to do is to add a container that would run X-Ray Daemon to the same task. Here is an example:

使用X射线守护程序设置边车非常简单。 假设我们在ECS中运行,并让我们的节点应用定义了任务。 那么我们要做的就是添加一个容器,该容器将在同一任务中运行X-Ray Daemon 。 这是一个例子:

const xray = taskDefinition.addContainer('xray', {image: ecs.ContainerImage.fromRegistry('amazon/aws-xray-daemon'),cpu: 32,memoryReservationMiB: 256,essential: false,
});
xray.addPortMappings({containerPort: 2000,protocol: ecs.Protocol.UDP,
});

第3步:添加权限以向X-Ray API报告跟踪 (Step 3: Add Permission to report traces to X-Ray API)

Last, but not least, the task role must have permission to do the reporting to X-Ray API. It is as simple as doing this in cdk:

最后但并非最不重要的是,任务角色必须具有向X-Ray API报告的权限。 就像在cdk中一样简单:

const taskRole = new iam.Role(this, 'TaskRole', {assumedBy: new iam.ServicePrincipal('ecs-tasks.amazonaws.com'),
});
taskRole.addManagedPolicy({managedPolicyArn: 'arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy',
});
taskRole.addManagedPolicy({managedPolicyArn: 'arn:aws:iam::aws:policy/AWSXRayDaemonWriteAccess',
});

结论:好,坏和丑 (Conclusion: The Good, the Bad and the Ugly)

That’s it! X-Ray is easy to set up and adds a ton of utility by enabling distributed tracing. However, it is not without its own downsides. For example, right now instrumenting an architecture for SNS → SQS → Lambda might not produce the desired results. The service is evolving and with time we expect the these gaps to be filled. In the meantime keep an eye on AWS announcements to stay updated!

而已! X-Ray易于设置,并且通过启用分布式跟踪可以增加大量实用程序。 但是,它并非没有缺点。 例如,现在为SNS→SQS→Lambda检测架构可能无法产生预期的结果 。 服务在不断发展,随着时间的流逝,我们期望这些空白将得到弥补。 同时,请注意AWS公告以保持更新!

翻译自: https://medium.com/swlh/x-ray-vision-fbeee441748

x射线mas


http://www.taodudu.cc/news/show-4348957.html

相关文章:

  • pm961 mysql_搭建Memcache服务详解
  • 3Dmax 常用-概念理解
  • 推荐系相关概念
  • 服务器如何多个网站和数据库,网站和数据库分两个服务器
  • Kubernetes基本概念和术语
  • tensorflow 一些概念
  • mPaaS 服务端核心组件:移动分析服务 MAS 架构解析
  • linux oracle开启监听服务器,linux服务器启动oracle监听端口
  • MAS概念
  • INSERT INTO和INSERT IGNORE INTO 以及REPLACE INTO的区别
  • AE圣诞树(html版本),免费
  • AE二次开发-获取图层的属性表
  • 基于AE的二次开发的主界面设计
  • 易基因 | 常用的6种DNA甲基化测序方法,你知道几个?
  • GO语言基础----简易计算器
  • 法坤老师:百度网盘密道转存12.0群文件自动转存发布咯
  • 还在用邀请码邀请注册吗?落后咯!!!我家APP自带邀请码的
  • Python采集手机4K壁纸,又是一个练手小案例,也不用担心没壁纸换咯
  • OpenCV-Python图像形态变换概述及morphologyEx函数介绍
  • 计算机网络技术期末考试2010模拟试题及答案
  • 计算机网络笔试面试题目大全
  • DL知识总结
  • 基于原始影像数据的深度学习模型预测脑龄可获得可靠的遗传生物标志物
  • 大学计算机基础模拟系统2014ppt第三,第一章_河海大学:大学计算机信息技术_ppt_大学课件预览_高等教育资讯网...
  • 计算机网络技术期末考试模拟试题及答案
  • 传奇黑客成『吹哨人』,推特麻烦了;谷歌20+技术学习路线;Python数据科学电子书;游戏智能体开发平台;前沿论文 | ShowMeAI资讯日报
  • 「合作共赢」泛微eteams云OA联手容联七陌 深耕SaaS协同软件市场
  • 5 款可替代 du 命令的工具
  • springboot集成ES实现磁盘文件全文检索
  • 在 Go 中导入包

x射线mas_X射线视觉相关推荐

  1. [转帖]什么是α射线、β射线、γ射线

    什么是α射线.β射线.γ射线 https://www.sohu.com/a/230945619_100124721 1.α射线 放射性核素发生衰变时放出α粒子,产生α射线.α粒子是一个高速运动的氦原子 ...

  2. β射线与哪些物质可产生较高的韧致辐射_什么是α射线、β射线、γ射线

    原标题:什么是α射线.β射线.γ射线 1.α射线 放射性核素发生衰变时放出α粒子,产生α射线.α粒子是一个高速运动的氦原子核.对于天然放射系列的核素放出α粒子的能量一般在4-8兆电子伏(MeV)范围, ...

  3. x射线和γ射线区别?α射线、β射线

    X射线与γ射线虽然都属电磁波,但它们是有区别的: (1)产生的机理不zhi同:X射线是原子的内层dao电子受激辐射的:γ射1653线是原子核受激辐射的: (2)光子能量不同:γ射线比X射线光子能量高, ...

  4. JAVA射线_射线法 - 萌德真帅 - 博客园

    射线法 这是一个大佬看了都说简单的算法....(甚至觉得没有掌握的必要) QAQ 这个算法是用来判断一个点是否在一个多边形以内.很简单 将这个点沿着x轴的正方向作射线.如果穿过的边数为基数,那么这个点 ...

  5. β射线与哪些物质可产生较高的韧致辐射_辐射无所不在,香蕉土豆里都有?我们还能愉快生活吗?...

    作为一枚受过系统科学教育,耳聪目明的当代年轻人,你是不是隔三差五被长辈亲友群里各种"XX有放射性,赶紧远离!"的科学谣言搞得哭笑不得?又或者,稍一不注意,长辈亲友就买回了各种号称黑 ...

  6. 【图像处理】射线爆发算法(Rayburst algorithm)

    [fishing-pan:https://blog.csdn.net/u013921430 转载请注明出处] 射线爆发方法简介   射线爆发算法(Rayburst algorithm)是一种经常被用于 ...

  7. Unity3D基础33:物理射线

    前文:https://blog.csdn.net/Jaihk662/article/details/86749803(摄像机与Game视图) 一.利用摄像机创建射线 物理射线:从一个点往一个方向发射一 ...

  8. Unity学习之Physic.Raycast(射线检测)个人理解分享

    Physics.Raycast参数 public static bool Raycast(Vector3 origin, Vector3 direction, out RaycastHit hitIn ...

  9. Unity - Ray射线检测

    一:射线 Ray射线 定义:射线是一条从原点出发,沿某一方向运动的无限直线. //创建一条初始位置为startPos,方向为dir的一条射线 Ray ray = new Ray (startPos, ...

最新文章

  1. Oracle ASM 详解 收藏
  2. Android数据存储
  3. 使用VGG训练Imagenet
  4. 进军中国软件,踏上寻找自我价值之路的菜鸟
  5. java校验邮箱_Java正则表达式校验邮箱和手机号 | 学步园
  6. Android之使用SoundPool播放一小段音频,实现猜歌的功能
  7. php 获取config,PHP MVC如何自动调用config?
  8. jQuery UI dialog插件出错信息:$(this).dialog is not a function
  9. C++基础::Stream(二)
  10. python界面打开为什么是黑的_Pycharm设置界面全黑的方法
  11. 南方CASS11.0.0.8下载安装教程附视频(日更)
  12. 微博认证怎么弄黄v:微博兴趣认证指定领域
  13. win10桌面美化,带音乐播放特效
  14. 计算机主板cpu的电源接口类型,给力:主板CPU电源的4pin和8pin有什么区别?
  15. 为什么当函数值为定值时,梯度垂直于等值面?
  16. 4399Q版泡泡堂(DEVC++实现+解析)
  17. 组装计算机主机算固定资产吗,​购买电脑配件组装电脑属于固定资产吗
  18. 【图文详解】Android手机系统精简 搭建Linux集群硬件环境 Jdk运行HelloWorld
  19. 【水果识别】形态学水果识别(含识别率)【含GUI Matlab源码 907期】
  20. 判断当前是否是移动端H5打开

热门文章

  1. Nginx反向代理服务器及负载均衡服务配置实战
  2. 小米的抢购骗局+小米的抢购页面的源代码分析(二)文本数组的分析
  3. 大二学期总结(我的机器人开发之路)
  4. 屏幕分辨率:聊一聊像素
  5. 商城运费模板数据库简单设计思路
  6. ins07001 oracle,社区
  7. 犀牛中斑马纹分析的作用
  8. 简单高效记账本的具体操作方法
  9. 2022年最新宁夏建筑安全员模拟题库及答案
  10. 基于纹理的复杂环境下道路消失点检测算法