是否无状态仅传输客户端的状态到别的地方? [英] Does stateless only transfers client's state to somewhere else?

查看:149
本文介绍了是否无状态仅传输客户端的状态到别的地方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了一整天的时间了解无状态的架构是什么。我看了很多帖子和答案像

I have spent a whole day understanding what stateless architecture is. I read many posts and answers like

<一个href=\"http://stackoverflow.com/questions/3302620/can-my-web-app-implement-user-login-and-remain-stateless?rq=1\">Can我的Web应用程序实现用户登录并保持无状态?

<一个href=\"http://stackoverflow.com/questions/1553645/pros-and-cons-of-sticky-session-session-affinity-load-blancing-strategy\">Pros和粘性会话/会话关联的负载缺点blancing战略?

http://www.quora.com/What-是无状态 - 和有状态的Web架构


  • 似乎无状态的只是将一些用户状态
    别的地方(数据库/内存缓存或客户端的cookie)。就是这个吧?如果是的话,国家只存储在别处,因此必须有一些不无状态的(客户端或服务器),但负载平衡器现在并不需要担心哪台机器路由。

  • It seems that stateless is only transferring some user state to somewhere else(database/memcache or client cookies).Is this right? If yes, the state is only stored somewhere else, so there must be something that is not stateless(client or server), though the load balancer now does not need to worry about which machine to route .

如果上面是正确的,如果我们选择的用户信息传输到中心位置(transfser客户似乎并不总是根据一些答案的解决方案),如数据库或memcache的,我们还需要找到这个会话信息每一个请求。这意味着,在这里保存用户状态将对同时处理几千万的请求的相同pressure的地方。而且很可能,我们一路找到会话信息就像是粘性会话(路由信息请求插入的内存缓存单个节点)。那么,为什么我们考虑转移状态是更具可扩展性?在pressure只转移(而通常,数据库已经有太多的负载)

If above is right, if we choose transfer the user information to central place(transfser to client seems not always be the solution according to some answers) like database or memcache , we still need to find this session info for every requests. That means the place where holds the user state will have the same pressure on handling tens of millions requests at the same time. And probably, the way we find the the session information is just like sticky session(route the information request into a single node in the memcache). So why do we consider transferring the state is more scalable? The pressure is only transferred(And always, database has already had too much load)

我是否错过了什么或理解错误?

Do I miss something or understand wrongly?

感谢您!

推荐答案

您是在移动的状态下,以不同的层正确意味着你的应用程序是有状态(很少有真正的无状态的应用,大多只有那些做纯数学)

You are correct in that moving your state to a different layer means your application is stateful (there are very few truly stateless applications, mostly only ones doing pure math).

这并不意味着单个图层不能是无状态的,而那些层将规模不同于状态层。这个想法是,通过使应用程序无状态的特定部分,你将能够扩展其 ,而不是垂直,因此能够通过简单地购买更多的硬件,以更多的要求作出回应。

That doesn't mean individual layers can't be stateless, and those layers that are will scale differently than the stateful layers. The idea is that by making a particular part of the application stateless, you will be able to scale it horizontally, instead of vertically, thus able to respond to many more requests by simply buying more hardware.

您仍然需要扩展,无论你推的状态。所以,如果你正在推动它到一个数据库,你需要能够相应地扩大该数据库。这种运作良好,如果你能推到了可以便宜缩放(如memcached的)层。

You will still need to scale wherever you push that state to. So if you are are pushing it out to a database, you will need to be able to scale that database accordingly. This works well if you can push it out to a layer that can be scaled cheaply (like memcached).

它往往是使您的业务和网络层无状态的,因为它们一般都贵得多比你的数据存储层规模的目标,但是这并非总是如此。如果你已经把你的数据存储层上的负荷很大,而且很少负载对应用程序或Web层(如数据驱动VS交互驱动的应用程序,那么你会超载数据层。

It is often the goal to make your business and web layers stateless because they are generally much more expensive to scale than your data-store layers, but this isn't always true. If you have put a lot of load on your data store layer, and very little load on your application or web layers (like a data-driven vs an interaction-driven app, then you will overload your data layer.

所以,喜欢一切,是否让您的应用程序无状态归结为看情况。一般情况下,状态的业务和网络层往往超载很久以前的数据层做。特别是如果你正在做的显著OOP。

So, like everything else, whether to make your application stateless comes down to "it depends". Generally, stateful business and web layers tend to get overloaded long before data layers do. Especially if you are doing significant OOP.

这篇关于是否无状态仅传输客户端的状态到别的地方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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