- 浏览: 2550685 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Page Cache(I)ehcache
1. Theory
user -----> page -----> filter ----> action ----> service ----> dao -------> database
2. Configuration changes
timeToIdleSeconds no requests for a time, ehcache will delete the cache data.
timeToLiveSeconds cache live time from the creatation time
<cache name="SimplePageCachingFilter"
maxElementsInMemory="10"
maxElementsOnDisk="10"
eternal="false"
overflowToDisk="true"
diskSpoolBufferSizeMB="20"
timeToIdleSeconds="900"
timeToLiveSeconds="900"
memoryStoreEvictionPolicy="LFU"
/>
LFU will erase the data by the hits of the requests.
<filter>
<filter-name>IndexCacheFilter</filter-name>
<filter-class>
net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter
</filter-class>
<init-param>
<param-name>cacheName</param-name>
<param-value>SimplePageCachingFilter</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>IndexCacheFilter</filter-name>
<url-pattern>/index.do</url-pattern>
</filter-mapping>
cache policy
FIFO first in first out
LFU less frequently used
LRU least recently used
3. Problems and Solutions
But get error messages:
2011-07-07 22:44:04,716 ERROR [net.xxxx.app.utils.Utility] (Timer-2) Exception while evicting elements
java.lang.NullPointerException
at net.xxxx.app.utils.Utility.evictExpiredElements(Utility.java:2241)
at org.jboss.scheduler30ss.EhCacheEvictScheduler.perform(EhCacheEvictScheduler.java:37)
at org.jboss.varia.scheduler.Scheduler$Listener.handleNotification(Scheduler.java:1251)
at sun.reflect.GeneratedMethodAccessor207.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.jboss.mx.notification.NotificationListenerProxy.invoke(NotificationListenerProxy.java:153)
at $Proxy316.handleNotification(Unknown Source)
at javax.management.NotificationBroadcasterSupport.handleNotification(NotificationBroadcasterSupport.java:274)
at javax.management.NotificationBroadcasterSupport$SendNotifJob.run(NotificationBroadcasterSupport.java:339)
at javax.management.NotificationBroadcasterSupport$1.execute(NotificationBroadcasterSupport.java:324)
at javax.management.NotificationBroadcasterSupport.sendNotification(NotificationBroadcasterSupport.java:247)
at javax.management.timer.Timer.sendNotification(Timer.java:1247)
at javax.management.timer.Timer.notifyAlarmClock(Timer.java:1209)
at javax.management.timer.TimerAlarmClock.run(Timer.java:1298)
at java.util.TimerThread.mainLoop(Timer.java:534)
at java.util.TimerThread.run(Timer.java:484)
Caused by: net.sf.ehcache.CacheException: Error configuring from /home/luohua/tools/jboss/30ss/ehcache.xml.
Initial cause was Error configuring from input stream. Initial cause was null:509:
Element <cache> does not allow attribute "momoryStoreEvictionPolicy".
Solution:
This is my project problem. My project already use ehcache in the system.
It will create the CacheManager from a configuration file this way:
cm = CacheManager.create(configuration_file_directory + "/ehcache.xml");
That is the problem. So I will customized the filter class like this CustomerSimplePageCachingFilter.java:
package com.xxxxx.web.filter;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter;
import net.xxx.xxxx.utils.Utility;
public class CustomerSimplePageCachingFilter extends SimplePageCachingFilter {
protected CacheManager getCacheManager() {
return Utility.getCacheManager();
}
}
Performance Test
>ab -n 1000 -c 50 http://localhost:8080/project/index.do >> log1.txt
>ab -n 1000 -c 50 http://localhost:8080/project/index.do >> log2.txt
error message:
apr_poll: The timeout specified has expired (70007)
solution:
This a bug from ab maybe, I just change the -n to a small number.
The comparation of the test results log1.txt:
Concurrency Level: 50
Time taken for tests: 84.977 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 3444000 bytes
HTML transferred: 3055000 bytes
Requests per second: 11.77 [#/sec] (mean)
Time per request: 4248.845 [ms] (mean)
Time per request: 84.977 [ms] (mean, across all concurrent requests)
Transfer rate: 39.58 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 1.3 0 8
Processing: 2179 4201 704.5 4095 8009
Waiting: 2178 4201 704.5 4095 8009
Total: 2181 4201 704.5 4095 8009
Percentage of the requests served within a certain time (ms)
50% 4095
66% 4286
75% 4425
80% 4531
90% 4960
95% 5591
98% 6454
99% 6950
100% 8009 (longest request)
log2.txt:
Concurrency Level: 50
Time taken for tests: 0.709 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 3218000 bytes
HTML transferred: 2975000 bytes
Requests per second: 1410.30 [#/sec] (mean)
Time per request: 35.453 [ms] (mean)
Time per request: 0.709 [ms] (mean, across all concurrent requests)
Transfer rate: 4431.98 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.6 0 3
Processing: 1 34 22.3 30 181
Waiting: 1 34 22.2 30 165
Total: 2 34 22.7 30 184
Percentage of the requests served within a certain time (ms)
50% 30
66% 37
75% 41
80% 43
90% 56
95% 75
98% 87
99% 159
100% 184 (longest request)
references:
http://ahuaxuan.iteye.com/blog/128458
http://wiki.springside.org.cn/display/calvin/Ehcache
http://hi.baidu.com/luohuazju/blog/item/b9ac3e51803fe7858d543026.html
http://ehcache.org/documentation/samples.html#Cache_Server_Examples
1. Theory
user -----> page -----> filter ----> action ----> service ----> dao -------> database
2. Configuration changes
timeToIdleSeconds no requests for a time, ehcache will delete the cache data.
timeToLiveSeconds cache live time from the creatation time
<cache name="SimplePageCachingFilter"
maxElementsInMemory="10"
maxElementsOnDisk="10"
eternal="false"
overflowToDisk="true"
diskSpoolBufferSizeMB="20"
timeToIdleSeconds="900"
timeToLiveSeconds="900"
memoryStoreEvictionPolicy="LFU"
/>
LFU will erase the data by the hits of the requests.
<filter>
<filter-name>IndexCacheFilter</filter-name>
<filter-class>
net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter
</filter-class>
<init-param>
<param-name>cacheName</param-name>
<param-value>SimplePageCachingFilter</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>IndexCacheFilter</filter-name>
<url-pattern>/index.do</url-pattern>
</filter-mapping>
cache policy
FIFO first in first out
LFU less frequently used
LRU least recently used
3. Problems and Solutions
But get error messages:
2011-07-07 22:44:04,716 ERROR [net.xxxx.app.utils.Utility] (Timer-2) Exception while evicting elements
java.lang.NullPointerException
at net.xxxx.app.utils.Utility.evictExpiredElements(Utility.java:2241)
at org.jboss.scheduler30ss.EhCacheEvictScheduler.perform(EhCacheEvictScheduler.java:37)
at org.jboss.varia.scheduler.Scheduler$Listener.handleNotification(Scheduler.java:1251)
at sun.reflect.GeneratedMethodAccessor207.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.jboss.mx.notification.NotificationListenerProxy.invoke(NotificationListenerProxy.java:153)
at $Proxy316.handleNotification(Unknown Source)
at javax.management.NotificationBroadcasterSupport.handleNotification(NotificationBroadcasterSupport.java:274)
at javax.management.NotificationBroadcasterSupport$SendNotifJob.run(NotificationBroadcasterSupport.java:339)
at javax.management.NotificationBroadcasterSupport$1.execute(NotificationBroadcasterSupport.java:324)
at javax.management.NotificationBroadcasterSupport.sendNotification(NotificationBroadcasterSupport.java:247)
at javax.management.timer.Timer.sendNotification(Timer.java:1247)
at javax.management.timer.Timer.notifyAlarmClock(Timer.java:1209)
at javax.management.timer.TimerAlarmClock.run(Timer.java:1298)
at java.util.TimerThread.mainLoop(Timer.java:534)
at java.util.TimerThread.run(Timer.java:484)
Caused by: net.sf.ehcache.CacheException: Error configuring from /home/luohua/tools/jboss/30ss/ehcache.xml.
Initial cause was Error configuring from input stream. Initial cause was null:509:
Element <cache> does not allow attribute "momoryStoreEvictionPolicy".
Solution:
This is my project problem. My project already use ehcache in the system.
It will create the CacheManager from a configuration file this way:
cm = CacheManager.create(configuration_file_directory + "/ehcache.xml");
That is the problem. So I will customized the filter class like this CustomerSimplePageCachingFilter.java:
package com.xxxxx.web.filter;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter;
import net.xxx.xxxx.utils.Utility;
public class CustomerSimplePageCachingFilter extends SimplePageCachingFilter {
protected CacheManager getCacheManager() {
return Utility.getCacheManager();
}
}
Performance Test
>ab -n 1000 -c 50 http://localhost:8080/project/index.do >> log1.txt
>ab -n 1000 -c 50 http://localhost:8080/project/index.do >> log2.txt
error message:
apr_poll: The timeout specified has expired (70007)
solution:
This a bug from ab maybe, I just change the -n to a small number.
The comparation of the test results log1.txt:
Concurrency Level: 50
Time taken for tests: 84.977 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 3444000 bytes
HTML transferred: 3055000 bytes
Requests per second: 11.77 [#/sec] (mean)
Time per request: 4248.845 [ms] (mean)
Time per request: 84.977 [ms] (mean, across all concurrent requests)
Transfer rate: 39.58 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 1.3 0 8
Processing: 2179 4201 704.5 4095 8009
Waiting: 2178 4201 704.5 4095 8009
Total: 2181 4201 704.5 4095 8009
Percentage of the requests served within a certain time (ms)
50% 4095
66% 4286
75% 4425
80% 4531
90% 4960
95% 5591
98% 6454
99% 6950
100% 8009 (longest request)
log2.txt:
Concurrency Level: 50
Time taken for tests: 0.709 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 3218000 bytes
HTML transferred: 2975000 bytes
Requests per second: 1410.30 [#/sec] (mean)
Time per request: 35.453 [ms] (mean)
Time per request: 0.709 [ms] (mean, across all concurrent requests)
Transfer rate: 4431.98 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.6 0 3
Processing: 1 34 22.3 30 181
Waiting: 1 34 22.2 30 165
Total: 2 34 22.7 30 184
Percentage of the requests served within a certain time (ms)
50% 30
66% 37
75% 41
80% 43
90% 56
95% 75
98% 87
99% 159
100% 184 (longest request)
references:
http://ahuaxuan.iteye.com/blog/128458
http://wiki.springside.org.cn/display/calvin/Ehcache
http://hi.baidu.com/luohuazju/blog/item/b9ac3e51803fe7858d543026.html
http://ehcache.org/documentation/samples.html#Cache_Server_Examples
发表评论
-
Stop Update Here
2020-04-28 09:00 314I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 474NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 367Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 367Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 335Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 429Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 434Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 373Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 453VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 384Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 475NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 421Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 336Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 246GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 450GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 325GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 312Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 317Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 291Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 310Serverless with NodeJS and Tenc ...
相关推荐
当`getPage`方法被调用时,如果`pageCache`中存在相同键的缓存,则直接返回,否则执行方法并将其结果存入缓存。 对于页面局部缓存,你可以使用相同的方式,只需为不同的部分创建不同的缓存名称,并在需要的地方应用...
解决web.xml中 <page-encoding>UTF-8</page-encoding>报错。错误提示: cvc-complex-type.2.4.a: Invalid content was found starting with element 'page-encoding'. One of '{"http:// java.sun....
接下来,我们将缓存集成到Web应用中,通常是在`page-filter-action-service-dao-db`架构中。页面缓存的理想位置是靠近客户端,即在`filter`层。当第一个用户请求页面后,页面被缓存。后续用户请求时,过滤器可以直接...
<cache alias="pageCache"> <key-type>java.lang.String <value-type>java.lang.String <heap unit="MB">5 <offheap unit="MB">10 </cache> ``` 然后,在Spring MVC项目中,我们需要创建一个自定义的...
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory ``` 接着,为了使特定的实体类使用二级缓存,我们需要在实体类上添加`@Cacheable`和`@Cache`注解: ``...
用 EL 表达式获取到参数中的 page,并作为缓存的 key,使用 @Cacheable 添加到 Ehcache 的缓存中。这时候,在缓存中就会出现 listOfTask_1 , listOfTask_2 , listOfTask_3 这种类型的 key。 当添加、删除任务时,...
- **操作系统磁盘缓存**:操作系统自动管理的Disk Cache,如Windows的虚拟内存和Linux的Page Cache。 - **数据库缓存**:数据库管理系统内部的缓存机制,如MySQL的Query Cache和Data Buffer。 - **应用程序缓存**:...
3. 在 index.jsp 页面中添加中文支持的标签,例如:<%@ page contentType="text/html;charset=gb2312" isELIgnored="false"%> 四、设置中文支持 在 MyEclipse 中,可以改变默认的编码方式,例如将 encoding 项目...
9. **性能优化**:为了提高性能,可以使用缓存技术,如Spring的Cache或Ehcache,来缓存查询结果,减少不必要的数据库访问。 10. **错误和异常处理**:在处理分页请求时,应考虑可能出现的错误情况,如非法的页码值...
例如,Ehcache 可以通过 `cacheManager.getCache().removeAll()` 来清除所有缓存项。 总之,清空JSP的缓存涉及到客户端和服务器端的不同层面,理解这些机制有助于我们在开发过程中快速解决因缓存导致的问题。在实际...
为了提高性能,菜单数据可以缓存在内存中,比如使用Spring Cache或者Ehcache。当菜单数据发生更改时,更新缓存内容。 综上所述,JSP动态数据菜单的实现涉及到了多个环节,从JSP基础、数据库交互、Java集合操作到...
8. **优化**:考虑性能优化,可以使用缓存技术如Spring Cache或 EhCache,缓存部分不常变动的数据,减少数据库查询次数。此外,还可以利用Spring的懒加载特性,避免一次性加载过多数据。 通过以上步骤,我们可以...
7. **缓存优化**:为了提高性能,可以考虑使用缓存机制,如内存缓存(如 Ehcache)或数据库缓存(如 MySQL 的 Query Cache),减少不必要的数据库查询。 8. **响应式设计**:确保分页小程序在不同设备和屏幕尺寸上...
新的版本支持集群下缓存共享,需要每个应用更新Quickstart2.35 及以上版本,参照etc/common/ehcache.xml改造,一般只需获取quickstart的ehcache.xml增量加上自定义的cache配置即可。 * WADE2.53版本存在的建议改造点...
dihaw-spring-security Maven Spring MVC 应用程序 ...* Ehcache: in order to optimize the database access and the cache of the application * logback: Logback is intended as a successor to the popul
dihaw-spring-security Maven Spring MVC 应用程序 ...* Ehcache: in order to optimize the database access and the cache of the application * logback: Logback is intended as a successor to the popul
spring-mvc-形成 Spring MVC 应用程序 ...* Ehcache: in order to optimize the database access and the cache of the application * logback: Logback is intended as a successor to the popular log4j projec
- **使用JSP指令和脚本**:合理利用JSP指令和脚本来控制页面的行为,如使用`<%@ page %>`指令设置页面的编码、错误处理等;使用`<% %>`脚本块执行Java代码逻辑。 - **减少数据库查询次数**:通过缓存机制减少对...
I. Spring Boot Documentation 1. About the Documentation 2. Getting Help 3. First Steps 4. Working with Spring Boot 5. Learning about Spring Boot Features 6. Moving to Production 7. Advanced Topics II....