amazon-web-services - 有没有办法保持 ELB 粘性 session ,即使它连接到的实例失败?

标签 amazon-web-services http session session-cookies amazon-elb

只是好奇这是否可能或您将如何实现。

无论我使用基于持续时间的粘性还是基于应用程序,当用户连接到的实例失败时,他们的 session 将被重置,因为他们必须连接到新服务器。

有没有办法避免这种情况发生?即使他们连接到的实例死亡,也能够让该 session 持续存在?如果这改变了一些东西,我也会使用带有证书的 SSL。

最佳答案

实现这一点的唯一方法是在某些存储服务中持久化您的 session 状态,可以是数据库表、s3、缓存服务、NoSQL 表等。

这些是一些方法

数据库中的 session 状态

Saving session state inside the database is common in lightweight web frameworks like Django. That way you can add as many front servers as you like without having to worry about session replication and other difficult stuff. You don’t tie yourself to a certain web server and you get persistence and all other features databases provide for free. As far as I can tell, this works rather nicely for small to medium size websites.

The problem is the usual: The database server may become your bottleneck. In that case your best bet may be to take a suitcase full of money to Oracle or IBM and buy yourself a database cluster. Reference: Saving Session Data in Web Applications

缓存服务中的 session 状态

Amazon ElastiCache offers fully managed Redis and Memcached. Seamlessly deploy, operate, and scale popular open source compatible in-memory data stores. Build data-intensive apps or improve the performance of your existing apps by retrieving data from high throughput and low latency in-memory data stores.

动态数据库

Amazon DynamoDB is a fast and flexible NoSQL database service for all applications that need consistent, single-digit millisecond latency at any scale. It is a fully managed cloud database and supports both document and key-value store models. Its flexible data model, reliable performance, and automatic scaling of throughput capacity.

无论您使用哪种方法,都必须与您的应用一起部署中间件来管理存储的 session 状态。

中间件:可以是第三方解决方案或您自己的解决方案。

资源

关于amazon-web-services - 有没有办法保持 ELB 粘性 session ,即使它连接到的实例失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48268251/

相关文章:

amazon-web-services - 使用 CloudFormation 创建 CodePipeline 通知规则

c# - 添加自定义 header

PHP 垃圾收集说明

php - Laravel 到基本 PHP 登录集成,工作!但无法设置 session

php - 在 PHP 中使用 Perl CGI session

amazon-web-services - 在 AWS 中重新分配私有(private) IP 地址?

amazon-web-services - 用于 S3 标准不经常访问文件的 AWS CLI 命令

linux - ssh 终端不自动完成或存储命令历史记录

validation - 在 go 中验证 http 请求的惯用方法

c - 使用 Apache API,为什么要逐行输入字符串?任何原因?