📜 ⬆️ ⬇️

Compare Tarantool with Redis and Memcached

image


Choose between Tarantool and Redis or between Tarantool and Memcached ? Let's look at the main differences to make it easier for you to decide.


Tarantool and Redis


As for in-memory databases, Redis compared with Memcached improved the ability to store cached data, use not only string but also other types of data, as well as perform complex data operations [1] . In Tarantool, operations with data groups have reached an even higher level of complexity, and in terms of storage reliability and indexing Tarantool surpasses 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 can be effectively used as the main database of the application - frankly, Redis not always such a feat [3] .


The main disadvantage of Redis is the inability to process data volumes more than the amount of RAM in the server. In Tarantool , you can choose storage engines:



Vinyl allows you to work with data whose volume is 10-100 times more than the available amount of RAM [4] . This is achieved by using the LSM tree (log-structured merge tree) instead of the more common B-tree, which ultimately led to the elimination of random write operations — the bottleneck of disk engines [5] .


Redis and Tarantool support Lua scripts, i.e., they allow complex functions to be applied to data. In addition, both databases can be supplemented with certain packages from the LuaRocks ecosystem. But right out of the box, Tarantool uses a faster LuaJIT , unlike vanilla Lua implementations in Redis . Tarantool also equipped with a full-fledged, non-blocking Lua server application that has access to the network and external services. At the same time, the implementation of Lua in Redis is placed in the sandbox, and scripts are blocked [6] . That is, waiting for the completion of Lua processes in Redis can reduce performance, but in Tarantool is no such problem: as long as one call is blocked on an external resource, another active call that runs in parallel continues to work.


Of course, comparing Tarantool with Redis would be incomplete without at least a brief mention of their relative throughput and latency levels. Testing on a single node using Yahoo! Cloud Server Benchmark (YCSB) Yahoo! Cloud Server Benchmark (YCSB) with a run of six main types of load - update heavy , read mostly , read only , read latest , short ranges and read-modify-write - showed that with respect to the Hash and Tree Tarantool ahead of Redis under all types of loads . Also in most cases, Tarantool less latency . This applies to logging loads with and without logging.


The advantage of Tarantool is explained by 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 range of additional tools, but they are not in Redis . One of the interesting features of the Tarantool application Tarantool is the ability to interact with other, slower databases in order to cache information stored in them, and thus speed up their work: this applies to Oracle , IBM DB2 , MySQL , MS SQL Server and PostgreSQL .


Tarantool orchestrates and virtualizes data, speeding access to it. The use of Tarantool in the architecture of almost any enterprise applications and services allows to reduce the code base of integration and scaling, and also reduces the requirements for servers and equipment. For example, one Tarantool server can replace dozens of servers on which the traditional DBMS , so you can scale your microservices and applications faster [8] .


Tarantool and Memcached


Memcached (2003) and Tarantool (2009) belong to two different generations of in-memory databases based on caching. So in a sense, comparing them is not too fair, since more recent technologies usually surpass the 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 choose between Memcached and Tarantool for your new application or, perhaps, you are wondering whether to continue supporting the legacy installation of Memcached .


Caching versus smart caching


Memcached 's approach is simple and good. Applications that use it check if the requested data is in Memcached before calling the slower database associated with it. However, Memcached and the associated database may become unsynchronized due to the failure to update one of them, since both of them are not replicated, and the application interacts with them separately. In Tarantool this problem is solved with the help of “smart” caching: the update will be completed only after a successful update of the associated database. That is, instead of interacting with two levels, the application interacts only with Tarantool , which is responsible for updating the associated database. In addition, at any time, a Lua application server can be connected to the data processing, working simultaneously with the database server.


Read and write


The main difference between the two caching methods lies in their ability to handle read and write operations in the associated databases. Memcached designed to reduce the load on reading, but not on writing. Tarantool also implemented a good handling of read operations. Its high CPU efficiency can help reduce the cost of expensive replicas for slower DBMSs. At the same time, Tarantool advanced processing capabilities for write operations. It writes to disk synchronously and therefore can replace disk DBMS. In addition, the write operations in Tarantool fully comply with the principles of ACID .


Cold start


When you run Memcached , there is no data in it, so all select operations must be passed directly to the associated database. In Tarantool this is solved by recovering data from saved files.


Ease of use


Memcached is easy to install and allows you to quickly perform GET and SET queries, which in some situations is enough. Tarantool also easy to install, but because of its more advanced functionality, it has a more extensive syntax. However, if you Tarantool it, you will be able to use Tarantool in a wide variety of areas - from microservices to the above-mentioned highly loaded transactional data processing, corresponding to 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 cash 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 greater than the RAM. In fact, Tarantool can not just work independently of a relational database, it can do without an additional backend in the form of a relational database. You can program a full-fledged program on Lua just as you would with traditional stored procedures.


Scaling


Memcached and Tarantool can be easily scaled by adding new machines, although you will have to take care of how to distribute data among nodes. Additionally, Tarantool has a built-in sharding mechanism that allows the cluster to scale automatically. More details about this mechanism can be found here .


✽✽✽


As you can see, when choosing between Memcached and Tarantool will Tarantool to take into account many things, from synchronization problems to scaling. If you have any questions about Tarantool , write in the comments.


Links


  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

')

Source: https://habr.com/ru/post/352760/


All Articles