question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adapt PHP configuration to fit memory limit of an application automatically

See original GitHub issue

Currently, the PHP buildpack really makes no attempt to configure HTTPD, Nginx and PHP-FPM such that resource usage does not go above the memory limit assigned to a given application.

If you look at PHP & PHP-FPM, this is where 90%+ of the assigned memory will be used. Right now, we default the memory_limit to 128M in php.ini [1] and we set the max number of workers in php-fpm.conf to 5 [2]. This leaves us with a default memory liability of roughly 128M * 5 + HTTPD/Nginx + PHP-FPM itself. From what I’ve seen, this is far higher than most memory limits (128 - 256M) being assigned to PHP workloads, which means given the current default configurations there’s a potential for PHP to consume more memory than expected and crash the container.

Currently, we put the responsibility of adjusting PHP’s configuration on the user. It’s easy enough with the PHP buildpack to override these default PHP & PHP-FPM settings so that you can scale the app to use as much memory as is required for your workload. Having said that, it’s unlikely new users or casual users of the buildpack will go through this process and will just rely on the buildpack defaults.

This issue is to open a discussion about how we can improve the buildpack so that it will do a better job adapting the PHP configuration to make use of the memory limit assigned to an application by default.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dmikusacommented, Aug 15, 2018

@astrieanna - I opened this to get feedback mostly. Right now what the buildpack does is pretty simple. There are more complicated things that we could be doing (see brainstorming above ^^).

I haven’t heard a lot of feedback on this though. It’d be nice if we could get this in front of a wider audience to perhaps hear what others thinks. Are there problems with what we do now? Does it work for most cases? Are there things people routinely change, customize or override with how the buildpack handles this now? Are there any concrete use cases that people could share? etc…

I will post something to the mailing list and see if that draws any additional feedback.

0reactions
dwillistcommented, Feb 15, 2019

Closing this due to inactivity, it seems like this discussion could be continued with relation to the php-web-cnb here. But please feel free to re-open.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Optimizing PHP Application Concurrency - Heroku Dev Center
Another quick and easy approach is lowering the memory limit configured in PHP in subsequent steps (of e.g. 16 MB) until you start...
Read more >
Changing PHP memory limits - Drupal
There are several techniques to increase the PHP memory limit. Use the right one for your system configuration.
Read more >
How to Increase PHP Memory Limits - Scout APM
Strategy 5: Increase via ini_set() Function​​ ini_set('memory_limit', '512MB'); The above function will set the memory limit at 512 MB. Also, the ...
Read more >
How to Increase Maximum Upload and PHP Memory Limits
How to Increase PHP Memory Limit and Maximum Upload Limit in WordPress · 1. Edit your wp-config.php file · 2. Edit your PHP.ini...
Read more >
How To Prevent PHP-FPM From Consuming Too Much RAM ...
If you think that you use too much RAM, look into your application if you can cut away things. In general, you want...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found