0

Might be a rookie question but unable to get clear answer on the web, so please help. Scenario is: I have two instances of php server (Let's say A and B), one instance of loadbalance and one of mysql. Stack is almost ready but one confusion in my mind is what will happen to the photos uploaded by user.

Suppose user comes to sever 'A' through load balancer and uploads the image which gets stored on my "webroot" folder on server 'A'. Now after few days user visits the website again and this time hits server 'B'. He won't be able to see his image as it is residing on server 'A'. I want to know how AWS opswork handles this problem?? Will it sync the data automatically or some extra chef receipe needs to be created from my side.

Please guide me on this. I am in process of applying opswork to my website and this confusion is not letting me proceed. Any links will be useful.

2 Answers2

3

Short answer: it doesn't.

You need to account for application state (which includes uploaded files) in your application. A frequent design pattern for uploadednfiles is to use S3 for storage instead of your local file system

Another option would be to have a long-running (non-ASG) storage server that exports a filesystem via NFS to your application servers, and then they all use that for uploaded content.

EEAA
  • 108,414
  • 18
  • 172
  • 242
  • Thanks for the Info. I was looking for this. Do I need to create chef recipe for NFS instance configuration or there exists built in support? Any info on advantages or disadvantages you can think of. Asking you a lot but please help – Ankur Aggarwal Jan 27 '15 at 14:44
  • No, there is not built-in support for doing this. You'll need to research how things like this get set up and then build it up yourself. – EEAA Jan 27 '15 at 14:53
  • thanks for the info. Finally decided to go with NFS and learning to create chef recipe for the same – Ankur Aggarwal Jan 28 '15 at 12:52
2

No, the data will not be synced.

The typical approach on AWS is to have your application upload the files to Amazon S3 instead of leaving them on an individual instance. This can be done on the client side using JavaScript (http://www.plupload.com/ is what I've used in the past for this) or on server-side in your script.

ceejayoz
  • 32,469
  • 7
  • 81
  • 105