The slowing caches



  • We had some performance issues, so a coworker decided to implement some caches. Rather than choosing industry standard, proven technologies, he tried to write his own cache implementation. The base was just a Map with input keys and resolved values, the first call would add something to the map and the second call would get it from the map, not having to do the expensive calculation. Nothing too bad.

    But then he noticed that when two calls were done at approximately the same time (this is a multi-threaded back-end server we're talking about), the expensive call was done twice (or more, depending on amount of calls) and each result (all the same) put into the Map. So he decided he needed to have a blocking mechanism so the very first call would block the other calls, do the expensive work, and the other calls would just re-use the calculated value (those calls still take as long [granted that multiple workloads at the same time didn't slow down processing] but at least database resources and such would be less).

    So how did he decide to implement this blocking mechanism? By synchronising on the entire Map.... bye bye performance.



  • There will be layers and layers of additional fun if this application is deployed on a load-balancing cluster. You should suggest that in your next design meeting.



  • @Speakerphone Dude said:

    There will be layers and layers of additional fun if this application is deployed on a load-balancing cluster. You should suggest that in your next design meeting.
     

    It already is. Duplicated caches are the least of our problems to be honest.



  • @pbean said:

    @Speakerphone Dude said:

    There will be layers and layers of additional fun if this application is deployed on a load-balancing cluster. You should suggest that in your next design meeting.
     

    It already is. Duplicated caches are the least of our problems to be honest.

    What is the load-balancing technology you use?



  • @Speakerphone Dude said:


    What is the load-balancing technology you use?

     

    Hopefully it's not just a see-saw...

     



  • @Speakerphone Dude said:

    What is the load-balancing technology you use?
     

    LinkedHashMap!

     



  • @pbean said:

    @Speakerphone Dude said:

    What is the load-balancing technology you use?
     

    LinkedHashMap!

     

    Did you misplace the exclamation mark? Because that's the opposite of a load-balancing technology, so !LinkedHashMap would not answer the question but would at least make sense a little.



  • @Speakerphone Dude said:

    @pbean said:

    @Speakerphone Dude said:

    What is the load-balancing technology you use?
     

    LinkedHashMap!

    Did you misplace the exclamation mark? Because that's the opposite of a load-balancing technology, so !LinkedHashMap would not answer the question but would at least make sense a little.

     

    Either your irony detector needs some calibration, or you've got to realize that an ironic answer to an ironic remarks suspiciously resembles grumpy dickweedery.



  • @TGV said:

    @Speakerphone Dude said:

    @pbean said:

    @Speakerphone Dude said:

    What is the load-balancing technology you use?
     

    LinkedHashMap!

    Did you misplace the exclamation mark? Because that's the opposite of a load-balancing technology, so !LinkedHashMap would not answer the question but would at least make sense a little.

     

    Either your irony detector needs some calibration, or you've got to realize that an ironic answer to an ironic remarks suspiciously resembles grumpy dickweedery.

    The record will show that I made an honest effort to demonstrate interest in the situation explained by the guy, and that he disputed my point without providing evidence to support his claim. This lead to an escalation of allegedly sarcastic answers for which I can't be held responsible.

    So let it be known that while I value your opinion in general and appreciate your input in any conversation, I simply cannot find how your comment is helping to move things forward in this specific instance.


  • Discourse touched me in a no-no place

    @Speakerphone Dude said:

    @TGV said:

    @Speakerphone Dude said:

    @pbean said:

    @Speakerphone Dude said:

    What is the load-balancing technology you use?
     

    LinkedHashMap!

    Did you misplace the exclamation mark? Because that's the opposite of a load-balancing technology, so !LinkedHashMap would not answer the question but would at least make sense a little.

     

    Either your irony detector needs some calibration, or you've got to realize that an ironic answer to an ironic remarks suspiciously resembles grumpy dickweedery.

    The record will show that I made an honest effort to demonstrate interest in the situation explained by the guy, and that he disputed my point without providing evidence to support his claim. This lead to an escalation of allegedly sarcastic answers for which I can't be held responsible.

    So let it be known that while I value your opinion in general and appreciate your input in any conversation, I simply cannot find how your comment is helping to move things forward in this specific instance.

     I assume this is what it looks like to be stack ranked in the bottom tier.



  • srsbsns time! Tell him to look at Google's [url=https://code.google.com/p/guava-libraries/]Guava[/url] library.

    Among other great features are a couple of great [url=http://docs.guava-libraries.googlecode.com/git-history/release/javadoc/com/google/common/cache/LoadingCache.html]cache[/url] classes that are super simple to use and have excellent performance and are thread safe and sound like they could be a drop-in replacement for his map.

    Here, have a [url=http://guava-libraries.googlecode.com/files/JavaCachingwithGuava.pdf]slideslow[/url].



  • @Speakerphone Dude said:

    What is the load-balancing technology you use?
     

    I've now clue, load balancing is what the "server guys" do. We developers develop the software. Also I thought I was posting in the "Side Bar WTF" sub-forum, where it's not my point to ask for help, but rather to share my WTFs with those interested.

     

    @Xyro said:

    srsbsns time! Tell him to look at Google's Guava library.

    Among other great features are a couple of great cache classes that are super simple to use and have excellent performance and are thread safe and sound like they could be a drop-in replacement for his map.

    Here, have a slideslow.

     

    Good suggestion. :) I personally really like Guava myself, and have played with it's cache utilities before. Interestingly, we exclusively use ehcache in our application and the guy just didn't know that. He was relatively new and nobody told him to implement caching with ehcache. Unfortunately, he also didn't ask, so we had to figure out on the code review. To be honest, the guy's not that bad, he just lacks some experience, that's all. He was very inquisitive about why what he had done was bad and how to do it better in the future.

     



  • @pbean said:

    Also I thought I was posting in the "Side Bar WTF" sub-forum, where it's not my point to ask for help, but rather to share my WTFs with those interested.

    It's unpossible for you to post here without idiots offering you "helpful" advice.



  • @blakeyrat said:

    It's unpossible for you to post here without idiots offering you "helpful" advice.

    Hi! I noticed in your post that you used the word "unpossible". You probably mean "[i]im[/i]possible".

    Hope that helps!
    Xyro


  • @blakeyrat said:

    @pbean said:
    Also I thought I was posting in the "Side Bar WTF" sub-forum, where it's not my point to ask for help, but rather to share my WTFs with those interested.

    It's unpossible for you to post here without idiots offering you "helpful" advice.

     

    Just for me, or for anyone?



  • @pbean said:

    Just for me, or for anyone?

    Just you, nobody cares about the others

    @Xyro said:

    Hope that helps!

    Knowing blakeyrat and his boolean states I doubt it (he is either "right" or doesn't care)


  • Discourse touched me in a no-no place

    @serguey123 said:

    @Xyro said:
    Hope that helps!

    Knowing blakeyrat and his boolean states I doubt it (he is either "right" or and he doesn't care)
    FTFY



  • @PedanticCurmudgeon said:

    @serguey123 said:
    @Xyro said:
    Hope that helps!

    Knowing blakeyrat and his boolean states I doubt it (+"he is right" +"he doesn't care')
    FTFY
    FTFTFY


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.