Hazelcast vs ElastiCache (Memcached)
This article compares Hazelcast to the Amazon Web Services ElastiCache Memcached Engine. Cost, Features, Node Management, Fault Tolerance, Monitoring, and Performance are all evaluated.
Join the DZone community and get the full member experience.
Join For FreeOverview
This article compares Hazelcast to the Amazon Web Services ElastiCache Memcached Engine. Cost, Features, Node Management, Fault Tolerance, Monitoring, and Performance are all evaluated.
Hazelcast
In a Hazelcast grid, data is evenly distributed among the nodes or as we call them “members” of a computer cluster, allowing for horizontal scaling both in terms of available storage space and processing power. Backups are also distributed in a similar fashion to other members, based on configuration, thereby protecting against single member failure.
Through collaboration with our customers, we’ve seen organizations scale with Hazelcast clusters from a single server to above 100 members, processing billions of transactions and organizations with dozens of clusters totaling over 1,000 members.
Each Hazelcast Server Member is connected to one another and shares relevant replication information (see Figure 1.)
Figure 1.
ElastiCache
Memcached cache clusters are comprised of from 1 to 20 nodes. Scaling a Memcached cache cluster out and in is as easy as adding or removing nodes from the cache cluster. If you need more than 20 nodes in a Memcached cluster, or more than 50 nodes total in a region, please fill out the ElastiCache Limit Increase Request form at http://aws.amazon.com/contact-us/elasticache-node-limit-request/.
Each ElastiCache Memcached Node is independent to one another and shares nothing (see Figure 2.)
Figure 2.
Cost
ElastiCache is not a flat fee –instead the larger the EC2 instance, the more it costs to use. For example, the following illustration has the costs for ElastiCache:
Then compare to the cost of the same EC2 instances:
You can see there is nearly a dollar per hour difference for the current generation 8XL ($3.64 vs $2.66) which equals about $8550 per year!
In terms of what do you get from Hazelcast, a node or member of open source is free; however, Hazelcast Enterprise is a flat fee per node so it doesn’t matter what size the node is you are not penalized for running larger instances.
Features
Memcached
It is well established as one of the oldest open source solutions in the caching market. Memcached is not an in-memory data grid (IMDG) instead; it is a simple key/value store that does not offer distributed compute or advanced serialization mechanisms. The server does not care what your data looks like. Items are made up of a key, an expiration time, optional flags, and raw data. It does not understand data structures; you must upload data that is pre-serialized. Some commands (incr/decr) may operate on the underlying data, but in a simple manner.
Hazelcast
Hazelcast is an in-memory data grid (IMDG). It is more of a computing platform than a simple key/value store. Here is an abbreviated list of just the open source Hazelcast features:
AtomicLong | List | Queues | Set | User Defined Services |
AtomicReference | Lock | Semaphone | Topic/ReliableTopic | Aggregators |
CountDownLatch | Map | Replicated Map | EntryProcessor | Continuous Query |
IdGenerator | MultiMap | RingBuffer | ExecutorService | MapReduce |
Hibernate 2nd Level | JCache | JClouds | AWS Discovery | Docker |
The complete feature list is well beyond the scope of this document, and can be found at the following link: https://hazelcast.com/products/
Scaling and Node Management
Given that ElasticBeanStalk is free, you only incur the cost of any underlying resources such as each EC2 instance. ElasticBeanStalk allows you to define scaling metrics and heart beats like in a Load Balancer for determining when and what to do when such metrics are observed. Adding or removing nodes based on http request is a rudimentary task using ElasticBeanStalk and since Hazelcast does not manage VM’s, it is a great match.
Node Management
Since neither Memcached nor Hazelcast perform node management, this is a comparison of ElastiCache versus ElasticBeanStalk Amazon Web Services. The following illustration applies to both solutions since they end up with the same physical topology (see Figure 3.)
Figure 3.
The primary differences are:
- ElastiCache incurs costs versus ElasticBeanStalk which is completely free.
- Memcached clients must keep an active list of all servers versus Hazelcast clients which utilize discovery and only need to connect to a single server since all servers know one another.
- Scaling up is the same between ElastiCache Memcached and ElasticBeanStalk Hazelcast.
- Scaling down will incur data loss for all ElastiCache Memcached clusters versus Hazelcast can safely scale down by using cluster quorum. The easiest method is to remove a node in more time than the migration events thus eliminating the possibility of data loss.
Scaling
Prior to using ElastiCache you must already know the size of your cluster and if it exceeds 20 nodes you must request permission. This is not the case with Hazelcast and the only limitation out of the box is the number of shards which defaults to 271 thus you could theoretically cluster up to 271 nodes without changing the default settings. In both cases, a certification process is warranted.
Certification
Hazelcast offers both a certification process (Solution Architect is included with each license) as well as additional training: https://hazelcast.com/university/hazelcast-complete-certification-training-program/
Amazon does not offer a certification process; however, they offer a certification training: https://aws.amazon.com/certification/faqs/
Fault Tolerance
ElastiCache
According to the ElastiCache best practices document (http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/BestPractices.html#FaultTolerance.Memcached) in order to mitigate the impact of a node failure, you need to spread your cached data over more nodes. Because Memcached does not support replication, a node failure will always result in some data loss from your cluster.
Hazelcast
The default configuration of Hazelcast employs a single backup and thus does not suffer data loss upon a node failure (http://docs.hazelcast.org/docs/3.6/manual/html-single/index.html#hazelcast-overview).
Monitoring
Hazelcast Management Center
The Hazelcast Management Center is a robust tool offering high and low level monitoring, event alarms, distributed object browsing, and an interactive console that allows the user to perform a wide range of tasks (http://docs.hazelcast.org/docs/3.6/manual/html-single/#administering-management-center).
ElastiCache CloudWatch
ElastiCache Cloud Watch is a non-interactive tool that allows the user to view important metrics with respect to the Memcached Cluster.
Conclusion
Proper use of in-memory caching can result in an application that performs better and costs less at scale. While Amazon ElastiCache greatly simplifies the process of deploying an in-memory cache in the cloud, it comes at great cost and lacks fault tolerance. Hazelcast provides far more features, performance, and monitoring and when paired with ElasticBeanStalk—Hazelcast is the clear winner.
Published at DZone with permission of Terry Walters. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments