分布式环境中会话 ID 的唯一性? [英] Uniqueness of Session ID in a Distributed environment?

查看:58
本文介绍了分布式环境中会话 ID 的唯一性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将 Spring Session(由关键 Gemfire 备份)用于我们在分布式环境中运行的 Spring Boot 应用程序.

We are using Spring Session (backed up with pivotal Gemfire) for our Spring Boot applications running in an Distributed environment.

在这样的分布式环境中,

In such a distributed environment,

Spring Session 是否确保为新的会话使用唯一的会话 ID跨不同 JVM 创建的会话?

does Spring Session ensure that a unique session id is used for new sessions being created across different JVMs ?

推荐答案

只是回顾了 Spring Session Pivotal GemFire 支持的旧 SO 帖子,所以我很抱歉你的问题没有得到及时回复.

Just reviewing old SO posts for Spring Session Pivotal GemFire support, so my apologies your question never got answered in a timely manner.

简而言之,Spring Session 使用 UUID 类以生成唯一"会话 ID.例如,参见 此处,或更一般地说,这里.

In a nutshell, Spring Session uses the UUID class to generate "unique" Session IDs. For instance, see here, or more generally, here.

注意:Spring Session Data Redis 支持 使用/包装 MapSession 类来存储会话状态Redis,默认情况下.

NOTE: Spring Session Data Redis support uses/wraps the MapSession class to store Session state in Redis, by default.

似乎有很多 讨论UUID 在集群中的 JVM 中的有效性,或者说是唯一性.这个一个特别的,虽然过时,但引起了我的注意,因为它起源于 OracleJava 社区论坛.

There are appears to be a lot of discussion about the effectiveness, or rather uniqueness, of UUID across JVMs in a cluster. This one in particular, though dated, caught my attention as it originated from the Oracle Java community forums.

但是,请记住,最终确定会话 ID 是否唯一的是您的应用程序对 Spring Session 的使用;即它不依赖于 GemFire 集群中的节点数量,因为单个 GemFire 节点不生成会话 ID(使用 Spring Session 的应用程序是).

However, keep in mind that it is your application(s) use of Spring Session that ultimately determines whether Session IDs are unique; i.e. it is not dependent on the number of nodes in a GemFire cluster since individual GemFire nodes are not generating the Session ID (applications using Spring Session are).

因此,如果只有 1 个应用程序(在微服务状态下可能不太可能)使用 Spring Session,那么 UUID 有概率保证是唯一的.即便如此,基于 引用 可用,使用 Spring Session 的 2 个或更多应用程序"节点似乎极不可能生成冲突的 ID(尽管,(几乎?)一切皆有可能;-).

Therefore, if only 1 application (probably not likely in the Microservices state of the world) is ever present with Spring Session in use, then the UUIDs are probabilistically guaranteed to be unique. Even then, based on references available, it seems highly unlikely that 2 or more "application" nodes employing Spring Session will ever generate IDs that collide (though, (almost?) anything is possible ;-).

不过,我想如果它是最重要的问题,遵循 Spring 的美丽传统,扩展 将是一件简单的事情GemFireOperationsSessionRepository 并覆盖 createSession() 方法,调用适当的 GemFireSession 构造函数 将所需的会话 ID 传入.

Though, I suppose if it is of paramount concern/importance, following with the beautiful tradition of Spring, it would be a simple matter to extend the GemFireOperationsSessionRepository and override the createSession() method, calling the appropriate GemFireSession constructor to pass the desired Session ID in.

但是,在所有情况下(GemFire、Redis 等),会话 ID 的唯一性问题与底层的后备数据存储无关.

However, in all cases (GemFire, Redis, etc), the Session ID uniqueness problem is agnostic of underlying, backing data store.

希望这有帮助...

干杯!

这篇关于分布式环境中会话 ID 的唯一性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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