Today I completed my exploration into making my architecture more stateless. I have a WordPress page that I have decided to use as a sample and experimented with different AWS solutions that allow this website to be launched independent of a local database or local file storage.
Through MySQL workbench I was able to determine that I would migrate my schema from my WordPress backup data from an ec2 instance to an RDS instance. This would allow my database load to be distributed to a remote connection to allow higher availability and scalability. This coupled with my ability to offload content to an EFS drive would make my web instances stateless, allowing me to scale them without reconfiguration.
After schema conversion was complete I modified the wp-config.php file in my Linux ec2 instance to point my database connection to my remote RDS instance. Modifications similar to what’s below:
define( 'DB_NAME', 'bitnami_wordpress' );
/** MySQL database username */
define( 'DB_USER', 'bn_wordpress' );
/** MySQL database password */
define( 'DB_PASSWORD', '**********' );
/** MySQL hostname */
define( 'DB_HOST', '"RDS_INSTANCE_IP_ADDRESS":3306' );
/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
After restarting apache, I was able to reload the website from the remote database connection. Certain items had difficulty transferring so I had to export then import specific tables from my ec2 localhost database into the RDS instance.
I learned that all migration is not straight-forward and that certain values may be lost or corrupted. This means that I needed to scrounge around my old and new database to compare tables. I needed to add some user data values and clean up entries created by spam bots online.
After recreating the database a few times, I learned that the initial migration needs to happen smoothly or else the new database may not serve the website correctly. I have a feeling that database engineers spend quite a bit of time making sure any upgrade happens during off hours and will scrub the new update for miniscule changes that can cause big issues.
Lastly about EFS solutions, they need to be optimized according to the solution being used. In my tests with Moodle, the system was running incredibly slow. I suspect I would need Elasticache. I will explore containerized solutions for WordPress but before I start I would like more experience with python and Javascript. I am pleased with my experience with managing databases and creating elastic file servers.