Multilingual config cached in "config" cache bin; quickly reaches APCu memory limits

Created on 2 December 2016, about 8 years ago
Updated 12 September 2023, over 1 year ago

Problem/Motivation

In #2765271: Rationalize use of the 'discovery' cache bin, since it's stored in the limited size APCu by default , we're rationalizing the use of the discovery cache bin.

We already landed #2824547: Change ViewsData to use the default cache bin instead of discovery and #2824548: Move token info cache to data cache bin as part of that. That really helps, see #2765271-19: Rationalize use of the 'discovery' cache bin, since it's stored in the limited size APCu by default .

But, multilingual sites face a bigger problem: multilingual (translated) configuration. (@dawehner already mentioned this in the issue summary of #2800605: Warn/inform users when the hosting environment has a too low limit of APCU cache .) Because

  config.typed:
    class: Drupal\Core\Config\TypedConfigManager
    arguments: ['@config.storage', '@config.storage.schema', '@cache.discovery', '@module_handler']

means that all translated configuration is also cached in the discovery bin. So, the more multilingual you are, the bigger of a problem you have.

This can easily result in a few megabytes per language … meaning that you can reach the APCu limit rather quickly.

Proposed resolution

TBD

Remaining tasks

TBD

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Cache 

Last updated 4 days ago

Created by

🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

  • D8MI

    (Drupal 8 Multilingual Initiative) is the tag used by the multilingual initiative to mark core issues (and some contributed module issues). For versions other than Drupal 8, use the i18n (Internationalization) tag on issues which involve or affect multilingual / multinational support. That is preferred over Translation.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India yash.rode pune

    I was trying to work on this, is there any way to reproduce this? I have managed to run the script with APCu on my local.

  • 🇬🇧United Kingdom catch

    @yash.rode you'd need to enable multiple languages on your site, I would think 10-20 would be a good number. And make sure that config is translated.

    Then visit various pages in the different languages so that the config + translations are loaded.

    Then you'd need to adapt msonnabaum's script to check the config cache bin instead of the discovery one.

    Having said that I think rather than the script, you could probably just check what is in the config cache bin in the database table (since cache items get written to both), and that will give you an idea of what's in there, at least to start.

  • 🇮🇳India yash.rode pune

    I added 20+ languages and translated the config for them, following are the results I am getting after running the script.

    Free: 23.23MB
    Total user: 8.56MB
    
    954k  - drupal.class_loader
    6812k - drupal.apcu_backend
    999k  - drupal.file_cache
    
    apcu_backend by prefix:
    
    356k  - discovery:library_info:claro
    304k  - discovery:entity_base_field_definitions:node
    248k  - discovery:entity_bundle_field_definitions:node
    238k  - discovery:entity_base_field_definitions:comment
    235k  - discovery:entity_base_field_definitions:user
    207k  - config:views:view
    187k  - discovery:typed_config_definitions
    175k  - discovery:entity_bundle_field_definitions:comment
    141k  - config:language:hy
    140k  - config:language:hr
    128k  - discovery:entity_type
    118k  - discovery:entity_base_field_definitions:shortcut
    116k  - discovery:local_task_plugins:zh-hant
    115k  - discovery:local_task_plugins:hr
    115k  - discovery:library_info:olivero
    114k  - discovery:local_task_plugins:hy
    114k  - discovery:local_task_plugins:bs
    113k  - discovery:entity_type_definitions:installed
    112k  - discovery:local_task_plugins:zh-hans
    112k  - discovery:local_task_plugins:hi
    112k  - discovery:local_task_plugins:bn
    112k  - discovery:local_task_plugins:eu
    112k  - discovery:local_task_plugins:en
    112k  - discovery:local_task_plugins:az
    112k  - discovery:local_task_plugins:sq
    112k  - discovery:local_task_plugins:ms
    112k  - discovery:local_task_plugins:af
    112k  - discovery:local_task_plugins:bg
    107k  - config:language:zh-hant
    92k   - discovery:ckeditor5_plugins
    80k   - discovery:typed_data_types_plugins
    80k   - config:core:base_field_override
    74k   - discovery:entity_base_field_definitions:menu_link_content
    69k   - discovery:entity_field_storage_definitions:node
    55k   - discovery:entity_base_field_definitions:taxonomy_term
    55k   - discovery:help_topics
    51k   - config:language:bs
    49k   - config:language:bg
    48k   - discovery:entity_bundle_field_definitions:user
    41k   - discovery:entity_base_field_definitions:block_content
    40k   - bootstrap:theme_registry:runtime
    35k   - config:language:az
    35k   - config:language:en
    34k   - discovery:element_info_build:claro
    34k   - config:language:af
    34k   - config:language:bn
    34k   - config:language:sq
    34k   - config:language:eu
    34k   - config:language:ms
    34k   - config:language:hi
    34k   - discovery:element_info_build:olivero
    33k   - discovery:field_types_plugins
    31k   - discovery:entity_base_field_definitions:file
    30k   - config:language:zh-hans
    29k   - discovery:node:field_storage_definitions
    29k   - discovery:menu_link_content:field_storage_definitions
    28k   - config:block:block
    26k   - discovery:validation_constraint_plugins
    26k   - discovery:entity_reference_selection_plugins
    25k   - discovery:block_content:field_storage_definitions
    23k   - discovery:entity_bundle_field_definitions:shortcut
    23k   - discovery:comment:field_storage_definitions
    22k   - discovery:entity_field_storage_definitions:comment
    21k   - discovery:local_action_plugins:zh-hans
    21k   - discovery:local_action_plugins:zh-hant
    21k   - discovery:local_action_plugins:af
    21k   - discovery:local_action_plugins:bs
    21k   - discovery:local_action_plugins:en
    21k   - discovery:local_action_plugins:hi
    21k   - discovery:local_action_plugins:hr
    21k   - discovery:local_action_plugins:hy
    21k   - discovery:user:field_storage_definitions
    21k   - discovery:taxonomy_term:field_storage_definitions
    19k   - config:system:action
    18k   - bootstrap:theme:active_theme
    18k   - discovery:field_formatter_types_plugins
    17k   - discovery:entity_field_map
    17k   - discovery:entity_bundle_extra_fields:node
    17k   - discovery:entity_bundle_extra_fields:comment
    16k   - config:language:entity
    15k   - discovery:contextual_links_plugins:zh-hant
    15k   - discovery:contextual_links_plugins:zh-hans
    15k   - discovery:contextual_links_plugins:hy
    15k   - discovery:contextual_links_plugins:bs
    15k   - discovery:contextual_links_plugins:hr
    15k   - discovery:entity_bundle_field_definitions:block_content
    13k   - discovery:file:field_storage_definitions
    12k   - config:field:field
    12k   - bootstrap:module_implements
    12k   - discovery:contextual_links_plugins:en
    12k   - discovery:contextual_links_plugins:af
    12k   - discovery:contextual_links_plugins:hi
    11k   - discovery:block_plugins
    10k   - discovery:shortcut:field_storage_definitions
    10k   - discovery:path_alias:field_storage_definitions
    10k   - discovery:field_widget_types_plugins
    10k   - discovery:views:field
    10k   - discovery:config_translation_info_plugins:zh-hans
    10k   - discovery:config_translation_info_plugins:zh-hant
    10k   - discovery:config_translation_info_plugins:bs
    10k   - discovery:config_translation_info_plugins:hr
    10k   - discovery:config_translation_info_plugins:hy
    10k   - discovery:entity_field_storage_definitions:user
    9k    - config:language:content_settings
    9k    - discovery:views:row
    9k    - discovery:element_info
    9k    - discovery:entity_base_field_definitions:contact_message
    9k    - discovery:contact_message:field_storage_definitions
    9k    - discovery:entity_base_field_definitions:path_alias
    9k    - config:core:entity_view_mode
    8k    - discovery:entity_bundle_info:zh-hans
    8k    - discovery:entity_bundle_info:zh-hant
    8k    - discovery:entity_bundle_info:af
    8k    - discovery:entity_bundle_info:hi
    8k    - discovery:entity_bundle_info:ms
    8k    - discovery:entity_bundle_info:sq
    8k    - discovery:entity_bundle_info:az
    8k    - discovery:entity_bundle_info:bg
    8k    - discovery:entity_bundle_info:bn
    8k    - discovery:entity_bundle_info:bs
    8k    - discovery:entity_bundle_info:eu
    8k    - discovery:entity_bundle_info:hr
    8k    - discovery:entity_bundle_info:hy
    8k    - discovery:entity_bundle_info:en
    8k    - discovery:condition_plugins
    8k    - config:field:storage
    7k    - discovery:views:style
    7k    - discovery:views:display
    7k    - discovery:filter_plugins
    6k    - discovery:views:filter
    6k    - config:filter:format
    6k    - discovery:language_negotiation_plugins
    5k    - config:core:entity_form_display
    5k    - config:editor:editor
    5k    - config:user:role
    5k    - config:core:date_format
    5k    - discovery:entity_view_mode_info:zh-hant
    5k    - discovery:entity_view_mode_info:af
    5k    - discovery:entity_view_mode_info:az
    5k    - discovery:entity_view_mode_info:bg
    5k    - discovery:entity_view_mode_info:bn
    5k    - discovery:entity_view_mode_info:bs
    5k    - discovery:entity_view_mode_info:en
    5k    - discovery:entity_view_mode_info:eu
    5k    - discovery:entity_view_mode_info:hi
    5k    - discovery:entity_view_mode_info:hr
    5k    - discovery:entity_view_mode_info:hy
    5k    - discovery:entity_view_mode_info:ms
    5k    - discovery:entity_view_mode_info:sq
    4k    - bootstrap:routing:non_admin_routes
    4k    - config:system:menu
    4k    - discovery:breakpoints
    3k    - discovery:entity_field_storage_definitions:block_content
    3k    - config:core:entity_view_display
    3k    - discovery:views:pager
    3k    - bootstrap:hook_info
    3k    - config:search:page
    2k    - discovery:views:area
    2k    - discovery:help_section_plugins
    2k    - discovery:views:access
    2k    - discovery:views:cache
    2k    - config:node:type
    2k    - config:language:ast
    2k    - config:language:my
    2k    - config:language:br
    2k    - config:language:be
    2k    - config:language:am
    2k    - config:language:ar
    2k    - config:language:ca
    2k    - config:contact:form
    2k    - discovery:views:exposed_form
    2k    - config:views:settings
    2k    - config:block_content:type
    1k    - config:core:extension
    1k    - config:system:theme
    1k    - config:language:negotiation
    1k    - discovery:views:relationship
    1k    - discovery:search_plugins
    1k    - discovery:breakpoints:toolbar
    1k    - discovery:entity_field_storage_definitions:taxonomy_term
    1k    - discovery:variant_plugins
    1k    - config:locale:settings
    1k    - config:system:performance
    1k    - discovery:entity_field_storage_definitions:file
    1k    - config:user:settings
    1k    - discovery:views:query
    1k    - bootstrap:path_alias_whitelist
    1k    - config:language:types
    0.9k  - discovery:views:join
    0.9k  - config:olivero:settings
    0.9k  - discovery:entity_form_mode_info:zh-hant
    0.9k  - discovery:entity_form_mode_info:hr
    0.9k  - discovery:entity_form_mode_info:hy
    0.9k  - config:search:settings
    0.9k  - discovery:editor_plugins
    0.9k  - config:core:entity_form_mode
    0.9k  - config:system:site
    0.8k  - config:taxonomy:vocabulary
    0.8k  - config:comment:type
    0.8k  - discovery:queue_plugins
    0.8k  - config:language:mappings
    0.8k  - config:update:settings
    0.8k  - discovery:image_toolkit_plugins
    0.7k  - config:core:menu
    0.7k  - config:shortcut:set
    0.7k  - config:system:date
    0.6k  - config:system:cron
    0.6k  - config:taxonomy:settings
    0.6k  - config:system:file
    0.6k  - config:filter:settings
    0.6k  - config:system:advisories
    0.6k  - config:automated_cron:settings
    0.6k  - config:comment:settings
    0.6k  - config:system:feature_flags
    0.6k  - bootstrap:user_permissions_hash:anonymous
    0.6k  - config:system:logging
    0.6k  - config:field:settings
    0.6k  - config:dblog:settings
    0.6k  - config:node:settings
    0.5k  - config:system:image
    0.5k  - discovery:entity_field_storage_definitions:path_alias
    0.5k  - config:claro:settings
  • 🇮🇳India yash.rode pune

    Results without no translations:

    Free: 25.08MB
    Total user: 6.63MB

    2262k - drupal.class_loader
    3261k - drupal.apcu_backend
    1262k - drupal.file_cache

    apcu_backend by prefix:

    207k - config:views:view
    188k - discovery:typed_config_definitions
    130k - discovery:local_task_plugins:en
    126k - discovery:library_info:claro
    126k - config:language:en
    125k - discovery:entity_type
    116k - discovery:local_task_plugins:gl
    115k - discovery:local_task_plugins:eu
    111k - discovery:entity_type_definitions:installed
    110k - discovery:library_info:olivero
    96k - discovery:ckeditor5_plugins
    80k - discovery:typed_data_types_plugins
    63k - discovery:entity_base_field_definitions:node
    61k - config:language:ast
    60k - config:language:af
    60k - bootstrap:theme_registry:runtime
    57k - config:core:base_field_override
    55k - discovery:entity_base_field_definitions:comment
    54k - config:language:gl
    54k - discovery:help_topics
    50k - discovery:entity_base_field_definitions:user
    49k - discovery:entity_base_field_definitions:menu_link_content
    46k - config:language:eu
    37k - discovery:entity_base_field_definitions:taxonomy_term
    34k - discovery:element_info_build:claro
    34k - discovery:element_info_build:olivero
    34k - discovery:field_types_plugins
    29k - discovery:menu_link_content:field_storage_definitions
    27k - config:block:block
    27k - discovery:node:field_storage_definitions
    26k - discovery:validation_constraint_plugins
    25k - discovery:entity_base_field_definitions:shortcut
    25k - discovery:entity_reference_selection_plugins
    23k - discovery:entity_bundle_field_definitions:node
    23k - discovery:comment:field_storage_definitions
    21k - discovery:local_action_plugins:en
    21k - discovery:local_action_plugins:eu
    21k - discovery:local_action_plugins:gl
    21k - discovery:user:field_storage_definitions
    21k - discovery:taxonomy_term:field_storage_definitions
    21k - discovery:entity_base_field_definitions:file
    20k - discovery:block_content:field_storage_definitions
    20k - bootstrap:theme:active_theme
    20k - bootstrap:module_implements
    20k - config:core:entity_view_display
    19k - config:system:action
    18k - discovery:field_formatter_types_plugins
    17k - config:core:entity_form_display
    16k - discovery:entity_base_field_definitions:block_content
    16k - discovery:entity_field_map
    16k - discovery:entity_field_storage_definitions:node
    14k - discovery:contextual_links_plugins:en
    13k - config:field:field
    13k - discovery:file:field_storage_definitions
    12k - discovery:contextual_links_plugins:gl
    11k - discovery:block_plugins
    10k - config:field:storage
    10k - discovery:shortcut:field_storage_definitions
    10k - discovery:path_alias:field_storage_definitions
    10k - discovery:field_widget_types_plugins
    10k - discovery:views:field
    10k - discovery:config_translation_info_plugins:en
    9k - config:core:date_format
    9k - discovery:views:row
    9k - discovery:element_info
    9k - discovery:entity_base_field_definitions:contact_message
    9k - discovery:contact_message:field_storage_definitions
    9k - config:core:entity_view_mode
    9k - discovery:entity_base_field_definitions:path_alias
    9k - discovery:entity_bundle_field_definitions:comment
    8k - discovery:condition_plugins
    8k - discovery:entity_bundle_info:eu
    8k - discovery:entity_bundle_info:gl
    8k - discovery:entity_bundle_info:en
    8k - discovery:entity_extra_field_info:eu
    8k - discovery:entity_extra_field_info:gl
    7k - discovery:entity_extra_field_info:en
    7k - config:language:entity
    7k - discovery:views:style
    7k - discovery:entity_bundle_field_definitions:user
    7k - discovery:views:display
    7k - discovery:filter_plugins
    6k - discovery:views:filter
    6k - config:filter:format
    6k - discovery:language_negotiation_plugins
    6k - discovery:entity_field_storage_definitions:user
    6k - config:image:style
    5k - config:language:content_settings
    5k - discovery:image_toolkit_operation_plugins
    5k - config:editor:editor
    5k - config:user:role
    5k - discovery:entity_field_storage_definitions:comment
    5k - discovery:entity_view_mode_info:en
    5k - discovery:entity_view_mode_info:eu
    5k - discovery:entity_view_mode_info:gl
    4k - config:user:mail
    4k - discovery:image_effect_plugins
    4k - bootstrap:routing:non_admin_routes
    4k - config:system:menu
    4k - discovery:breakpoints
    3k - config:language:bs
    3k - discovery:views:pager
    3k - config:language:ca
    3k - bootstrap:hook_info
    3k - config:tour:tour
    3k - config:search:page
    2k - discovery:views:area
    2k - config:language:pl
    2k - config:media:type
    2k - discovery:views:access
    2k - discovery:views:cache
    2k - discovery:entity_bundle_field_definitions:block_content
    2k - config:node:type
    2k - config:contact:form
    2k - discovery:entity_field_storage_definitions:block_content
    2k - discovery:entity_bundle_field_definitions:shortcut
    2k - discovery:views:exposed_form
    2k - discovery:help_section_plugins
    2k - config:views:settings
    1k - config:core:extension
    1k - config:system:theme
    1k - discovery:views:relationship
    1k - discovery:search_plugins
    1k - discovery:breakpoints:toolbar
    1k - discovery:views:join
    1k - config:system:image
    1k - discovery:variant_plugins
    1k - config:locale:settings
    1k - config:system:performance
    1k - discovery:entity_bundle_field_definitions:file
    1k - discovery:entity_field_storage_definitions:file
    1k - config:user:settings
    1k - discovery:views:query
    1k - bootstrap:path_alias_whitelist
    1k - config:language:types
    0.9k - config:olivero:settings
    0.9k - config:responsive_image:styles
    0.9k - config:file:settings
    0.9k - discovery:entity_form_mode_info:en
    0.9k - config:search:settings
    0.9k - discovery:editor_plugins
    0.9k - config:core:entity_form_mode
    0.9k - config:system:site
    0.8k - config:language:negotiation
    0.8k - config:taxonomy:vocabulary
    0.8k - config:comment:type
    0.8k - config:block_content:type
    0.8k - config:language:mappings
    0.8k - config:update:settings
    0.8k - discovery:image_toolkit_plugins
    0.7k - config:core:menu
    0.7k - config:shortcut:set
    0.7k - config:system:date
    0.7k - config:system:maintenance
    0.7k - config:contact:settings
    0.7k - config:image:settings
    0.6k - config:system:cron
    0.6k - config:user:flood
    0.6k - config:taxonomy:settings
    0.6k - config:system:file
    0.6k - config:filter:settings
    0.6k - config:system:diff
    0.6k - config:system:advisories
    0.6k - config:menu_ui:settings
    0.6k - config:system:mail
    0.6k - config:field_ui:settings
    0.6k - config:system:rss
    0.6k - config:automated_cron:settings
    0.6k - bootstrap:user_permissions_hash:anonymous
    0.6k - config:comment:settings
    0.6k - config:system:feature_flags
    0.6k - config:system:logging
    0.6k - config:text:settings
    0.6k - config:dblog:settings
    0.6k - config:field:settings
    0.6k - config:node:settings
    0.5k - discovery:entity_field_storage_definitions:menu_link_content
    0.5k - discovery:entity_field_storage_definitions:taxonomy_term
    0.5k - discovery:entity_field_storage_definitions:contact_message
    0.5k - discovery:entity_field_storage_definitions:path_alias
    0.5k - discovery:entity_field_storage_definitions:shortcut
    0.5k - config:claro:settings
    0.5k - config:workflows:workflow

Production build 0.71.5 2024