美文网首页
Stateless vs StateFul server

Stateless vs StateFul server

作者: canezk | 来源:发表于2016-11-11 11:25 被阅读176次
    • 区别

      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.

    • Example:file system

      Stateful: server maintains information about client operations such as open mode, file offset, etc
      Stateless: client should send self-containing request to server

    • Example:web server
    1. COOKIE
      其实一般的cookie已经属于是stateful了,但是很多web server借助类似于redis这些来实现全局session,所以可以简单认为这种web server是stateless的,因为request可以到任何一台机器;
    2. Transaction
      A stateless service is a service that does not store any data on the application
      server. It reads or writes data to the database, returns a value (or not), and after
      that, any information on the task itself is forgotten.
      A stateful service is used to perform transactions, that is a series of tasks that depend on the result of preceding tasks. The easiest example is sending an order at a web store, where you gather your products in a shopping cart, and when you check out, you enter your account data on one page, store it, then enter your billing address, store it, then confirm your order and conclude the transaction. Each step depends on the successful outcome of the preceding step, and data needs to be preserved until the last one of these steps is completed or the transaction is canceled, in which case there has to be a rollback to restore your account balance to the way it was before you checked out.

    相关文章

      网友评论

          本文标题:Stateless vs StateFul server

          本文链接:https://www.haomeiwen.com/subject/schfpttx.html