Closed (fixed)
Project:
Drupal core
Version:
9.1.x-dev
Component:
update.module
Priority:
Major
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
24 Jul 2020 at 04:21 UTC
Updated:
10 Apr 2026 at 10:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
aaronmchaleCouple of initial thoughts:
Each of these could be factors in deciding how to proceed.
Comment #3
heddnThe default droplet for Digital Ocean is now 1GB. And that's been the default for a few years. I haven't tracked Linode, so I'm not sure how recently they changed, but their entry level plan is also 1GB. So the age-old truism that we have to fit Drupal on a 512MB box seems to not be the case any more.
Secondly, early performance numbers seem to show that 500-600MB of memory is needed by composer alone to run an update of Drupal core. Let's add 128M for Drupal core. So a good place to test/play around with is a 700MB memory limit for running automatic updates via composer. That's not a small amount, but it also isn't out of the reach of smaller hosting either. Especially if we can bump the memory at runtime for the update process only and not require all php threads have that high of dedicated memory.
Comment #4
effulgentsia commentedThe default has been 128M since PHP 5.2.1, and still is as of 8.0.0-alpha3.
1GB is reasonable for VPS setups. However, old-style shared hosting is still a thing, and I suspect that many of the large shared hosting providers limit well below that. Even for newer-style managed cloud container providers, the cost increases for memory. E.g., FortRabbit's pricing goes from $5/mo for 128M to $30/mo for 512M, and then way up to get above 512M.
Comment #5
heddnI wondered about shared hosting as I've never entered that world much. Thanks for posting those numbers. Would it be worth it to some folks if they wanted automated updates to pay the extra a month needed for memory? I could see it being worth it for some people. I'm not sure we'll be able to get memory down much below 500-700 and also use composer.
Comment #6
webchickHere's the list that's first in Google results when you search "most popular shared hosts" https://www.cnet.com/news/best-web-hosting-providers-in-2020/ ("best" is not the same as "most popular" but let's start there).
Ok I'm tired of this now, someone else can take it from here. ;)
Comment #7
heddnSo, to me, it looks like a stretch that we can get the memory needs down into the shared hosting limits. Yeah, there might be an exception, but by and large, the resounding message is 64-128. Maybe 512 as a stretch. But no where near the 700 that would sorta be needed. Where does that leave us? Auto updates for all but the extreme edge case of shared hosting (if that)?
Comment #8
aaronmchaleRe #7: Is it still the case that the memory intensive part is the building or reading of the composer.lock file? If I remember correctly I believe that was the issue with Composer 1.
Comment #9
effulgentsia commentedI imagine that it would be worth it for some and not for others, and that that ratio would depend to some extent on both the ease of upgrading their hosting plan and the cost. For Drupal as a project, we'd prefer for as many sites as possible to stay secure, and we know that without auto-updates there's way too many sites not applying security updates in a timely way.
A possible saving grace for #6 is that increasingly, shared hosting companies are providing the option to upgrade to a managed plan with dedicated resources. That's much better than asking people to switch to some other VPS provider, because:
However, taking a couple of the examples from #6:
A next step here might be to see if the other providers in #6 as well as other major providers offer something similar, where by simply spending $10/mo or so more money, you could get the needed RAM, without having to switch providers or take on any new sysadmin responsibilities.
Comment #10
webchickYeah, agreed that if they need to switch to an un-managed VPS in order to auto-update their Drupal, they're plugging their Drupal security problems but also giving themselves N more attack vectors to worry about. :\ Not a net win...
Neat to know about Managed VPS as a thing, though. I might switch to that myself. :)
Comment #11
fkelly12054@gmail.com commented@webchick ... on inmotionhosting, shared plan my php.ini shows:
max_execution_time = 30 ; Maximum execution time of each script, in seconds
max_input_time = 60 ; Maximum amount of time each script may spend parsing request data
memory_limit = 512M ; Maximum amount of memory a script may consume (32MB)
however under the core section when I run phpinfo.php it shows a memory_limit field of 768M. This is for php 7.3.20.
Not that either will be sufficient for composer. But
In most of the updating recommendations I see on Drupal.org they are saying "don't run composer against your production server".
What I, and I think most shared server users, am trying to do is set up a local version using Wampserver, (or equivalent) that mirrors the production server as exactly as possible and then run composer updates there. Getting this set up properly can be a p.i.t.a. ... for instance on a typical local server set up you will have multiple versions of PHP scattered around and need to find the right one to change the memory limits setting on. But once you do it is easy and fast to run composer update to do both core and contrib updates. This should give a set of files that can then be synched back over to the production server copy of Drupal. Run update.php and you should be ready to go.
Comment #12
effulgentsia commentedThanks for the info on InMotion, @fkelly!
That is the current recommendation. This issue is part of the Automatic Updates Initiative. #2940731: Automatic Updates Initiative overview and roadmap contains an overview of the initiative, and what's being currently proposed and explored for that is for Drupal to use Composer 2 to perform an automatic update directly on the production server. That's still very much work in progress, and this issue is for getting some more clarity on what that would mean in terms of being able to work on shared hosting.
Comment #13
effulgentsia commentedI just found #2958021-47: Proposal: Composer Support in Core initiative, which is a comment from 2 years ago that looked into where Composer consumes the bulk of memory:
That was for Composer 1. Not sure if that's changed for Composer 2.
Comment #14
webchickThere was talk at some point of running Composer-as-a-Service (and charging some fee for it), so we could offset the memory requirement to some super-beefed up server that the DA runs for people who aren't able to run Composer in production due to RAM limitations. Not sure if that's a viable path...
Comment #15
effulgentsia commentedHas the peak memory situation improved with Drupal 9's
drupal/recommended-project? Here's what I'm seeing on my MacBook, using https://getcomposer.org/download/2.0.0-alpha2/composer.phar.First, create a new project for Drupal 9.0.1:
Next, profile a dry run of updating it to 9.0.2:
Which outputs:
According to that last line, this only required 114MiB of memory. Does that seem accurate, or is there something strange with my setup that's causing it to consume ~4x less RAM than others have reported?
Comment #16
heddnI think it uses more memory when you limit it to _only_ drupal core. I did the same setup tasks as in #15 just now. Then added:
composer require drupal/pathauto drupal/group drupal/commerce drupal/admin_toolbarBecause the number of contrib dependencies also has an effect.
And with
composer update drupal/core-recommended --with-all-dependencies -v --dry-run --profile, I got a much higher memory usage:Memory usage: 65.34MiB (peak: 471.26MiB), time: 20.42sComment #17
ressaUsing the recommended test method by The Composer developers, I get these results in Ubuntu 18.04, PHP 7.3.20, Composer 2.0.0-alpha2:
Comment #18
ressaYes @heddn, you're right -- adding a few modules makes all the difference. Same procedure as above, only adding a few modules quadruples the memory usage:
Comment #19
effulgentsia commentedIt seems to depend on which contrib modules...
If I require most of the dependencies of the ones from #16:
Then after a
I still only see 172MiB of peak memory. There's also this line in the output that's interesting:
Which is 72% more than the
70557from #15, and maybe is part of the reason for needing 50% more memory?However, if I require any one of:
Then, a
analyzes over
600,000rules and requires over 400MiB of RAM.I wonder what it is about these modules that causes such a massive increase of rules that Composer needs to analyze.
Comment #20
ressaI can confirm the findings (Composer
2.0.0-alpha2"preview"):$ COMPOSER_DISABLE_NETWORK=1 composer update drupal/core-recommended --with-all-dependencies -v --dry-run --profilePackages
commerceguys/intl drupal/address drupal/admin_toolbar drupal/ctools drupal/entity drupal/entity_reference_revisions drupal/profile drupal/state_machine drupal/token drupal/variationcacheResult:
Packages
drupal/pathauto drupal/group drupal/admin_toolbarResult:
Comment #21
ressaRunning Composer 2.0.0-alpha2 Drupal 9.0.1 > 9.0.2 with
$ COMPOSER_DISABLE_NETWORK=1 composer update drupal/core-recommended --with-all-dependencies -v --dry-run --profile:Comment #22
effulgentsia commentedI'm now seeing the same on
drupal/pathautoas #21, but when I wrote #19, I'm pretty sure that was the first one I tried and got the much larger result. Hm, not sure what changed.Comment #23
effulgentsia commentedThere's a PR on https://github.com/zaporylie/composer-drupal-optimizations/pull/17 to make that plugin work on Composer 2. That PR is incomplete and fails to install on Composer 2. I'm working on a local copy that I now have installing correctly, but it's not making any dent in the numbers. I don't know yet if it's because that plugin solves a different problem space than what we're encountering in #20, or if my work in progress port of it is buggy. I'll post an updated PR there once I have something worth sharing.
Comment #24
ressaYour work on
zaporylie/composer-drupal-optimizationssounds interesting @effulgentsia, I will be ready to try it out, when there is something to test. I also wasn't sure if my results were consistent, possibly because I didn't runcomposer updateto updatecomposer.lock?I wrote a little scripts which runs through the 30 most popular Drupal 9 modules. The modules fell into two categories, fast ones and slow ones, like we have already seen. I ran the process three times, with same results. I wonder what sets them apart?
Fast: 165 MB (17703 packages, 114015 rules)
Slow: 456 MB (17704 packages, 602129 rules)
Test update the 30 modules with Composer 2 with these commands. First, get Composer 2:
$ composer self-update --previewGet the update script, rename (
.shfiles are not allowed to upload) and give it execute permissions:Get Drupal 9, enter folder and run the update script:
To build the list, copy and paste the resulting text from the terminal in a file called
terminal-results.txt, and run these commands:Comment #25
effulgentsia commentedThanks for #24!
To add to that, I found that
composer require drupal/entity:^1.1leads to a fast update (per #24), butcomposer require drupal/entity:^1.0leads to a slow one.What changed between 1.0 and 1.1 was that 1.0 had a require of drupal/core of "^8.7.7 || ^9" and 1.1 changed that to "^8.8 || ^9".
However, I tried replicating the exact same scenario on GitHub, but in that case
composer require effulgentsia/composer-test:^1.1andcomposer require effulgentsia/composer-test:^1.2led to equally fast (low memory) updates.So the change to drupal/entity's composer.json isn't the full story, but perhaps that in combination with something else that https://packages.drupal.org is doing for projects that change their composer.json across different tags?
Comment #26
naheemsays commented@effulgentsia - could that be due to increased requirements checks? Maybe https://github.com/composer/composer/pull/8850 will help if it gets commited to Composer (they have a request for performance numbers in that pull request)
Comment #27
ressaGreat effulgentsia! Interesting with the differences in drupal/entity ...
You're right in your assumption @NaheemSays, the patch being investigated in Composer issue Filter dependent packages early #8850 fixes the issue, and all modules update using only 96 MB in 1.27 seconds, the results:
composer self-update --previewandcomposer self-update --snapshot--preview: latest release of Composer version 2.0.0-alpha2 2020-06-24 21:36:18)--snapshot: dev-release of Composer 2.0-dev (2.0-dev+2d3...2f2) 2020-07-30 19:06:51)Same 19 fast and 11 slow modules as listed in #24:
19 fast modules (typical numbers)
11 slow modules (typical numbers)
php composer-test.phar
Updating with test-release for performance improvement Composer version 2.0-dev (2.0-dev+0713...6c7) 2020-07-17 14:16:58 from Filter dependent packages early #8850, all 30 modules peak at only around 96 MB memory usage in 1.27 seconds.
Typical numbers:
I have tweaked the script a bit, to automate some of the tedious tasks. You can run it with these commands:
It will result in a file called something like
final-result-Composer-version-2.0.0-alpha2-2020-06-24-21:36:18.txt.To run the code with the
composer-test.pharperformance test version of Composer 2 from "Filter dependent packages early #8850", download thecomposer-test.phar:$ wget https://seld.be/composer-test.phar... and switch Composer version around line 23 of
composer2memtest.sh, to make it look like this:Attaching result files for completeness.
Comment #28
ressaUpdating test script, I uploaded a wrong version.
Comment #29
ressaComment #30
MixologicThe main discrepancy between the groups of projects, is the slow group has a wider dependency net:
drupal/core: ^8 || ^9.This causes composer to consider every d8 and d9 version of core that exists - as of today, there are 167 releases of drupal core > 8.
Core itself has a very large dependency chain, thus having that many more releases means that composer creates hundreds of thousands of more rules to consider.
Which could help explain why that PR would help trim down the number of core versions that composer would consider before creating all the rules.
Comment #31
effulgentsia commentedPostponing this on https://github.com/composer/composer/pull/8850, which would solve this for us. If, for whatever reason, they don't merge it, we might need to explore alternatives, but for now, I think it makes sense to wait and see if they merge it.
Comment #32
bojanz commentedThe PR has been merged and is included in the latest Composer pre-release (2.0-rc1).
Comment #33
effulgentsia commentedYep, and I think that makes this issue fixed now. We can re-open it if/when we discover otherwise.
Comment #35
ressaI was reminded about this Composer/Drupal performance issue via #3356739: Memory usage increases linearly when (un)installing modules via config import, and ran a few commands with 55 modules. Composer peaks at
~150MiBand Drush at~65MiBso it looks good:Composer download
Composer update from Drupal 11.3.6 to 11.3.7
Composer update from Drupal 11.3.6 to 11.3.7 + modules ("everything")
Drush install
Drush uninstall