
Compare Tarantool with Redis and Memcached
- Transfer
Choose between Tarantool
and Redis
or between Tarantool
and Memcached
? Let's look at the main differences, so that it is easier for you to decide.
Tarantool and Redis
As for the in-memory
databases, Redis
compared with the Memcached
improved storage capabilities of cached data, the use of not only string, but also other types of data, as well as performing complex operations with data [1] . In Tarantool operations on data groups have reached an even higher level of complexity, and in terms of reliability of storage (persistence)
and indexing they are Tarantool
superior Redis
, not to mention the speed of work and user support [2] . Given the development of storage facilities, as well as the ability to work with transactions and large amounts of data, Tarantool
you can effectively use the application as the main database - frankly, such a featRedis
not always on the shoulder [3] .
The main drawback Redis
is the inability to process data volumes more than the amount of server RAM. In the Tarantool
same you can choose storage engines:
Memtx
working as a traditionalin-memory
database- or
Vinyl/Disk
, allowing the use of disks in combination with RAM.
Vinyl
allows you to work with data whose volume is 10-100 times greater than the available amount of RAM [4] . This was achieved by using the LSM tree (log-structured merge tree)
instead of the more common B tree, which ultimately eliminated random write operations - the bottleneck of disk engines [5] .
Redis
and Tarantool
support scripts on Lua
, that is, they allow you to apply complex functions to the data. In addition, both databases can be supplemented with certain packages from the ecosystem LuaRocks
. But right out of the box it Tarantool
uses a faster LuaJIT
, unlike vanilla- Lua
based implementation Redis
. It is also Tarantool
equipped with a full-fledged, non-blocking Lua
application server that has access to the network and external services. At the same time, it is placed in the “sandbox” in the Redis
implementation Lua
, and scripts are blocked [6] . That is, waiting for the completion of Lua
-processes in Redis
can reduce productivity, and inTarantool
There is no such problem: while one call is blocked on an external resource, another active call, which is simultaneously being executed, continues to work.
Of course, comparing Tarantool
with Redis
would not be complete without even a brief mention of their relative throughput and delay levels. Testing on the same node using the benchmark Yahoo! Cloud Server Benchmark (YCSB)
with run of six basic types of load - update heavy
, read mostly
, read only
, read latest
, short ranges
and read-modify-write
- showed that, for the indices Hash
and Tree Tarantool
is ahead Redis
in all types of loads. Also in most cases u have Tarantool
less latency
. This applies to loads with proactive logging and without it.
The advantage Tarantool
is due to the work in tandem of a database management system (DBMS)
and a full-fledged application server [7] . This server, which can be used separately, has a whole set of additional tools, but Redis
they do not. One of the interesting features of the application server Tarantool
- the ability to interact with other, slower database for the purpose of caching of information stored in them, and thus accelerate their work: this refers to the Oracle
, IBM DB2
, MySQL
, MS SQL Server
and PostgreSQL
.
Tarantool
Orchestrates and virtualizes data, accelerating access to it. Using Tarantool
in the architecture of almost any enterprise applications and services can reduce the integration and scalability codebases, as well as reduces the requirements for servers and equipment. For example, one server Tarantool
can replace dozens of servers on which the traditional one runs DBMS
, so you can quickly scale your microservices and applications [8] .
Tarantool and Memcached
Memcached (2003)
and Tarantool (2009)
belong to two different generations in-memory
of caching-based databases. So in a sense, comparing them is not too fair, since more recent technologies usually outperform earlier ones. But if the technology appeared later, this does not mean that it is better suited for some task. Sometimes less advanced tools are preferable for certain needs. We will proceed from the assumption that you are choosing between Memcached
and Tarantool
for your new application or, perhaps, are considering whether to continue supporting the legacy installation Memcached
.
Caching versus smart caching
The approach Memcached
is simple and good. The applications that use it check to see if there is any requested data in Memcached
it before invoking the slower database it is paired with. However Memcached
, the associated database may also be out of sync due to a failure to update one of them, because both of them are not replicated, and the application interacts with them separately. As Tarantool
this problem is solved with the help of "smart" caching: the update is completed only after a successful update conjugate database. That is, instead of interacting with two levels, the application only interacts with Tarantool
, which is responsible for updating the conjugate database. In addition, at any time, you can connect to the data processing Lua
application server, working simultaneously with the database server.
Read and write
The main difference between the two caching methods is their ability to handle read and write operations in related databases. Memcached
Designed to reduce the load on reading, but not on writing. The Tarantool
same processing is implemented good reads. Its high utilization efficiency CPU
can help reduce the amount of costly replicas for slow DBMSs. Moreover, the Tarantool
developed processing capabilities of write operations. It writes to disk synchronously and therefore can replace disk DBMSs. In addition, recording operations in Tarantool
full compliance with the principles ACID
.
Cold start
When launched Memcached
, there is no data in it, so all selection operations (select)
must be transferred directly to the conjugate database. This Tarantool
is solved by restoring data from saved files.
Ease of use
Memcached
easy to install and allows you to quickly perform queries GET
and SET
, which in some situations is quite enough. Tarantool
it is also easy to install, but due to more developed functionality it has a more extensive syntax. However, if you master it, you will be able to apply it Tarantool
in a variety of fields - from microservices to the aforementioned highly loaded transactional data processing, corresponding ACID
.
Independence
Memcached
was created to support other databases. Tarantool
also works in conjunction with other databases, but can function completely independently, which is not typical for cache solutions. This is achieved with the help of reliable data storage, a full-fledged application server, ACID
transactions, the ability to work with data whose volume is more than RAM. In fact, Tarantool
it can not only work independently of a relational DBMS, it can do without an additional backend in the form of a relational DBMS. You can program for a Lua
complete program in the same way as with traditional stored procedures.
Scaling
Memcached
and Tarantool
you can easily scale by adding new machines, although you will have to take care of how to distribute data among nodes. Additionally, Tarantool
there is a built-in sharding mechanism that allows you to scale the cluster automatically. You can read more about this mechanism here .
✽✽✽
As you can see, when choosing between Memcached
and you Tarantool
will have to take into account many points, from synchronization problems to scaling. If you have any questions about Tarantool
, write in the comments.
References
- http://www.infoworld.com/article/3063161/application-development/why-redis-beats-memcached-for-caching.html
- https://hackernoon.com/tarantool-vs-redis-38a4041cc4bc
- https://news.ycombinator.com/item?id=3010345
- https://medium.com/@denisanikin/tarantool-vinyl-200k-transactions-per-second-on-a-disk-based-database-c5f3cbba6543
- https://medium.com/@denisanikin/when-and-why-i-use-an-in-memory-database-or-a-traditional-database-management-system-5737f6d406b5
- https://hackernoon.com/tarantool-vs-redis-38a4041cc4bc
- https://medium.com/tarantool-database/dbms-as-an-application-server-779402dbf485
- https://medium.com/@denisanikin/how-to-save-one-million-dollars-on-databases-with-tarantool-5eb1596ec628
- https://github.com/tarantool/vshard