Justinus Hermawan
Justinus Hermawan

Reputation: 1214

Laravel with nginx server and AWS RDS got "too many connections" error

I'm facing a problem with my Laravel app running under nginx web server (an EC2 instance) and a remote DB connection to my AWS RDS (MySQL).

I've already scaled it up from t2.micro to t2.large for both of my EC2 and RDS, but MySQL still produced

too many connections

and

cannot allocate memory

error in my nginx log.

My RDS has max. 312 MySQL connections and I've used PDO persistent on my Laravel database config but it still doesn't solve the issue.

Do I have to scale it up to the higher instance level or is there anything wrong with my architecture?

Any answer would be appreciated.

Upvotes: 1

Views: 1376

Answers (1)

We went through a problem similar to this for a short time, we will solve the following problem:

1 - We use Aurora replicas. You can use replicas using the resource or the cluster

https://i.sstatic.net/hVcmh.png

2 - We modify the parameters of the institution. max_execution_time by default or unlimited RDS mounts. We place or limit as 10000.

https://i.sstatic.net/U7Ccb.png

3 - Assets for slow query (slow_query_log) of the cluster. Displays all queries that exceed 10 seconds of execution. Command, browsing optimizing queries.

https://i.sstatic.net/C7HX4.png

We have no more problems than we do. I hope I have helped.

Upvotes: 1

Related Questions