現在、4つのWebサーバーにDNSポーリングを使用しています。
私たちが遭遇した問題は次のとおりです。ユーザーが更新すると、他のWebサーバーに移動する可能性があります。ユーザーがすでにログインしている場合、これは非常に気分が悪くなります。セッションを使用してログインステータスを記憶しますが、他のWebサーバーに更新すると、セッションが失われます。
したがって、最善の解決策は、ユーザーが更新するときに同じWebサーバー上にいるようにすることです。抜け道はありますか?
Ok, I believe you mean "Round Robin DNS". Well, what you describe is a very common problem and there is no "right" solution for it, since the possible answers depend on many variables: are you trying to provide automatic failover or just load balancing? Are you willing to spend time and/or money in a load balancer? What technologies are you using? Java EE? PHP? Apache? IIS?
Having said that, if you're just after load balancing and failover is not much of an issue you may want to use different names for each server (www1,www2,www3 and so on) and redirect to them from your "main" web server (www) upon first access. It's simple (and simplistic) but practical in a few settings.
Webサーバーは共通のデータベースサーバーを使用してセッション情報を保存できますか?
特定のハードウェアベースのロードバランサーは、このタイプの問題を回避するために、ユーザーとサーバーの間に「スティッキー」な関係を作成することを知っています。
かなりの数のオプションがあります。
balance source
ます。注意: ノードの数が変わると、セッションが失われる可能性があります。cookie
または機能を使用して、url_param
これを回避できます。HAProxy のドキュメントを参照してください。読む価値があります、本当に。
4つのWebサーバーはすべて同じサイトとネットワーク上にありますか、それとも分散していますか?
If the former, you can include a server ID somewhere in the HTTP response, such that a reverse proxy in front of the real servers can identify which server is responsible for the session.
クライアントの場所に基づいて応答できる DNS サーバーは、この問題を解決できます。geoip モジュールを使用した PowerDNS または GeoIPdns がその例です。クライアントが常に同じ応答を受け取るように、IP アドレス セットが重複していないことを確認する必要があります。
これだけでは、いかなる種類のフェイルオーバーも提供されません。