Link to home
Start Free TrialLog in
Avatar of Mark
Mark

asked on

AWS Design help

AWS Design help

I have a Ubuntu server (basically a LAMP stack) hosted on Linode. There's a PHP script that gets heavy usage that I'd like to move to AWS (along with the DB it uses).

I was thinking of putting the PHP Script on AWS Elastic beanstalk and having it connect to an Aurora auto scaling MYSQL database.  Most of the PHP script does read operations with the exception of a call to increment a hit counter.

How do I go about keeping the master database (on linode) and the AWS RDS Aurora database in Sync so I can offload the heavily-used PHP script

Or am I completely going about this the wrong way .. please advise
Avatar of Mark
Mark

ASKER

I want to have the PHP script and the database it connects to available regardless of the load .. both auto scaling
Avatar of David Favor
Describe more about how your PHP script interacts with MySQL.

Including running EXPLAIN on slow SELECT statements.

Might be a simple fix someone notices.

Specifically you said...

- I want to have the PHP script and the database it connects to available regardless of the load

- both auto scaling

Both these are normally handled by tuning your LAMP Stack on a single install. For example, start with...

1)  FPM PHP with deep logging enabled to determine if you require running more PHP processes.

2) Run top to ensure you never start swapping or worse, OOM (out of memory killer) begins running.

3) For MySQL, simple start will be to pick the correct storage engine. Can't tell you how many MySQL problems I've fixed by changing from MyISAM to InnoDB, because of locking contention.

4) Next for MySQL, just run mysqltuner, for some very coarse tuning suggestions.

5) With PHP, be sure Opcache is both running + correctly tuned (lots of free memory blocks + key blocks).

6) Run iotop -P -a -d 1 cycling through various I/O looking for massively ramping up disk writes, then fix related code.

So long as you have lot's of free memory + low disk I/O code, you can tune a LAMP Stack on most garden variety hardware to handle the load.

If you have run away I/O, moving to other hardware won't fix this. Best to fix this so your code runs well on cheap hardware, so you can easily scale up usage.
Avatar of Mark

ASKER

David:

This is not about slow select statements, I'm well versed on proper indexing, etc. .. this is about wanting AWS to handle scaling issues for me

Linode had a data center systemwide outage this week--I want to move this mission-critical scripts from Linode to AWS and have them handle it for me.

It's a single PHP script making 1-4 select queries and 1 insert statement.
Avatar of Mark

ASKER

As far as I can discern:

- Setup an RDS Aurora MYSQL instance
- Setup an elastic beanstalk PHP application to talk to it

My questions are:
- Based on the available information I have supplied, is this the best setup.
- Do I use AWS's Database Migration Service to keep the RDS db instance up to date?
- Can I configure both beanstalk and RDS to scale automatically without limit?
- When RDS vertical scaling occurs, does my PHP script need to change the host it connects to or does AWS route the connections automatically
- When an insert/update/delete SQL command, what is the delay time till all instances are updated
@Mark - you are asking very specific AWS questions which I doubt you will get exact answers to.

Unfortunately AWS documentation is actively striving for the worst technical documentation in history award and I suspect it might just win it - so I understand why you are posting here.

I think the best way forward is to try and work through this with you - rather than giving specific advice (maybe there is an expert on this forum with this specific knowledge - but I have not seen much on AWS here yet). I am busy upskilling on AWS although not from the PHP side - more on the Node - so not familiar with beanstalk.

I started here
https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.Integrating.AutoScaling.html

From this I get that you need to setup your Aurora instance and at least one replica. After that Amazon will scale the replicas as needed - it will add instances (and I assume populate them for you) and remove instances (but only ones it added) based on load.

There is also a link to a connector for Maria - that you would need to use to access the cluster - I have not look at this yet but I would imagine this is what you would need to use in your PHP script to access the data.

This may be what you have already - but post back with comments / questions and let's take it from there.
ASKER CERTIFIED SOLUTION
Avatar of Ramasamy P
Ramasamy P
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mark

ASKER

Thank you all