0

We have developed Laravel based software, locally tested with Laravel Valet and everything is working fine. One installing on a staging (direct admin) webserver with exactly the same database and code the memory usage dramatically increased.

Local testing specs: OS: MacOS Catalina Proc: 2.3 GHz 8-Core Intel Core i9 Memory: 16 GB 2667 MHz DDR4

Staging server specs: OS: CentOS 7.0 64-Bit Processor Speed (MHz) 2693.670 Total Memory 1014728 kB

This is a basic static page:

Staging server: 21MB, PHP 7.4.2

Development machine: 5MB, PHP 7.4.4

Another larger page (which needs optimization):

Staging server: 101MB, PHP 7.4.2

Development machine: 85MB, PHP 7.4.4

We know this development machine is a lot slower but we cannot explain the memory usage increase. Does anybody know how to analyze and resolve this?

The used framework is Laravel v6.18.20

SvT
  • 5
  • 4
  • First thing to double check is that you followed the guidelines for deploying a Laravel app (found here: https://laravel.com/docs/6.x/deployment) It also looks like you're using different versions of PHP. I'm curious if the memory usage differences are between 7.4.2 and 7.4.4. – Dan Fletcher Jun 17 '20 at 16:31
  • The deployment procedure has been followed as far as possible. Also locally this had not been done and this is using less memory. I really cannot imagine that this version difference changes so much in memory usage.The newe version would be worse in this case... – SvT Jun 17 '20 at 17:56
  • My first guess recommendation would be to compare the extensions and modules you're using for PHP and Apache/Nginx on each system. Those can heavily affect memory usage. Considering that the difference in memory usage was 16 MB in both examples, this seems a likely cause. Another thing to check would be caching settings or other things that might be affected by `.env` settings. – Kyle Challis Jun 17 '20 at 23:38

1 Answers1

0

Well Laravel Valet uses a very lightweight web server and that is a huge difference, I suggest to configure your webserver to use Nginx instead of Apache and be sure you are using PHP as FPM module, generally speaking, servers with Direct Admin uses Apache webserver by default and that will increase the memory usage of every request.

Try to switch to an Nginx webserver

OsDev
  • 1,243
  • 9
  • 20
  • Just switched to Nginx. The results are the same. PHP server is already running as FPM module. – SvT Jun 17 '20 at 17:57