How do I deal with concurrent changes in a web application?

后端 未结 3 770
半阙折子戏
半阙折子戏 2021-01-05 07:40

Here are two potential workflows I would like to perform in a web application.

Variation 1

  • user sends request
  • server reads data
  • serve
3条回答
  •  不知归路
    2021-01-05 07:42

    Things are simple in the application layer - every request is served by a different thread (or process), so unless you have state in your processing classes (services), everything is safe.

    Things get more complicated when you reach the database - i.e. where the state is held. There you need transactions to ensure that everything is ok.

    Transactions have a set of properties - ACID, that "guarantee database transactions are processed reliably".

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题