Compare Tarantool with Redis and Memcached

Original author: Evan Bates
  • Transfer

image


Choose between Tarantooland Redisor between Tarantooland Memcached? Let's look at the main differences, so that it is easier for you to decide.


Tarantool and Redis


As for the in-memorydatabases, Rediscompared with the Memcachedimproved 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 Tarantoolsuperior 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, Tarantoolyou can effectively use the application as the main database - frankly, such a featRedisnot always on the shoulder [3] .


The main drawback Redisis the inability to process data volumes more than the amount of server RAM. In the Tarantoolsame you can choose storage engines:


  • Memtxworking as a traditional in-memorydatabase
  • or Vinyl/Disk, allowing the use of disks in combination with RAM.

Vinylallows 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] .


Redisand Tarantoolsupport 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 Tarantooluses a faster LuaJIT, unlike vanilla- Luabased implementation Redis. It is also Tarantoolequipped with a full-fledged, non-blocking Luaapplication server that has access to the network and external services. At the same time, it is placed in the “sandbox” in the Redisimplementation Lua, and scripts are blocked [6] . That is, waiting for the completion of Lua-processes in Rediscan 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 Tarantoolwith Rediswould 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 rangesand read-modify-write- showed that, for the indices Hashand Tree Tarantoolis ahead Redisin all types of loads. Also in most cases u have Tarantoolless latency. This applies to loads with proactive logging and without it.


The advantage Tarantoolis 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 Redisthey 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 Serverand PostgreSQL.


TarantoolOrchestrates and virtualizes data, accelerating access to it. Using Tarantoolin 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 Tarantoolcan 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-memoryof 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 Memcachedand Tarantoolfor your new application or, perhaps, are considering whether to continue supporting the legacy installation Memcached.


Caching versus smart caching


The approach Memcachedis simple and good. The applications that use it check to see if there is any requested data in Memcachedit 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 Tarantoolthis 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 Luaapplication 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. MemcachedDesigned to reduce the load on reading, but not on writing. The Tarantoolsame processing is implemented good reads. Its high utilization efficiency CPUcan help reduce the amount of costly replicas for slow DBMSs. Moreover, the Tarantooldeveloped processing capabilities of write operations. It writes to disk synchronously and therefore can replace disk DBMSs. In addition, recording operations in Tarantoolfull 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 Tarantoolis solved by restoring data from saved files.


Ease of use


Memcachedeasy to install and allows you to quickly perform queries GETand SET, which in some situations is quite enough. Tarantoolit 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 Tarantoolin a variety of fields - from microservices to the aforementioned highly loaded transactional data processing, corresponding ACID.


Independence


Memcachedwas created to support other databases. Tarantoolalso 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, ACIDtransactions, the ability to work with data whose volume is more than RAM. In fact, Tarantoolit 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 Luacomplete program in the same way as with traditional stored procedures.


Scaling


Memcachedand Tarantoolyou can easily scale by adding new machines, although you will have to take care of how to distribute data among nodes. Additionally, Tarantoolthere 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 Memcachedand you Tarantoolwill have to take into account many points, from synchronization problems to scaling. If you have any questions about Tarantool, write in the comments.


References


  1. http://www.infoworld.com/article/3063161/application-development/why-redis-beats-memcached-for-caching.html
  2. https://hackernoon.com/tarantool-vs-redis-38a4041cc4bc
  3. https://news.ycombinator.com/item?id=3010345
  4. https://medium.com/@denisanikin/tarantool-vinyl-200k-transactions-per-second-on-a-disk-based-database-c5f3cbba6543
  5. https://medium.com/@denisanikin/when-and-why-i-use-an-in-memory-database-or-a-traditional-database-management-system-5737f6d406b5
  6. https://hackernoon.com/tarantool-vs-redis-38a4041cc4bc
  7. https://medium.com/tarantool-database/dbms-as-an-application-server-779402dbf485
  8. https://medium.com/@denisanikin/how-to-save-one-million-dollars-on-databases-with-tarantool-5eb1596ec628
  9. https://github.com/tarantool/vshard

Also popular now: