Local cache (1) Performance test and usage scenario analysis of ehcache/jcs/cache4j/jcs

foreword

        I have seen several local cache performance tests on the Internet before, but I only saw one result, and I did not see the specific test scheme and usage scenarios. Therefore, during the holiday period, Brother Maotou compiled a cache performance analysis of the military parade. In addition, friends need to get rid of a cognitive misunderstanding, that is, don't compare local cache and distributed cache. The role of localcache is to solve the problem of overheating of distributed cache nodes and stand in front of distributed caches as L1 cache.

 

        During the test, pay attention to the following points:

  • Environment simulation degree: close the useless software that occupies the CPU, keep the CPU at 0% use, there are browsers, 360, Cytek drivers, etc. on the author's machine; the fence is used in the code to make the data unrelated to the cache run in advance;
  • Multi-threaded test: Do not do a single-threaded loop, one access is basically meaningless, and the Internet architecture is only used in high concurrency scenarios;
  • Test scenarios: divided into: insert, miss, hit several scenarios;
  • Performance optimization: For different cache components, performance optimization should be done. For example, if the blocking settings of oscache are different, the performance will be different;
  • Scenario Analysis: Don't just say which is good and which is bad. In fact, different scenarios are different, there is no absolute

Test Data

Run on 4C PC (I5-3230), unit: milliseconds

The latest version

Ehcache_2.10.0

oscache_2.4.1

jcs_1.3

cache4j_0.4

4 threads plugged into 100W

6093

2828

2489

1460

32 threads plugged into 100W

6989

2161

blocking=false

2143

2424

4 threads read (hit) 100W

862

575

253

820

32 threads read (hit) 100W

490

573

323

846

4 threads read (miss) 100W

965

1225

166

68

32 threads read (miss) 100W

421

1325

182

97

Component code amount

a lot

many

few

very little

Component richness

★★★★★

★★★

Function

★★★★★

★★★★

★★

latest update

2015.4.2

2011.1.11

2007.5.30

2006.2.23

echache has the worst multi-threaded insert performance. The insertion performance of oscache is the best, because oscache enables cache.blocking=false, that is, asynchronous insertion, but it will cause many read misses, and it can be turned on if there is a requirement for strong consistency. As a memory cache, no business scenario will have such a large amount of insertion.

From the point of view of hit read, jcs performs the best, and the difference in other read performance is not obvious, all within 1 second. After the multi-threaded reading of ehcache, the reading ability has been improved to a certain extent, which is very suitable for high-concurrency web applications. The multi-threaded reading stability performance of oscache is also very good.

In the case of a miss, it can be seen that the performance of cache4j is the best, and the performance of ehcache and jcs is not too far behind, which is completely within the acceptable range. The performance of oscache is slightly worse. Since the cache is used, the cache hit rate should be kept above 90% to be called the cache, so this performance impact is not particularly large.

Both ehcache and oscache are large cache components that support the web very well. In particular, ehcache continues to be more refined. After being acquired by Terracotta in 2009, the integrated cache function is even more powerful. ehcache is kept up to date. The update and community support of oscahce is slightly worse, and it has not been updated for nearly 4 years.

The results of the above performance test report show that the performance gap between insertion performance and miss is not particularly obvious. The difference in hit rate reading is not large except for JCS. If you just want to use a map that increases the invalidation time, then jcs is the best; if you just want to use the simplest cache component and minimize the code, then cache4j is the first choice; if you consider strong scalability and web support, it is definitely To choose ehcache or oscache. But oscache has a fatal flaw, that is, since 2011, it has not been updated for 4 years.

 

Taken together, ehcache's multi-threaded hit read performance, web support, distributed integration, community support, update speed, and extensive application. The best choice for caching.

insufficient

        Friends are welcome to continue in-depth research, share the research results, and we can make progress together. In the follow-up, Brother Maotou will gradually improve the deficiencies in this test. The test results are basically the same as the reference articles published on the Internet. The article is absolutely original, respect each other's labor results, please indicate the source when reprinting.

  • The code running environment should be best under linux
  • The test case code is redundant and not designed
  • The test case did not run for a long time, but only ran 3-5 times and took the data with the best results

Reference article

 

http://www.jdon.com/37031

http://sourceforge.net/projects/cache4j/

update history

2015-09-05

Finish the first draft

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326845533&siteId=291194637