为什么使用有状态的 Web 服务是糟糕的编程,为什么会被允许? [英] Why is it bad programming to use a stateful webservice and why would it be allowed?

查看:24
本文介绍了为什么使用有状态的 Web 服务是糟糕的编程,为什么会被允许?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我们的组织中使用有状态的网络服务.然而,我在网上读到的任何地方都说构建有状态的 Web 服务是糟糕的编程,但没有说明原因.我想我不明白它有什么不好.我也不太明白为什么他们会提供一种解决方法来允许您在网络服务中拥有状态.

I have a need for a stateful webservice in our organization. However, everywhere I read online says that building a stateful webservice is bad programming but nothing ever says why. I guess I don't understand what is so bad about it. I also don't really understand why they would give a work around to allow you to have state in a webservice.

所以我想我的问题是,为什么使用有状态的网络服务是糟糕的编程,为什么会被允许?

So I guess that my question is, why is it bad programming to use a stateful webservice and why would it be allowed?

推荐答案

Web 服务的全部目的是以高度可扩展的方式在一个事务中交付一项功能.这意味着要保持简单和原子性.

The whole purpose of a web service is to deliver a piece of functionality in one transaction in a way that is highly scalable. This means keeping things simple and atomic.

当您必须多次调用来执行操作时,您很有可能会挂起事务.客户回来了吗?他们完成了吗?交易应该保持多长时间?他们坠毁了吗?应该如何处理回滚?

When you have to make multiple calls to perform the operation, you have a great potential of leaving transactions hanging. Is the client coming back? Are they done? How long should the transaction remain open? Did they crash? How should rollbacks be handled?

这些问题的答案可能会对运行服务所需的资源产生根本性的影响.这就是为什么每个人都建议一次性完成所有工作的原因.

The answers to these questions could have a radical impact on the resources necessary to run your service. Which is why everyone recommends doing it all in one swoop.

这篇关于为什么使用有状态的 Web 服务是糟糕的编程,为什么会被允许?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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