zoukankan      html  css  js  c++  java
  • org.apache.catalina.webresources.Cache.backgroundProcess The background cache eviction process was unable to free [10] percent of the cache for Context [/filestore]

    需要耐心啊,太急于求成,希望直接就得到解决方法了...以至于正确方法都已经出现了,我却没有耐心看下去,所以反而又耽误了不少时间....

    项目加载100+张图片,还有一个小的MP4,所以console警告缓存不够

    org.apache.catalina.webresources.Cache.getResource Unable to add the resource at [/base/1325/WA6144-150x112.jpg] to the cache because there was insufficient free space available after evicting expired cache entries - consider increasing the maximum size of the cache
    
    The background cache eviction process was unable to free [10] percent of the cache for Context [/liuda] - consider increasing the maximum size of the cache. After eviction approximately [11,145] KB of data remained in the cache
    

    反正就是缓存不够了

    http://stackoverflow.com/questions/26893297/tomcat-8-throwing-org-apache-catalina-webresources-cache-getresource-unable-to

    上面链接是stackoverflow上出现的和我一样的错误,第二个答案成功的解决了这个警告,就是把缓存弄大点。一开始没耐心看答案,直接把代码加进server.xml了,正确的应该是加到context.xml

    <Resources cachingAllowed="true" cacheMaxSize="100000" />
    

    作者:我比风更自由
    来源:CSDN
    原文:https://blog.csdn.net/qq_26684469/article/details/52346667
    版权声明:本文为博主原创文章,转载请附上博文链接!

    背景资料

    一个WebSource是在Web应用程序中的文件或目录。出于性能原因,Tomcat可以缓存WebSource。默认情况下,静态资源缓存(总共所有资源)的最大值为 10240千字节(10 MB)。在请求webResource时(例如,在加载静态图像时),webResource被加载到缓存中,然后将其称为缓存条目。每个缓存条目都有一个TTL(生存时间),这是允许缓存条目保留在缓存中的时间。当TTL过期时,缓存条目有资格从缓存中删除。cacheTTL的默认值为5000毫秒(5秒)。

    加载webResource时,代码会计算缓存的新大小。如果计算的大小大于默认的最大大小,则必须删除一个或多个缓存的条目,否则新大小将超过最大值。因此代码将计算“targetSize”,这是缓存希望保持的大小(作为最佳值),默认情况下为95%。为了达到此targetSize,必须从缓存中删除/逐出条目。

    因此,当其TTL过期且尚未达到targetSize时,将删除缓存条目。

    在尝试通过逐出缓存条目来释放缓存之后

    因此,如果在尝试释放缓存后,大小仍然超过最大值,它将显示有关无法释放的警告消息:

    cache.addFail=Unable to add the resource at [{0}] to the cache for web application [{1}] because there was insufficient free space available after evicting expired cache entries - consider increasing the maximum size of the cache
    

    问题

    因此,正如警告信息所述,问题是

    insufficient free space available after evicting expired cache entries - consider increasing the maximum size of the cache
    

    如果您的Web应用程序在短时间(5秒)内加载了大量未缓存的webResources(大约最大缓存,默认为10mb),那么您将收到警告。

    当Tomcat 7无法释放缓存时,它根本不会输出任何警告,而Tomcat 8将输出警告。

    因此,如果您使用的Tomcat 8具有与Tomcat 7相同的默认缓存配置,并且您在Tomcat 8中收到警告,那么Tomcat 7的(和我的)缓存设置在没有警告的情况下表现不佳。

    解决方案

    有多种解决方案:

    • 增加缓存(推荐)
    • 降低TTL(不推荐)
    • 禁止缓存日志警告(不推荐)
    • 禁用缓存

    通过在Context元素中添加$CATALINA_BASE/conf/context.xml“XXXXX”代表增加的高速缓存大小,以kbytes为单位。默认值为10240(10 MB),因此请设置大于此值的大小。

    <Resources cacheMaxSize="XXXXX" />
    

    您必须调整以获得最佳设置。请注意,当您突然增加流量/资源请求时,问题可能会再次出现。

  • 相关阅读:
    B.Icebound and Sequence
    Educational Codeforces Round 65 (Rated for Div. 2) D. Bicolored RBS
    Educational Codeforces Round 65 (Rated for Div. 2) C. News Distribution
    Educational Codeforces Round 65 (Rated for Div. 2) B. Lost Numbers
    Educational Codeforces Round 65 (Rated for Div. 2) A. Telephone Number
    Codeforces Round #561 (Div. 2) C. A Tale of Two Lands
    Codeforces Round #561 (Div. 2) B. All the Vowels Please
    Codeforces Round #561 (Div. 2) A. Silent Classroom
    HDU-2119-Matrix(最大匹配)
    读书的感想!
  • 原文地址:https://www.cnblogs.com/miye/p/10042859.html
Copyright © 2011-2022 走看看