简体   繁体   中英

AWS load balancer and auto-scaling

I have an application to sell some products and sometimes it gets crashed due to heavy traffic to overcome with this I hope AWS load balancer & auto-scaling will definitely help with this.

I have a few questions about it,

  1. What to do if I have a code-base & MySql server in the same instance? ( I can make use of RDS in this case )

  2. How to deploy the code? Do I need to create AMI each time when to be deployed or is there an automated process.

I am looking for the best approach to achieve this.

If you are using Wordpress the best configuration for a Free-Tier Based Instance is:

1) Install LAMP Stack on your instance by entering the command below

CentOS, RHEL, Amazon Linux AMI

yum install httpd php php-mysql php-pdo php-gd php-mbstring

Ubuntu, Debian

sudo apt-get install apache2 php php-mysql php-pdo php-gd php-mbstring

2) Setup an RDS to host your DB Server. You can use MySQL Workbench to connect to an RDS instance.

3) Upload your Wordpress Files to the /var/www/html folder and change the DB Host, DB Username and DB Password in the wp-config file. If you want to deploy a new site, I recommend using Duplicator Pro to migrate the whole site and do the configuration before installation.

4) If you are not able to see the reflected changes. Execute the below query on MySQL Workbench.

UPDATE wp_options SET option_value = replace(option_value, 'old_url', 'new_url') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'old_url', 'new_url');

UPDATE wp_posts SET post_content = replace(post_content, 'old_url', 'new_url');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'old_url', 'new_url');

To answer your questions:

1) You have to remove/migrate the MySQL Server Part of the code to RDS otherwise it will give you 504 Error Timeout as both Server and Client is using the CPU of the instance simultaneously.

2) You don't have to create AMI every time. AMI is automatically created once you select the type of Instance you can deploy the code using ssh, Filezilla for FTP Upload, MySQL Workbench for RDS Deployment

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM