Jump to content

So why is stateless so important using AWS Elastic Beanstalk?


March
 Share

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 

Link to comment
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.  

Link to comment
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.

Link to comment
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
Link to comment
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

Link to comment
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

Link to comment
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 

Link to comment
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.

Link to comment
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

Link to comment
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
Link to comment
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
Link to comment
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
Link to comment
Share on other sites

 Share

×
×
  • Create New...