What kind of cache effect is high? Open source a simple cache component J2cache

Source: Internet
Author: User

Background

Today's web systems have more and more application of caching technology, and caching technology is really chronological to enhance the performance of the system. I also started to touch some cache requirements in my project.

    • Start with a simple JVM (Java managed memory) for caching, which is good for a single application server.
    • For system availability, there is a need to prepare a system environment, then there will be a number of shared resources issues, such as the Tomcat session shared
    • Several systems will have a common set of cached data, thus becoming a shared pool

The growth of demand has brought about changes in the system, and I'm starting to think about how to make these codes compatible and provide more consistent support for future system modules. Just in OpenFire this open source project has been inspired, its cluster thinking I think it is a good solution.

J2cache Introduction

Then began to write a simple cache system, the structure is very simple, the code is very simple. Say is open source actually also a bit too, just think behind closed doors no meaning, so put the code on GitHub, if there is a master to see pointing out that I do not make big. Ha ha.

Github:https://github.com/mini188/j2cache

The code is very simple, the MAVEN project is also very easy to introduce, I do not intend to do what the code to explain, interested friends download a simple look to understand.

Main features of the project:
    • Storage structure of Key-value
    • Based on java.util.map<k, v> interface, so it's easy to be compatible with HashMap and the like
    • Extension based on policy mode
Three storage scenarios are implemented for this project:
    • JVM virtual machine memory, for single application, or for situations where synchronization is not required
    • Redis for scenarios where Redis is required, such as cache sharing, etc.
    • Iginte, a scheme with network computing
J2cache Test and test machine environment:

My test method is simple, write 1 million consecutive objects to the cache, and then look at the performance of the processing. Explain that these tests are done natively

Os:windows7 64-bit

cpu:i5-4210u @ 1.70GHZ 2.40GHZ

ram:8g

Redis is used with Redis on Windows redis-x64-3.2.100

1,000,000 objects written in the local environment
    • Start Test Write Cache Jvmcache

Total time: 2380ms

Writes per millisecond: 420 records

Writes per second: 420,000 records

    • Start Test Write Cache Ignitecache

Total time: 9503ms

Writes per millisecond: 105.

Writes per second: 105,000 records.

    • Start Test Write Cache Rediscache

Total time: 40367ms

Writes per millisecond: 24.

Writes per second: 24,000 records.

Results

In order to compare the various scenarios in some data, a simple write test, the use of local memory cache this scheme is the most efficient, the amount of write up to 420,000 per second. And Redis is only 24,000/sec, I'm not particularly familiar with Redis, and I'm a little surprised to see this data.

I am lazy, did not test read and write performance for a period of time, but from this simple test found that the effect of local memory is still very high, if coupled with some other functions, such as network transmission, data synchronization after the performance will be degraded.

Only Redis and ignite poor so I do not understand, do not know is not my method is wrong?

Note: This article is original, welcome reprint, please in the article page obvious location give this article link! If you think this article is not bad please click on the lower right corner of the recommendation, thank you very much! http://www.cnblogs.com/5207

What kind of cache effect is high? Open source a simple cache component J2cache

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.