0

I have a cloud-based application written in PHP 5.6. It is a supermarket application that has traffic in some specific hours. In those peak hours, when large traffic hits across multiple supermarkets, the processing slows down among all the supermarkets.

I am using AWS EC2 and the application is running with a load balancer. There are 4 instances under the load balancer. I have tried to increase the no. of instances but still facing the slowness issue in those peak hours. I have also tried to change the category of the instance to a higher no. of CPUs but that didn't resolve the issue of slowness as well. I assume the PHP is single-threaded and due to this reason, increasing the CPUs might not have worked.

The web server is apache and PHP is being used as a module of Apache as in the following image: phpinfo

It will be a great favor if someone can advise with the solutions to handle these issues.

Waseem
  • 41
  • 5
  • Have you verified what resources are running short when the instances are slow? You can access specific metrics in the monitoring part of the aws panel. Maybe it's not the CPU? Maybe it's not even the EC2 instances, but instead the database if such exists? – thephper Dec 28 '21 at 12:09
  • @thephper, thank you, I have checked, this is not the case. I have upgraded the instance to have more CPUs and it is working way better now. – Waseem Jan 08 '22 at 16:06

1 Answers1

0

is CPU usage is on servers reached the limit ?

Yes: means there is an application issue and need to be resolved a quick fix is to implement Auto-scaling based on CPU traffic

No: Means something else other than CPU is the bottleneck

1- Consider using PHP-FPM as a process manager to have better control over the number of connections and threads.

2- configure slow PHP log to identify functions with slow execution

3- log slow database queries.

4- install and configure PHP profiler.

AWS PS
  • 4,420
  • 1
  • 9
  • 22