无状态系统和有状态系统之间的区别是什么?它们如何影响并行性? [英] What are the differences between stateless and stateful systems, and how do they impact parallelism?

查看:249
本文介绍了无状态系统和有状态系统之间的区别是什么?它们如何影响并行性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解释无状态系统与有状态系统之间的差异,以及状态对并行性的影响.

Explain the differences between stateless and stateful systems, and impacts of state on parallelism.

推荐答案

一个无状态系统可以看作是一个盒子[黑色? ;)]在任何时间点,输出的值仅取决于输入的值[在一定的处理时间之后]

A stateless system can be seen as a box [black? ;)] where at any point in time the value of the output(s) depends only on the value of the input(s) [after a certain processing time]

有状态系统可以看作是一个方框,在任何时候输出的值都取决于输入和内部状态的值,因此,从根本上说,有状态系统就像带有"内存"的状态机,因为同一组输入值可以根据系统先前接收到的输入来生成不同的输出.

A stateful system instead can be seen as a box where at any point in time the value of the output(s) depends on the value of the input(s) and of an internal state, so basicaly a stateful system is like a state machine with "memory" as the same set of input(s) value can generate different output(s) depending on the previous input(s) received by the system.

并行编程的角度来看,如果正确实施了无状态系统,则该系统可以同时由多个线程/任务执行,而不会出现任何并发问题[例如考虑一个可重入函数] 有状态系统将要求执行访问的多个线程并以排他的方式更新系统的内部状态,因此将需要一个序列化[synchronization]点.

From the parallel programming point of view, a stateless system, if properly implemented, can be executed by multiple threads/tasks at the same time without any concurrency issue [as an example think of a reentrant function] A stateful system will requires that multiple threads of execution access and update the internal state of the system in an exclusive way, hence there will be a need for a serialization [synchronization] point.

这篇关于无状态系统和有状态系统之间的区别是什么?它们如何影响并行性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆