I'm using drupal 7.33 - php 5.4
I have many roles (17). When I change some data in the profile page I get the following error.
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 46 bytes) in /var/www/html/MY_SITE/sites/all/modules/authcache/modules/authcache_enum/authcache_enum.comb.inc on line 94
If I reduce the number of roles which are using authcache, the problem disappear.
Look like the code in the patch on this post should solve the problem but the code is totally different from the actual version.
I've checked the versions: 7.x-2.0-beta3+31-dev and 7.x-2.0-beta4 but the code is different than the patch.
Is there a way to correct the problem or at least a work around ?
Thank !!
Comments
Comment #1
znerol commentedPlease explain a bit your use-case. Do you have any scheme on how the roles are assigned to users? Are there any role-combinations which never will occure? Can you formulate (in words) a set of rules which role combinations are to be expected?
Comment #2
daniele belitrandi commentedI have 5 main roles:
- anonymous
- admin (which is a new role, Not drupal default. This role has access to almost everything and only 1 user is assigned to it)
- Master Publisher (has access to manage all the site content but do not have access to site configuration. just 1/2 user will have this role)
- Master Editor (has access to create/edit/delete node of only some content type and can publish the node, Few user will have this role).
- Editor (has access to create/edit/delete node of only some content type but cannot publish the node, only create draft node).
Then I have 13 different roles which give just 1 permission to access just 1 content type for each role. For example:
the role "Ad Banner city" give access to the content type "Ad Banner city"
the role "Ad Banner Country" give access to the content type "Ad Banner country"
the role "Ad Column city" give access to the content type "Ad column city"
.........and so on for 13 roles..............
As per default the role "Editor" is assigned to the user which give access to some content type. If the user want to purchase a banner ad, I will assign also the role "Ad Banner city". So the user will have 2 roles: "Editor" and "Ad Banner city".
I tested different combination of assigned roles to authcache.
What I found out is that doesn't matter which role is assigned to autcache and if the role give a lot of permission or just few of them.
The problem lay only on the quantity of roles. In my environment if I assign 17 roles everything is fine but in the moment I assign the eighteen role, the error come up.
I can live with that because it is only one role less than my need, but maybe my test result can be useful for someone.
Thanks for your reply and have a nice day.
Comment #3
znerol commentedAuthcache Enum tries to discover every possible authcache key. It does this by enumerating every combination of roles. In order to solve your problem it might be enough to limit the number of combinations.
Maybe this is possible by determining the maximum of existing role combinations instead of blindly work with all the combinations which are theoretical possible. I.e. select the user with the most roles and only build combinations of roles up to that number. However, this obviously will not work if there is at least one user having (nearly) all roles assigned.
In order to asses whether restricting the cardinality would solve the problem in your case, please save the following PHP snipped into a file in your websites root directory and run it once, then post the result here:
The output should look similar to this:
k_max=2;dt=0.00018405914306641Comment #4
znerol commentedComment #5
Matroschker commentedHello,
I got a similar error message in my system:
PHP Fatal error: Out of memory (allocated 1695023104) (tried to allocate 36 bytes) in C:\\...\\sites\\all\\modules\\authcache\\modules\\authcache_enum\\authcache_enum.comb.inc on line 29, referer: ...
... so I tried to patch the authcache.module with the patch from here "https://www.drupal.org/node/1963756" but the code is different, so now way to do this. (Checked with current DEV-version from 2015-01-02)
.. and I run your PHP code on my site, here is the result: k_max=119;dt=0.015625
Thanks for helping
Matroschker
Comment #6
znerol commented@Matroschker these numbers indicate that there are at least 119 authcache enabled roles at the site in question. Is this really true?
Comment #7
Matroschker commentedHi znerol,
yes it's true. But I checked this also with 45 roles - the same effect.
Matroschker
Comment #8
znerol commentedCan you estimate how many users you have per role-combination?
Comment #9
Matroschker commentedznerol,
not really. We have ~10 roles which defines the permissions for the kind of worker and a lot of product roles, which we use to give access to special content.
Can you explain why it is necessary that all roles, an user have, must selected in the authcache configuration that the caching works?
Matroschker
Comment #10
znerol commentedI'd like to point out the following things about Authcache;
As a rule of thumb if you end up selecting more than a small number of roles (perhaps at most 10) in Authcache, then you most probably should not use it at all.
Comment #11
Matroschker commentedOk, thank you for these information, we will consider these.
Can you recommend another cache modul?
PS: We have no free content only content which is available for authenticated users.
Thank you.
Comment #12
znerol commentedPerhaps post this question to the High Performance group on groups.drupal.org.
Comment #13
Matroschker commentedNow we could solve the performance issue on our site with an update of PHP to version 5.6 to enable built in OpCache and an enabled Memcached and Memcached Storage.
Thank you for your help.
(Drupal 7.34)
Comment #14
socialnicheguru commentedI have multiple roles but would like the option to select authenticated users (no other roles) and authorized user (any other roles). The latter would just cache anyone who is has the authenticated user role regardless of any other roles they might have.
Comment #15
znerol commented@SocialNicheGuru This is not something which could be solved safely in a generic way, but it can be achieved by customizing the Customizing authcache key calculation as explained in Authcache 2 tuning guide - optimize cache-hit ratio.
Comment #16
joelpittetk_max=4;dt=0.025913953781128Comment #17
killes@www.drop.org commentedI've also run into this but I resolved to not cache for most of the roles as the people who have these roles are few and they are unlikely to get a good cache hit ratio anyway.
Comment #18
Sneakyvv commentedPatch supplied in related issue #2443049-19: Performance issue with cache expiration