简体   繁体   English

AWS 负载均衡器

[英]AWS Load Balancer

I have created WebApi in Mvc .net , where i am using Microsoft.OWIN for authentication and access token generation and hosting my APIs in AWS.我在 Mvc .net 中创建了 WebApi,我在其中使用Microsoft.OWIN进行身份验证和访问令牌生成并在 AWS 中托管我的 API。

Now , as am using load balancer to distribute the traffic , so AWS automatically generates multiple instance of the EC2 instance that means multiple servers , so when and where the Login Api is called , the request goes to one main server and generated the Token and in Claims Identity , we are storing UserID of that Logged IN User , but when another APIs are called simultaneously to multiple instances randomly, then that UserID which is stored while login in Claims Identity is not accessible from other randomly generated servers.现在,由于我使用负载均衡器来分配流量,因此 AWS 会自动生成 EC2 实例的多个实例,这意味着多台服务器,因此在调用 Login Api 的时间和地点,请求会转到一台主服务器并生成令牌并在Claims Identity ,我们正在存储该登录用户的UserID ,但是当另一个 API 同时随机调用到多个实例时,则登录时存储在Claims Identity中的UserID无法从其他随机生成的服务器访问。

So, I dont know whether it Owin issue or AWS load Balancer issue , is there functionality in AWS or OWIN , so that UserID will be accessible from multiple server?所以,我不知道是 Owin 问题还是 AWS 负载均衡器问题,AWS 或 OWIN 中是否有功能,以便可以从多个服务器访问 UserID?

and I can't remove OWIN from my API.我无法从我的 API 中删除 OWIN。

You need to have a central session store, something like Redis or a central DB.您需要有一个中央会话存储,例如 Redis 或中央数据库。 I have seen both used by different applications and I am sure there are other methods available to act as a central point for all sessions.我已经看到这两种方法都被不同的应用程序使用,并且我确信还有其他方法可用作所有会话的中心点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM