Java

1.7 and UP.

It uses NIO File channels for cache write backs to disk. Hence dependency on 1.7.

POM

<dependency>
    <groupId>org.wonderdb</groupId>
    <artifactId>wonderdb</artifactId>
    <version>0.2</version>
</dependency>

Github location

https://github.com/dreamdbvilas/wonderdb

Design and How it works

WonderDB cache can be configured as Btree+ index or hash index. Please refer to my blog on Btree+ and Hash Index to understand how both these data structures work in general and how they are used in WonderDB.

Configuration

Default server.properties contents are configured for dev machines with minimum settings for caches. You will need to change values based on available physical memory.

Property Description
primaryCache.maxSize Default value 50000. It means it uses 50000 blocks of JVM memory for caching. Each block is 2048 bytes. So default value will use 50000*2048=100MB of JVM heap. Rule of thumb is to set 50% of JVM heap for primary cache.
primaryCache.highWatermark Default value 49090. It describes when primary cache eviction thread will start evicting entries into the cache. Its value should be about 1% of primaryCache.maxSize.
primaryCache.lowWatermark Default value 49050. It describes when primary cache eviction thread stops evicting. Its value should be 2% of primary cache max size.
secondaryCache.maxSize Default value 50000. It uses 50000 blocks of machine physical memory (Direct ByteBuffer). Each block is 2048 bytes. So default value will use 50000*2048=100MB of machine physical memory outside of JVM heap. Set its value based on available machine physical memory.
secondaryCache.highWatermark Default value 49050. It describes when secondary cache eviction thread will start evicting entries into the cache. Its value should be about 1% of secondaryCache.maxSize.
secondaryCache.lowWatermark Default value 49050. It describes when secondary cache eviction thread stops evicting. Its value should be about 2% of secondary cache max size.
cacheWriter.syncTime Default value 3000 (3 seconds). Its value is set in millisecond. It describes how frequently cache writer thread writes back dirty blocks from secondary cache to the disk.
disk.asyncWriterThreadPool.queueSize Default value 10. It describes number parallel threads cache writer invokes to write secondary cache block to disk. Its value should be set depending on type of disk and number of CPUs the node has.
cache.storage Default value ./cache. It describes location of disk file to store cache entries.
cacheIndex.storage Default value ./cacheIndex. It describes location of disk file to store cache key entries.
cache.type [btree , hash]. Default is btree. Read more about btree. If your queries are mostly PK lookup type then use hash else leave it to btree. We have seen performance improvement of over 100% with hash.
cache.buckets This is used only when cache.type is hash. I am in the process of updating a document explaining calculations for its optimal performance. For now leave it to its default value.

Supported APIs

API Description
byte[] get(byte[] key) Gets entry from the cache.
void set(byte[] key, byte[] value) Set value into the cache.
void remove(byte[] key) Removes entry from the cache.

Using it in the code

Initialization

It needs to first initialize primary and secondary caches including disk files and number of thread pools. Add folioing line into your initialization code. This should be called only once.

WonderDBCacheService.getInstance().init(<server.properties file name>);
Accessing it in the code

To get value from cache, use following line from anywhere in the code.

CacheManager.getInstance().get(byte[] key);

To set a value,

CacheManager.getInstance().set(byte[] key, byte[] value);

To remove entry from the cache

CacheManager.getInstance().remove(byte[] key);
Shutdown

Call following line during the shutdown at the end. It cleans up all resources like thread pools, caches, sockets etc. JVM will not exit properly if this line is not called during shutdown.

WonderDBCacheService.getInstance().shutdown();

Questions?

Post you question on WonderDBCache google group.

Performance Tests

Performance testing was done on Amazon EC2 xlarge VM (4 CPUs, 13 GB RAM and 2 40GB standard SSDs with 3000 IOPs). Here are the results.

I first loaded 1 million entries in to the cache with value size of 1000 bytes and key size of 4 bytes.

It took 92 seconds to load. About 10869 records per second.

All tests are run for get and set api with accessing a randomly generated key between 0-1M int value. Results below are for the get apis.

Cache settings with hash index (cache.type=hash, config settings)
100% access from cache

 

# of threads Queries per second (QPS) CPU

200K

25000 25%

400K

44000 50%

600K

54000 60%

800K

61500 70%

1M 

52600 75-80%

1.2M

50000 75-80%

Cache settings with BTree+ index (cache.type=btree, config settings)
Case I – 100% access from cache

In this test keys were generated between 0-100000 just to make sure all keys will be accessed from the cache.

# of threads Queries per second (QPS) CPU
1  14285 20-25%
2 23529 25-50%
3  30000 50-75%
4  33000 75+%
5  33000 75+%
Case II – 80% from memory and 20% from disk (SSD)

In this test keys were generated between 0-1M to make sure there were 20% cache misses.

# of threads Queries per second (QPS) CPU
1  7142 20-25%
2  10000 25-50%
3  12500 50-75%
4  13800 75+%
5  12500 75+%

0 Responses

  1. Your comment is awaiting moderation.

    You said this perfectly!

    viagra cialis and relationships harvard study silagra generic viagra cumwithuscom
    generic viagra
    viagra product information – https://genericviagrantx.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  2. Your comment is awaiting moderation.

    Truly a good deal of very good knowledge.

    buy viagra com inr and viagra
    viagra 100mg
    generic viagra in the uk – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  3. Your comment is awaiting moderation.

    Many thanks! Quite a lot of stuff!

    viagra and contraindications easy buy viagra online
    cheap viagra
    funny viagra jokes – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  4. Your comment is awaiting moderation.

    Superb content. Many thanks!

    buying viagra buying viagra online vs doctor
    viagra without a doctor prescription
    semen turns yellow viagra – https://genericviagramsl.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  5. Your comment is awaiting moderation.

    Valuable tips. Cheers.

    viagra columbus viagra nottingham
    viagra pills
    what is comparable to viagra – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  6. Your comment is awaiting moderation.

    Lovely material, Kudos!

    fake generic viagra viagra used for cardiac issues
    buy viagra
    viagra viagra a a target blank – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  7. Your comment is awaiting moderation.

    Amazing tons of very good facts.

    viagra sites street value viagra 100mg
    generic viagra 100mg
    viagra compare prices no questions – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  8. Your comment is awaiting moderation.

    Terrific material. Cheers.

    gay viagra viagra plus cialis
    buy viagra
    taking l-arginine along with viagra – https://genericviagramsl.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  9. Your comment is awaiting moderation.

    Superb stuff. Regards.

    warning window buy viagra now how to remove viagra official site
    viagra online
    book viagra diaries – https://genericviagrantx.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  10. Your comment is awaiting moderation.

    Nicely put. Thank you!

    get viagra perscription online generic viagra cost local pharmacy
    viagra pills
    international viagra sellers – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  11. Your comment is awaiting moderation.

    Great material, Cheers.

    viagra prescription for woman viagra rectally
    viagra without a doctors prescription
    cheap viagra cialis levitra – https://genericviagramsl.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  12. Your comment is awaiting moderation.

    Seriously many of helpful info.

    women taking mens viagra effects generic viagra advanced canada
    viagra generic
    lifestyles viagra – https://genericviagrantx.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  13. Your comment is awaiting moderation.

    Very good postings. Appreciate it.

    long term effects using viagra buying viagra at tesco
    viagra for sale uk
    viagra and depression in women – https://genericviagrantx.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  14. Your comment is awaiting moderation.

    You actually said it fantastically.

    samples of viagra viagra doseages
    buy viagra
    88 keys stay up viagra – https://genericviagrantx.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  15. Your comment is awaiting moderation.

    Many thanks! A good amount of forum posts.

    banned viagra commercials can viagra be dependent
    viagra without a doctors prescription
    slow down viagra – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  16. Your comment is awaiting moderation.

    With thanks. Lots of info.

    what are the benifets of viagra karides viagra
    buy viagra
    viagra generic uk – https://genericviagrantx.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  17. Your comment is awaiting moderation.

    Regards. Loads of postings.

    viagra online sale canada viagra and heart problems
    buy generic viagra
    get viagra online in canada – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  18. Your comment is awaiting moderation.

    You’ve made your point.

    cheap viagra online without prescritpion re buy viagra
    generic viagra 100mg
    mccain viagra commercial – https://genericviagrantx.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  19. Your comment is awaiting moderation.

    Good write ups. Thank you!

    free viagra sample online gay men viagra
    buy generic viagra
    viagra in new zeland – https://genericviagramsl.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  20. Your comment is awaiting moderation.

    Cheers. I appreciate this!

    viagra p5 inhibitor international drug store viagra
    buy viagra
    non persription viagra – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  21. Your comment is awaiting moderation.

    Nicely put, Many thanks.

    what works like viagra will hydrochlorothiazide affect viagra
    generic viagra
    drm viagra – https://genericviagramsl.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  22. Your comment is awaiting moderation.

    Wow many of terrific tips!

    levitra viagra sending emails account viagra 2011 cost winnipeg
    viagra for women
    nitrates and viagra – https://genericviagramsl.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  23. Your comment is awaiting moderation.

    You’ve made your stand pretty nicely!!

    natural supplement viagra web md viagra
    viagra online
    viagra find sites computer – https://genericviagramsl.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  24. Your comment is awaiting moderation.

    You have made your position extremely clearly!.

    find viagra free sites online best prices on viagra
    buy viagra
    viagra tv commercial girl – https://genericviagrantx.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  25. Your comment is awaiting moderation.

    Regards, Helpful stuff!

    availability of viagra in spain patent expiration for viagra
    viagra pills
    men who have tried viagra – https://genericviagrantx.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  26. Your comment is awaiting moderation.

    Effectively voiced without a doubt! !

    mixing vicodin viagra viagra paul thorn mp3
    cheap viagra
    viagra in use – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  27. Your comment is awaiting moderation.

    You actually reported this fantastically!

    viagra aberdeen generic viagra india trial pack
    viagra without a doctor prescription
    buy viagra in england – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  28. Your comment is awaiting moderation.

    Factor certainly applied..

    sex experiments with viagra canadian pharmacy for viagra
    generic viagra 100mg
    emanuelle viagra – https://genericviagrantx.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  29. Your comment is awaiting moderation.

    You actually explained it exceptionally well!

    viagra online uk big dicks on viagra tubes
    generic viagra
    viagra bp – https://genericviagramsl.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  30. Your comment is awaiting moderation.

    This is nicely put! !

    viagra commercial blues song can you mix viagra and phentermine
    viagra for women
    generics mexico viagra – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  31. Your comment is awaiting moderation.

    With thanks. A good amount of info!

    free cialis viagra samples viagra recovery time after ejaculation
    viagra online
    low blood pressure viagra warning – https://genericviagrantx.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  32. Your comment is awaiting moderation.

    You actually said it exceptionally well!

    edinburgh uk viagra pages comment news aphrodisiac new women viagra
    viagra for women
    levitra or viagra reviews – https://genericviagrantx.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  33. Your comment is awaiting moderation.

    Nicely put, Thanks a lot.

    viagra banned ads viagra and no perscription and us
    viagra generic
    medical articles on viagra – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  34. Your comment is awaiting moderation.

    Regards. Terrific stuff.

    buy viagra in stoke on trent viagra online cheap
    viagra 100mg
    find sites computer shop viagra online – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  35. Your comment is awaiting moderation.

    Position very well considered.!

    online prescription viagra how to get viagra in philippines
    buy viagra online
    viagra benefit – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  36. Your comment is awaiting moderation.

    You actually revealed it superbly!

    can i chew viagra girls on viagra
    viagra without a doctor prescription
    1 generic viagra – https://genericviagrantx.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  37. Your comment is awaiting moderation.

    Factor effectively applied!.

    viagra head office toronto photo after using viagra
    viagra pills
    edinburgh viagra pages search find – https://genericviagramsl.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  38. Your comment is awaiting moderation.

    Superb postings. With thanks.

    northwest pharmacy viagra cheap compare viagra to cialis
    generic viagra 100mg
    viagra sudden blindness – https://genericviagrantx.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  39. Your comment is awaiting moderation.

    Appreciate it, Quite a lot of information!

    generic brand viagra viagra uk online viagra uk url
    generic viagra 100mg
    canadian generic viagra – https://genericviagrantx.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  40. Your comment is awaiting moderation.

    Thanks a lot! I like this.

    free mail viagra viagra for canadians
    viagra pills
    viagra marketing campaign – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  41. Your comment is awaiting moderation.

    Amazing postings. Thanks.

    what is the safe viagra dosage natural viagra formulas
    viagra without a doctor prescription
    natural female viagra – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  42. Your comment is awaiting moderation.

    Great advice. With thanks.

    boyfriend taking viagra without me pulmoanry htn viagra
    buy viagra online
    viagra to masturbate – https://genericviagrantx.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  43. Your comment is awaiting moderation.

    Cheers! Very good stuff.

    viagra in new zeland viagra efectos
    viagra for women
    walgreens viagra cost – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  44. Your comment is awaiting moderation.

    With thanks! I enjoy it!

    generic viagra drugs order brand pill viagra falls off broadway play
    viagra for sale uk
    viagra mouse virus – https://genericviagramsl.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  45. Your comment is awaiting moderation.

    You actually explained it effectively!

    t 84 viagra viagra liquid
    viagra for sale uk
    what if a woman took viagra – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  46. Your comment is awaiting moderation.

    Seriously plenty of very good information!

    best viagra alternative viagra cocks
    generic viagra
    order prescription viagra – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  47. Your comment is awaiting moderation.

    Thank you. Ample advice!

    andros viagra viagra available in beijing
    viagra without a doctors prescription
    viagra online uk – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  48. Your comment is awaiting moderation.

    Truly quite a lot of awesome advice!

    file name of viagra virus india generic viagra
    viagra for sale uk
    viagra alternative natural – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  49. Your comment is awaiting moderation.

    Point very well considered.!

    canadien viagra buy viagra while overseas
    viagra for women
    natural female viagra – https://genericviagrarcp.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  50. Your comment is awaiting moderation.

    You made your position very clearly!!

    viagra thailand uses of vega viagra
    viagra pills
    viagra like drugs – https://genericviagramsl.com

    Geraldjum
    DwayneFoest
    KevinRoyah

  51. Your comment is awaiting moderation.

    You have made your stand pretty nicely..

    side-effects viagra viagra edinburgh news search site
    viagra 100mg
    viagra coral calcium adipex betting – https://genericviagrantx.com

    Geraldjum
    DwayneFoest
    KevinRoyah

Leave a Reply