AWS - multiple app servers causing un-authorized exception

Hi there,

I have recently deployed a Yii1.1.x app to a PHP Layer using Amazon OpWorks.

I have spun up two separate PHP instances running Yii, both pointing to an RDS.

All incoming requests go through a load balancer, which directs the traffic either to my two instances (app1, or app2).

I am finding however that after a user logs into my app, if an ajax requests gets routed to the other instance,

my RestfulYii is saying that the request is Unauthorized.

  • and the load balancer is sending them here and there - ie: some to app1, and some to app2 - BUT - since the user has logged into app1, a session hasn’t been created for app2 yet - so the user returns an “unauthorized” message -

I am wondering - how to get different app servers aware of when a user has logged into one of them? Anyhow have experience with this?

Any insight would be highly appreciated.

Kind regards

Hi Fire,

As generally when we work we set same app on different instance but there is load balancer ahead of all this instances. And we have session stickiness on load balancer. So load balancer maintain key value pair for session id and from where(server) it was generated. SO on very next request it routes the request from its map data. I think this will solve your problem.

In java normally I have seen people creating cluster of server so session is replicated then all servers and load balancer maintain primary, secondary and so on server in its mapping and then it routes the request to respective server.

Let me know if it solves your issue.

This is interesting, but can you be more specific what exactly and how he has to do it?

I tried to give some reference URL for this but somehow it didn’t worked out as forum is not allowing me to post URL(strange).

But in AWS there is one stuuf : "Configure Sticky Sessions for Your Load Balancer" so you guys can have a look there.