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 1 year has passed since last update.

複数のサーバーを使用したアプリケーションの開発で詰まった件(スティッキーセッション)

0
Posted at

複数のサーバを使用したアプリケーションの開発で詰まった件

発生した事象

・図書登録機能を実装する際に、国立国会図書APIを利用してサムネイル画像を取得していた。その際に、取得したサムネイル画像が登録フォームに表示されたりされなかったりした。
(画像をサーバーに保存することはできていた上に、その保存先のファイルパスも正確に指定していた。)

原因

・サーバーを複数使用していた。
・どうやらデフォルトではロードバランサーは、選択したロードバランシングアルゴリズムというものに基づいて、登録されたターゲットに各リクエストを個別にルーティングするらしかった。

解決策

・そのためスティッキーセッション機能 (セッションアフィニティとも呼ばれる) を使用して、ロードバランサーがユーザーのセッションを特定のターゲットにバインドするように設定する必要があった。

→つまり、画像が保存されているサーバーに対して画像を呼び出せた際は、画像が表示されていたが、別のサーバーに対して呼び出している際は画像が表示されなかった。そのため、同セッション中は同じサーバーに対してアクセスするという設定をすることによって、毎度画像が表示されるようになった。

[参考サイト]
https://docs.aws.amazon.com/ja_jp/elasticloadbalancing/latest/application/sticky-sessions.html
https://qiita.com/takuma-jpn/items/873f6fb52ee5dc3500f6

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?