Antipatrón: almacena datos de más de 256 KB en la memoria caché
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Estás viendo la documentación de Apigee y Apigee Hybrid.
Consulta la documentación de Apigee Edge.
Apigee proporciona la capacidad de almacenar datos en una caché en el entorno de ejecución para una persistencia y una recuperación más rápida.
En un principio, los datos se almacenan en la caché de la memoria del Message Processor, denominada caché L1.
La caché L1 está limitada por la cantidad de memoria reservada para ella como un porcentaje de la memoria JVM.
Las entradas almacenadas en caché se conservan más adelante en la caché L2, a la que todos los Message Processor pueden acceder. Encontrarás más detalles en la siguiente sección.
La caché L2 no tiene ningún límite estricto para la cantidad de entradas de caché. Sin embargo, el tamaño máximo para las entradas que se puede almacenar en caché está restringido a 256 KB.
256 KB es el tamaño de caché recomendado para un rendimiento óptimo.
Antipatrón
Este antipatrón en particular aborda las consecuencias de superar las restricciones actuales del tamaño de la caché en Apigee.
Cuando se almacenan en caché datos superiores a 256 KB, las consecuencias se ven de la siguiente manera:
Las solicitudes a la API que se ejecuten por primera vez en cada uno de los procesadores de mensajes deben obtener los datos de manera independiente de la fuente original (política o servidor de destino), ya que las entradas mayores a 256 KB no están disponibles en L2 caché.
Almacenar datos de mayor tamaño (> 256 KB) en la caché L1 tiende a agregar más estrés a los recursos de la plataforma. Como resultado, la memoria caché L1 se llena más rápido y, por lo tanto, hay menos espacio disponible para otros datos. Como consecuencia, no se podrá almacenar en caché los datos de forma tan agresiva como lo haría.
Las entradas almacenadas en caché de los Message Processors se quitarán cuando se alcance el límite de entradas. Esto hace que los datos se recuperen desde la fuente original nuevamente en los respectivos Message Processors.
Impacto
Los datos de tamaño > a 256 KB no se almacenarán en la caché L2/persistente.
Las llamadas más frecuentes a la fuente original (ya sea una política o un servidor de destino) generan mayores latencias para las solicitudes a la API.
Práctica recomendada
Es preferible almacenar datos de tamaño menor a 256 KB en caché para obtener un rendimiento óptimo.
Si necesitas almacenar datos de más de 256 KB, considera hacer lo siguiente:
Usar cualquier base de datos apropiada para almacenar datos grandes
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-04 (UTC)"],[[["\u003cp\u003eApigee uses a two-tiered caching system (L1 and L2) to store data for persistence and faster retrieval, with L1 being an in-memory cache and L2 being a persistent cache accessible to all Message Processors.\u003c/p\u003e\n"],["\u003cp\u003eThe L2 cache has a size limit of 256 KB per entry for optimal performance, and exceeding this limit results in the data not being stored in L2.\u003c/p\u003e\n"],["\u003cp\u003eCaching data larger than 256 KB causes API requests to fetch data independently from the original source on each Message Processor, and it also stresses the L1 cache, leading to less space available for other data.\u003c/p\u003e\n"],["\u003cp\u003eStoring data under 256 KB is the preferred practice for optimal caching performance, and for data exceeding this size, consider using a database or compressing the data.\u003c/p\u003e\n"],["\u003cp\u003eExceeding the cache size limit increases the frequency of calls to the original source and results in higher API request latency.\u003c/p\u003e\n"]]],[],null,["# Antipattern: Store data greater than 256 KB size in cache\n\n*You're viewing **Apigee** and **Apigee hybrid** documentation.\nView [Apigee Edge](https://docs.apigee.com/api-platform/antipatterns/caching-large) documentation.*\n\nApigee provides the ability to store data in a cache at runtime for persistence and faster\nretrieval.\n\n- The data is initially stored in the Message Processor's in-memory cache, referred to as *L1\n cache*.\n- The L1 cache is limited by the amount of memory reserved for it as a percentage of the JVM memory.\n- The cached entries are later persisted in *L2 cache*, which is accessible to all Message Processors. More details can be found in the section below.\n- The L2 cache does not have any hard limit on the number of cache entries, however the maximum *size* of the entry that can be cached is restricted to 256 KB. The cache size of 256 KB is the recommended size for optimal performance.\n\nAntipattern\n-----------\n\nThis particular antipattern talks about the implications of exceeding the current cache size\nrestrictions within Apigee.\n\nWhen data \\\u003e 256 KB is cached, the consequences are as follows:\n\n- API requests executed for the first time on each of the Message Processors need to get the data independently from the original source (policy or a target server), as entries \\\u003e 256 KB are not available in L2 cache.\n- Storing larger data (\\\u003e 256 KB) in L1 cache tends to put more stress on the platform resources. It results in the L1 cache memory being filled up faster and hence lesser space being available for other data. As a consequence, one will not be able to cache the data as aggressively as one would like to.\n- Cached entries from the Message Processors will be removed when the limit on the number of entries is reached. This causes the data to be fetched from the original source again on the respective Message Processors.\n\nImpact\n------\n\n- Data of size \\\u003e 256 KB will not be stored in L2/persistent cache.\n- More frequent calls to the original source (either a policy or a target server) leads to increased latencies for the API requests.\n\nBest practice\n-------------\n\n- It is preferred to store data of size \\\u003c 256 KB in cache to get optimum performance.\n- If there's a need to store data \\\u003e 256 KB, then consider:\n - Using any appropriate database for storing large data **OR**\n\n - Compressing the data\n\nFurther reading\n---------------\n\n- [Cache internals](/apigee/docs/api-platform/cache/cache-internals)"]]