维护应用程序服务器或数据库中的状态? [英] Maintaining state in the application server or in the database?

查看:239
本文介绍了维护应用程序服务器或数据库中的状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

REST在服务器上提倡没有客户端状态的Web应用程序。着名的购物车示例被转换为一个通常驻留在数据库中的资源。

REST advocates web applications without client state on the server. The famous shopping cart example is translated to a resource which typically resides in a database.

我想知道,使用数据库是否是一种很好的做法,因为数据库已经是许多应用程序的瓶颈。使用有状态的企业Java bean不是更好吗?

I wonder if it is a good practise to use a database for that kind of data, since the database is already the bottleneck in many applications. Wouldn't it be better to use a stateful enterprise java bean instead? Application servers are designed with clustring in mind.

这两种方法有哪些优点和缺点?

What are the advantages and disadvantages of the two approaches?

推荐答案

在应用服务器上存储会话仅在以下情况下有效:

Storing sessions on the application server will only work if:


  • 您的客户端始终连接到应用程序服务器(也称为会话亲和性)

  • 您的应用程序集群节点都使用通用安装点(nfs等)来执行会话

如果您的客户端不能保证始终连接到集群中的相同应用程序节点,则在中央数据库和/或EJB中存储会话将起作用。

Storing sessions in a central database and/or EJB will work if your clients are not guaranteed to always connect to the same application node in your cluster.

另一种考虑的方法是使用 memcached 等服务。这将适用于任何一种情况。

Another approach to consider is using a service such as memcached. This will work in either case.

这篇关于维护应用程序服务器或数据库中的状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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