I have an API server built with lumen. When I run load test that swarms the server, at a certain points it throws PDOException: SQLSTATE[HY000] [1040] Too many connections
. I am using a free tier AWS EC2 and RDS setup so I know that my instance is not big enough for this test, but is there any way to optimize this without upgrading the RDS instance first?
My question is:
- Will connection pooling avoid this problem? Will the requests wait for an available connection instead of crashing when I use connection pooling?
- Is there a way from preventing my app from crashing when this happens? So far it always require me to reboot my RDS instance