Answers.Body: <p>Easiest solution: if AWS supports "sticky sessions" at the load balancer level, then you should enable to to ensure that the user gets sent back to the same EC2 instance that their session was created on.</p>
  
  <p>Next easiest: create an NFS share and use <a href="https://secure.php.net/manual/en/function.session-save-path.php" rel="nofollow noreferrer">https://secure.php.net/manual/en/function.session-save-path.php</a> on all EC2 shares so all EC2 instances read/write to the same place.  You'd also want to set the Craft <a href="https://craftcms.com/docs/config-settings#appId" rel="nofollow noreferrer">appId</a> and <a href="https://craftcms.com/docs/config-settings#validationKey" rel="nofollow noreferrer">validationKey</a> config settings to be consistent across all of the EC2 instances.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-05T02:50:45.560Z
Answers.Text: Thank you @Brad for the answer and also for editing the question, learnt quite a few things there. :)
Answers.UserDisplayName: Ankit Sahu
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-03T17:56:00.407Z
Answers.LastActivityDate: 2017-05-05T21:30:46.233Z
Answers.LastEditDate: 2017-05-05T21:30:46.233Z
Answers.UserDisplayName: Brad Bell
Body: <p>Things were fine (no session logout for admin from CP) when there was only one EC2 instance for our website.
  I created a replica of the existing EC2 instance and now when I go to Control Panel, session keeps getting expired every 30 seconds.
  Please help me out in order to resolve the issue.
  Also, what are the things I should keep in mind when I'm using multiple EC2 instances for Craft website.</p>
  
Tags: <control-panel><multi-environment><session>
Title: With two EC2 Craft instances, the Control Panel session keeps expiring
ThreadText: # With two EC2 Craft instances, the Control Panel session keeps expiring
  
  (Asked by: username_0 on 2017-05-03)
  
  Things were fine (no session logout for admin from CP) when there was only one EC2 instance for our website.
  I created a replica of the existing EC2 instance and now when I go to Control Panel, session keeps getting expired every 30 seconds.
  Please help me out in order to resolve the issue.
  Also, what are the things I should keep in mind when I'm using multiple EC2 instances for Craft website.
  
  **Tags:** control-panel, multi-environment, session
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-05-03. Score: 1 | Accepted answer
  
  Easiest solution: if AWS supports "sticky sessions" at the load balancer level, then you should enable to to ensure that the user gets sent back to the same EC2 instance that their session was created on.
  
  Next easiest: create an NFS share and use <https://secure.php.net/manual/en/function.session-save-path.php> on all EC2 shares so all EC2 instances read/write to the same place. You'd also want to set the Craft [appId](https://craftcms.com/docs/config-settings#appId) and [validationKey](https://craftcms.com/docs/config-settings#validationKey) config settings to be consistent across all of the EC2 instances.
  
  > **Comments:**
  > **username_0**: Thank you @username_1 for the answer and also for editing the question, learnt quite a few things there. :)  
  
  ---
  
  