Skip to content

Commit

Permalink
[zh] sync stateful-apps.md in Chinese
Browse files Browse the repository at this point in the history
Signed-off-by: windsonsea <haifeng.yao@daocloud.io>
  • Loading branch information
windsonsea committed Nov 18, 2022
1 parent c47747a commit c045358
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions content/zh-cn/stateful-apps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: 有状态应用
status: Completed
category: 概念
tags: ["基本原理", "", ""]
---

## 是什么

当我们说到有状态(和[无状态](/zh-cn/stateless-apps/))应用时,
状态是指应用需要存储以便其按设计运行的任何数据。
例如,任何能记住您购物车的在线商店都是有状态应用。

## 解决的问题

使用一个应用通常需要多个请求。
例如,使用网上银行时,您将通过输入密码(请求 #1)来验证自己的身份,
然后您可以将钱转给某个朋友(请求 #2),最后您需要查看转账详情(请求 #3)。
为了保证正常运行,每一步都必须记住前面的步骤,银行需要记住每个人的账户状态。
今天我们使用的大多数应用至少总有一部分是有状态的,
因为这些应用会存储诸如偏好和设置之类的东西以改善用户体验。

## 如何帮助

有几种方法可以为有状态应用存储状态。
最简单的是将状态保存在内存中,而不是将其持久保存在任何其他地方。
这样做的问题是,每次应用必须重启时,所有状态都会丢失。
为了防止这种情况发生,状态被持久存储在本地(磁盘上)或数据库系统中。

0 comments on commit c045358

Please sign in to comment.