0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Cookieセッション管理におけるスティッキーセッションとそれ以外の方法

Posted at

用語確認

セッションとCookieについて

Cookie周りの仕様および図解

ロードバランサー(略称:LB)

サーバへの大量のリクエストを均等に分散すべく振り分ける機構。
image.png

AWSならばELB(ALB、CLB、NLB)。

スティッキーセッションとはなにか

この話題においては、サーバへの一連のアクセスには、クライアント、LB、サーバが存在する。

  • リクエストを行ったクライアント
  • LBから振り分けられたリクエストを受け付けたサーバ

この二者を常に紐付ける必要性があった。
その必要性とは、サーバ側にセッション情報を保持させていたためである。
つまり、サーバはメモリ上にセッション情報(=ユーザの状態など)を持っている構造になっている。

image.png

スティッキーセッションおよびCookieの構成

この構成では2つのCookieが存在する。

  • サーバのセッション情報の識別情報(一般的にはセッションキー)
  • LBにて付加する振り分け用の識別情報

セッションをサーバから分離する構成

キャッシュサーバでセッションを管理

image.png

キャッシュサーバ例

  • Redis
  • Memchached

この構成の特徴

責務が明確になる。リクエスト元を意識しなくなる。図上はあえて、色分けしてセッションを記載したが、この構成ではその区別はなくなる。

  • LBはリクエスト分散に集中
  • サーバは処理に集中
  • キャッシュサーバはセッション管理に集中
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?