Antipadrão: armazene dados com tamanho superior a 256 KB no cache
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Esta é a documentação da Apigee e da Apigee híbrida.
Confira a documentação da Apigee Edge.
A Apigee permite armazenar dados em um cache no ambiente de execução para persistência e recuperação
mais rápida.
Os dados são inicialmente armazenados no cache da memória do processador de mensagens, chamado de cache
L1.
O cache L1 é limitado pela quantidade de memória reservada para ela como uma porcentagem da memória
JVM.
As entradas em cache são mantidas mais tarde no cache de L2, que pode ser acessado por todos os processadores de
mensagens. Veja mais detalhes na seção abaixo.
O cache L2 não tem limite absoluto sobre o número de entradas de cache, mas o
tamanho máximo da entrada que pode ser armazenado em cache é restrito a 256 KB.
O tamanho de cache de 256 KB é o
tamanho recomendado para desempenho ideal.
Antipadrão
Este antipadrão específico fala sobre as implicações de exceder as restrições de tamanho de
cache atuais na Apigee.
Quando dados maiores que 256 KB são armazenados em cache, as consequências são as seguintes:
As solicitações de API executadas pela primeira vez em cada um dos processadores de mensagens precisam receber os
dados independentemente da origem (política ou servidor de destino), já que entradas maiores que
256 KB
não estão disponíveis em no cache L2.
O armazenamento de dados maiores (maiores de 256 KB) no cache L1 tende a colocar mais estresse nos recursos da
plataforma. Isso faz com que a memória do cache L1 seja preenchida mais rapidamente e, portanto, menos espaço está
disponível para outros dados. Como consequência, não será possível armazenar os dados em cache da
maneira mais agressiva que eles gostariam.
As entradas em cache dos Processadores de mensagens serão removidas quando o limite de
entradas for atingido. Isso faz com que os dados sejam buscados novamente a partir da origem nos
respectivos processadores de mensagem.
Impacto
Os dados de tamanho maiores que 256 KB não serão armazenados no cache L2/permanente.
Chamadas mais frequentes da origem (uma política ou um servidor de destino) levam a
uma maior latência para as solicitações da API.
Prática recomendada
É preferível armazenar dados de tamanho inferior a 256 KB no cache para ter o desempenho ideal.
Se for necessário armazenar dados com tamanho superior a 256 KB, considere:
Usar qualquer banco de dados apropriado para armazenar dados grandes
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 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)"]]