-1

I have two EC2 instances. One with 1GB RAM and 1vCPU and the second with 32GB RAM and 12vCPU.

I am running a script on cron job but I still have the same performance in both.

I tried changing max_memory, max_connection in php.in and I am using PHP 8 but still no luck.

On the 32GB server, I tried running my script multiple times in parallel but it doesn't seem to do any better.

How can I make my PHP use the best of the RAM and run faster?

1 Answers1

2

As we have no idea what your program does, it's impossible to say if adding resources will improve its performance.

Whatever you do, beware premature optimization. Sampling resources usage during its run (e.g. with vmstat) will yield if your programm is resource starved. Establish a baseline, add resources and verify that your program actually benefitted from adding them.

If there is no bottleneck, adding resources will not make your program run faster. Running it on a newer CPU model might speed it up a little.

As you've stated that your program is invoked by cron, I'm assuming that you are running standalone software (with perhaps the occasional call to a web application). Thus making use of more CPU cores is something that your code must be prepared for, using some kind of parallel operation paradigm like threading, forking, etc.

If we're talking web application only, and your cron job is a glorified wget call, check if you are using php-fpm and the PHP opcache module.

fuero
  • 9,413
  • 1
  • 35
  • 40