当前位置:网站首页>A practical method of temporal architecture

A practical method of temporal architecture

2020-11-16 15:20:37 InfoQ

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":" This article was originally published in Mikhail Shilkov Personal blog , Authorized by the original author InfoQ Translate and share ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/temporal.io\/","title":null,"type":null},"content":[{"type":"text","text":"Temporal"}]},{"type":"text","text":" Allow developers to build highly reliable applications , You don't have to worry about all the border conditions . If you're new to it Temporal, Then read my article 《"},{"type":"link","attrs":{"href":"https:\/\/mikhail.io\/2020\/10\/temporal-open-source-workflows-as-code\/","title":null,"type":null},"content":[{"type":"text","text":" Open source workflow is code "}]},{"type":"text","text":"》. Next , I'll show you how to install and run Temporal."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Temporal Contains multiple components . In this paper , I'd like to give an overview of its main building blocks and their interactions . Final , You will be right Temporal And deployment to the development environment 、 There is an overall understanding of the transition and production environment considerations ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"Workers"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Workers Is to run Temporal The computing node of the application code . You compile workflows and activities into executable workers. Next , You can run it in the background worker The executable of , It will listen for new tasks that need to be processed ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Your first development environment may only need one wokrer, Running workflow and activities simultaneously in a single process .worker Can be hosted anywhere you want : Can be used as a local process on a laptop , It can also be used as AWS Fargate Mission , It can be Kubernetes Medium pod, wait ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.infoq.cn\/resource\/image\/a1\/b0\/a1a51d1072aa3526ccdabc17a1b1fbb0.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null},"content":[{"type":"text","text":"Temporal worker Execute workflows and activities "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Production deployment usually runs a large number of heavily loaded workflows , therefore , You may need to run multiple workers in parallel . Make sure the nodes are distributed on a computing cluster , To achieve flexibility and scalability ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.infoq.cn\/resource\/image\/02\/24\/02bb11e1125d4a104920a1e4f2af2024.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null},"content":[{"type":"text","text":" The workload extends to multiple Temporal workers"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Workers Independent operation , Each is responsible for handling its own load . Logically speaking ,Workers yes “ Stateless ”: They don't care about the past and the future .Workers There is no direct communication between , But they go through a Temporal Central service —— The brain of the system —— Coordination ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"Temporal service "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Temporal Service is Temporal One of the components provided . Its purpose is to track the workflow 、 Activities and tasks , And coordinate the implementation of the workers ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Your early environment might have only one instance of a service running in the background .worker Know the domain name of the service (IP) And port , And pass gRPC Connect to service ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.infoq.cn\/resource\/image\/03\/0f\/03a78f31035853d7a84762285ed1360f.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null},"content":[{"type":"text","text":"Worker And Temporal Service interaction "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Temporal The service itself consists of multiple components : front end 、 matching 、 History, etc . But now, , We can think of it as a black box “ service ”."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Once the workload starts to increase , You need to extend the service component to multiple instances , To achieve high flexibility and high throughput . therefore , Now there are more than one workers Talking to multiple service instances ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.infoq.cn\/resource\/image\/57\/ea\/578cc2240dfb172070a4854cb2c55eea.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null},"content":[{"type":"text","text":" Running multiple components Temporal colony "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Temporal Services can tolerate node failures , Because it stores its state in external memory ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":" data storage "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" All workflow data —— Task queue 、 Execution status 、 Activity log —— Are stored in a persistent data store . Persistence technology is pluggable , There are currently two official options :Cassandra and MySQL. More options , Include PostgreSQL, Under development ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"MySQL The database complements the simplest Temporal Deployment diagram ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.infoq.cn\/resource\/image\/94\/31\/94148e22ddf33d29df027c95d7173e31.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null},"content":[{"type":"text","text":"MySQL As Temporal Data storage "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" For highly distributed applications that will encounter high load , Use Cassandra Maybe better . This database can be your own cluster , It can also be a hosted cloud service ( such as Azure Cosmos DB):"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.infoq.cn\/resource\/image\/50\/5f\/5081e05af8eeb024c014185ae7c0e85f.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null},"content":[{"type":"text","text":"Cassandra As Temporal Data storage "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Your code will never interact directly with the data store . Basically , It is Temporal One of the services ( It's quite important ) Implementation details ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"Temporal Web Console "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Temporal It provides a convenient Web Console to view the namespace 、 Workflow and activity history . Technically speaking , It's not a required component —— But you may want to use it to manually check and fix problems ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" You may have other client components , for instance , To start workflow execution ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":" External client "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" You need a client to start your first workflow execution . It can be Temporal Command line interface "},{"type":"codeinline","content":[{"type":"text","text":"tctl"}]},{"type":"text","text":", Can also be used in SDK Or primitive gRPC Write any custom code through the call to initiate a workflow ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" Each client must be connected to a Temporal service , To start or terminate a workflow 、 Waiting for completion 、 List the results in the history , wait . for example ,Web The application can process specific HTTP Start workflow execution at endpoint ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":" be made one "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" The figure below combines all the parts mentioned above ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.infoq.cn\/resource\/image\/60\/84\/602dda81a36d657e27d3b766c37c7a84.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null},"content":[{"type":"text","text":"Temporal High level architecture "}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" As you can see , To make Temporal It takes quite a lot of components to work .Temporal Designed to handle millions of workflows reliably , And provide high performance guarantee , meanwhile , It's still open source , You can migrate between different infrastructure options . This requires a multi-layer approach ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":" You can "},{"type":"link","attrs":{"href":"https:\/\/docs.temporal.io\/docs\/go-run-your-first-app\/","title":null,"type":null},"content":[{"type":"text","text":" Getting started "}]},{"type":"text","text":" Deploy everything to the development machine . then , You can move components to your favorite cloud environment ."}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":" Link to the original text :"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https:\/\/mikhail.io\/2020\/10\/practical-approach-to-temporal-architecture\/","title":null,"type":null},"content":[{"type":"text","text":"https:\/\/mikhail.io\/2020\/10\/practical-approach-to-temporal-architecture\/"}]}]}]}

版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢

随机推荐