Jump to content
Sign in to follow this  
March

So why is stateless so important using AWS Elastic Beanstalk?

Recommended Posts

It is unfortunate that I must learn so many things the hard way.  After changing my Amazon Elastic Beanstalk with deployed Processwire code the Amazon Elastic cloud removed the website content because it is a stateless environment.  Here is the article that explains this: 

https://www.otreva.com/blog/deploying-wordpress-amazon-web-services-aws-ec2-rds-via-elasticbeanstalk/ 

I think my mistake is that inside the instance I stored content inside the instance that was running mysql and not the other instance that I thought was the database but I am not sure.  

Understanding elastic beanstalk as a stateless environment is very important and means that the server instance will terminate and rebuild automatically and any local content will not be replicated unless deployed through the beanstalk environment.  This means you you should not ftp php code changes but should instead write scripts or use the EB CLI with GIT hooks to deploy new code or deploy a new zip file version through elastic beanstalk.   

So my question for the forum is will Processwire work in a stateless environment like Amazon Elastic Beanstalk?  

If all content including images, etc. is stored in an outside database (RDS) and connect to the Amazon EC2 instance then it should all work.  

If any content or settings are stored inside the EC2 instance like what I think happened to me with mysql running inside my EC2 instance then when Elastic Beanstalk terminates and rebuilds environments the content will be lost.  It is scary to think that all the admin controls will be lost if they are not stored outside the EC2 instance inside the RDS database otherwise Elastic Beanstalk will wipe them out terminating and rebuilding, bummer. 

If anyone can add advise on this subject of PW running inside stateless environments it is much appreciated.  

Sincerely, 

March 

Share this post


Link to post
Share on other sites
Having some trouble with Processwire.  We are using Elastic Beanstalk on Amazon and these environments are often terminated and rebuilt in a stateless infrastructure.  

 

We think we can fix the problem by writing scripts for Amazon servers to protect certain local values so we need not log in and connect to database and rebuild all the website content as we have had to do a few times.  

 

We have identified the config variables but do believe PW stores many values on the remote server in some location.  Can you help us know where PW stores these values?  Some examples of the values we are seeking are like db hostname, user, login, and like I said much of the website content that I thought was stored in the DB. 

 

Your advise would be very helpful.  

Share this post


Link to post
Share on other sites

The database variables are in /site/config.php and there are some other useful values there. The config file is very simple, but you can add to it - a list of possible variables that processwire can use are here: https://processwire.com/api/variables/config/

All data is stored in the mysql database and assets like images and files are stored in site/assetts

That is about it.

Share this post


Link to post
Share on other sites

This might help

https://www.otreva.com/blog/deploying-wordpress-amazon-web-services-aws-ec2-rds-via-elasticbeanstalk/

It covers wordpress, but talks about things like not being able to upload images directly or install plugins and so on - in otherwords, as it is stateless, you are uploading a complete solution from git.

After that I get completely lost! :)

  • Like 1

Share this post


Link to post
Share on other sites

Joss,

Thank you so much for reply and happy New Year's Eve! My wife and have returned from a wonderful southeastern trip and it is nice to rest and relax inside a warm house.

Your reference to the config variables is really helpful and I had assumed this as well. Something seems to be happening inside the beanstalk server where the PHP code lives.

I mean is the config variables the only place in the beanstalk server instance where PW modifies? Is all the content, photos etc. inside a database outside the beanstalk instance? I don't mean to say the same thing but why is PW admin asking me to complete installation and after adding login and DB configuration for the third time it is like starting a new website with all my content gone.

AWS said if they can identify what variables are changed inside the EB instance we can make a workaround to preserve beanstalk from destroying our site ever time a snapshot or change is made in auto scaling.

Thank you again Joss.

March

Share this post


Link to post
Share on other sites

Maybe my question is not clear. Is the MYSQL database inside the EB instance? If so this would make sense. I have set up two websites and one seems to connect to the remote RDS and the other one that keeps being destroyed with auto scaling and the like also has a remote RDS in the setup that it seems to be ignored otherwise I would seem some data in it from our missing website.

Thank you, March

Share this post


Link to post
Share on other sites

Please don't get me worng.  We love processwire and  like you believe it is an awesome CMS and more.  But the Amazon Elastic Beanstalk environment is qestionable.

For instance when you modify pages or add modules in the admin control panel these changes are made local to the web server correct?  If they are truly saved in a remote database then this is good. 

If there is someone that knows where PW saves data on the webserver and where this is what we need to know.  Sincerely, March 

Share this post


Link to post
Share on other sites

PW saves data in the associated MySQL database. So, it will depend where on a server your MySQL installation is. 

Edit:

Just reading through the doc about installing Wordpress that I pointed to you earlier, it explains all about how to set up the database on beanstalk, how to install you wordpress locally, how to link the two together and so on. The instructions there will be pretty much the same when installing Processwire.

Maybe just follow that guide - much better than guessing.

Share this post


Link to post
Share on other sites

Joss,

Happy New year thanks! I have reread the article but hear it's what I cannot understand. If PW is a CMS with an admin panel to make changes online what happens if we add a page or new field?

The article says this:

Done! Well with the deploy process.

Now your basic WordPress application is up on AWS but keeping it stateless means you must always install plugins locally, make changes locally to theme files, and otherwise change the sources code in the repo locally and then add, commit and push to AWS.

We can live with changing files locally but it would be so much nicer to leverage the awesome pW admin panel and let it be but AWS will destroy all the admin panel updates without some sophisticated code to back up and deploy to Amazon S3 or something.

I really don't mean to make this more complicated than it is but Amazon has destroyed the website three different times with elastic beanstalk.

Are there special PW files besides config that needs back up in S3?

Thanks,

March

Share this post


Link to post
Share on other sites

Joss,

Thank you for your assistance with this article: https://www.otreva.com/blog/deploying-wordpress-amazon-web-services-aws-ec2-rds-via-elasticbeanstalk/ 

It took a little more to understand the cantankerous elastic beanstalk environment, to configure the local eb git deployment tools but it is all very clear now!  One of the biggest thing to know is that you should not mess with the elastic beanstalk environment; it is made with insane environment restrictions that in some ways makes it good because you just need to deploy the code with a few command.  But this is also the hardest thing to learn because messing with it will potentially destroy your code.  Nevertheless this is the system we have chosen and see some advantages and again are super excited about rapid development of content we can now do through Processwire.  

We have even found a PW module that will help us back up the PW code to an Amazon S3 bucket here: https://processwire.com/talk/topic/1368-save-files-in-amazon-s3-cloud/

Thanks again for all your help.  I suppose learning the hard way has its merits because you don't forget as easy but then again I've never measured learning easy against learning hard but for some reason I think learning hard retains memory a little better.  What we like about PW is it makes learning easier, yeah! 

Cheers, and again happy new year, 

March 

  • Like 1

Share this post


Link to post
Share on other sites

Yes, again I have confirmed that everything is working fine now and successfully rebuilt the website again.  Its not too bad if I must say myself.  

I've noticed things like the images and other items in the assets directory need to be deployed from the local environment to take effect.  I can't tell you how happy I am to have a development procedure down now.  Looking forward to learning more about PW.  

  • Like 1

Share this post


Link to post
Share on other sites

Once you work it out fully and are sure it is stable, you should write out the complete procedure from scratch for anyone else who wants to do this :)

Share this post


Link to post
Share on other sites

For sure, would like to do this. After we try adding some modules we can check to see if changes are reflected in the remote as they are in the local environments. For now the database is working marvelously and Amazon has a simple code push that we have perfected and this process would be valuable to pw fans.

  • Like 3

Share this post


Link to post
Share on other sites

One thing that has stopped me using Amazon before is that I can never work out what it is likely to cost!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By FrancisChung
      Has anyone come across this issue where Amazon Cloudfront seems to refuse to cache a certain small number of static objects?
      I've tried invaliding the cache (root path) several times to no avail.
      I had a look at the file permissions of the objects in question, and they seemed all ok.
      I've also gone into the Amazon Console and there are no errors logged.
      You can see more details of this here :
      http://www.webpagetest.org/performance_optimization.php?test=171106_A4_be80c122489ae6fabf5e2caadcac8123&run=1#use_of_cdn
       
      I recently upgraded this test site to PW 3.062 from PW 2.8.x and noticed this was happening. I'm also running the latest version of Procache on this site.
    • By FrancisChung
      Hi there,
      I was looking for some Processwire + Amazon integration advice. I've never built an e-commerce platform before and surprisingly there's hardly any articles or forum posts when you type in variation searches of "Amazon + Processwire"

      Are there any 3rd party tools and services you recommend?
      Any gotchas I should be aware of ?

      Thanks in advance!
    • By artaylor
      Hi all,
      I am trying to use Amazon S3 to store video files for a client. I am having trouble getting the SDK to work. I am sure it is a stupid error on my part but my head is sore from banging it against my desk and I thought I would finally ask for some help. 
      I am running PW 3.0.11 on NGINX.
      1. Amazon recommends using Composer to install the SDK. I was not sure where in the path to install the SDK so I put composer in the /site folder and installed the SDK there (putting vendor at the same level as modules), then I put the require and uses statements in _init.php. I always got an error saying it could not load the aws or s3 classes from the library.
      2. So, then I tried to use aws.phar. I put that in the /site directory but once again, no matter what I do, it will not load with the following error:
      require(): Failed opening required '/site/aws.phar'
      The file is there with proper permissions and the code for loading is:
      // --- amazon S3 stuff require $config->urls->site . 'aws.phar'; $s3 = new Aws\S3\S3Client([     'version' => 'latest',     'region'  => 'us-standard',   ]); So, here are my questions:
      1. In general, where is the correct place to put a php library? It is not a PW module so I assume it should not go in the modules folder.
      2. Should I use Composer to install the SDK? If so, where do I put the files? Should I add the AWS SDK to the main composer.json file or put it somewhere else?
      3. If I don't use Composer, where do I put the aws.phar file so that PW can load it?
      4. Should I not put the 'require' in the _init.php file and move it to another file (_func.php)?
      I am sure there is a massive face-palm in my future when this gets sorted out.
      Thanks
×
×
  • Create New...