Skip to Content
Dapr学习手册
book

Dapr学习手册

by Haishi Bai, Yaron Schneider
November 2021
Beginner to intermediate
239 pages
4h 15m
Chinese
China Electric Power Press Ltd.
Content preview from Dapr学习手册
状态
87
在复杂的交易中,支持案例编号可以作为持久的记录。当事务由多个客服处
理时,事务状态会被案例编号延续。这就是有状态服务的行为,这也是本章
的重点。
2.1.1
无状态与有状态
Web
服务可以分为两大类:无状态和有状态。无状态服务在请求之间不维护
上下文信息。例如,通过搜索引擎进行搜索是独立的请求,搜索引擎需要的
只是搜索模式,不需要任何额外的上下文信息来进行搜索。如果在发出搜索
后被断开连接,当重新连接时,需要重新提交搜索查询条件,因为搜索引擎
不会记住之前的搜索条件。
有状态服务在交易过程中维护上下文信息,可能跨越多个请求。例如,在向
在线购物车中加入物品时,
Web
服务器会记录购物车中的物品,这样你就可
以继续购物,并在稍后结算所有物品。
区别有状态服务和无状态服务的另一个方法是看状态保存的位置。保持状态
的服务不一定是有状态服务。例如,考虑更新学生记录数据库的学生记录管
理系统。每个
CRUD
(创建、读取、更新、删除)操作都是独立的请求,如
果操作中途失败,则需要重新提交请求。但是,如果服务在计算节点本身维
护上下文信息,它就变成了有状态的。
在本章的剩余部分,我们将把在计算节点上保存状态的服务视为有状态服务。
我们使用这个定义是因为在计算节点上托管一个具有本地状态的服务与托管
一个无状态的服务是完全不同的。
2.1.2
为什么无状态服务在云端更受欢迎?
很多云平台都强烈偏爱无状态服务。这是因为无状态服务天然地符合云计算
的特点。
88
2
2.1.2.1
扩展无状态服务
搜索引擎由成千上万的后台服务器支持 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

流畅的Python(第2版)

流畅的Python(第2版)

Luciano Ramalho
数据科学原理

数据科学原理

Posts & Telecom Press, Sinan Ozdemir
Python预测分析实战

Python预测分析实战

Posts & Telecom Press, Alvaro Fuentes
机器学习开发者指南

机器学习开发者指南

Posts & Telecom Press, Rodolfo Bonnin

Publisher Resources

ISBN: 9787519859367