Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to improve the performance of cassandra read storage

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is about how to improve the performance of cassandra read storage. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

As a distributed storage performance, cassandra is characterized by fast writing and slow reading. Recently I read the documentation of cassandra 1. 0 and found that 1. 0 has made some improvement in read performance. Users can configure it reasonably according to the requirements of the system, so as to improve the performance of reading. The following editor will explain how to improve the performance of cassandra read storage.

How to improve the performance of cassandra read Storage

1. Disable read repair

Cassandra performs read repair operations in the background for each read operation. If only one node data is required to be read, after reading one node, cassandra returns the result to the client, and then synchronizes the other replicas with read repair (according to timestamp). If you want to read multiple nodes, then cassandra reads multiple nodes, compares them according to timestamp, returns the latest data from the client, and then calls read repair to synchronize other nodes. The operation of Read repair in the background will take up a certain amount of CPU and Imax O, so it will affect the read performance. To improve read performance, you can disable read repair, which of course affects consistency, but for systems with stable nodes, it is possible to consider. In one method, the node reapair of hinted off and nodel tool is used to synchronize them periodically to improve consistency. Before cassandra1.0, disabling read repair requires code modification, and the new cassandra1.0 can set the probability of read repair by adjusting parameters (0 to 1) for each read operation.

Compaction: use Leveled compaction and set multithreaded_compaction to improve the speed of compaction.

In the article "Compression Strategies in cassandra" (http://www.cnblogs.com/marysam/articles/2266061.html)), I introduced two compaction strategies currently supported by cassandra1.0-Tiered Compaction and Leveled Compaction.

For leveled compaction, it can improve read and write performance. As stated in the cassandra1.0 documentation, with leveled compaction, read performance has been improved by 400%.

The reason why Leveled compaction can improve read performance is that there are no duplicate records in each layer of leveled comapction, which ensures that 90% of reads can be done in one sstable. The worst-case scenario is that a record exists at each layer, but at this time the 10TB data is only 7 layers, just look up 7 SStable.

2 、 Compression

The compression of cassandra is introduced in http://www.datastax.com/dev/blog/whats-new-in-cassandra-1-0-compression. It is said here that with compression, its read performance has been improved by 25% Mel 35%.

The reason why Compression can improve the performance of reads is that after compression, each node can store more data. At the same time, Cassandra can quickly locate the location of the records in SStable index, and then decompress these records for operation. In other words, compression improves the speed of reading in two ways:

Allow more data in memory for data that is no longer in memory, but is frequently accessed, can also be accessed faster through SStable index.

How to improve the performance of cassandra read Storage

3. Adjust the values of key cache and row cache

Key cache: the location where the record is kept in memory. When the column of a row is very large, it is not appropriate to put the whole row in memory, so just save the location of the key, that is, the location of the row. This allows the program to quickly navigate to the row and operate. For systems with a large number of operations on row, there is a great improvement. The default is 200000. You can use nodetool cfstats or time jconsole to check its hit rate.

Row cache:row cache keeps the contents of the entire row in memory. It is appropriate for a small number of hot data to ask rhetorical questions frequently, or to return the entire columns. When using row cache, pay attention to its impact on memory.

If key cache is hit, it will reduce the number of queries once. If Row cache hits, reduce the number of queries twice. For systems where the type of column is picture, of course, each row is very large, so you can't rely on row cache to improve performance. But we can increase the key cache, or even set it to the keys of all row. This ensures that all read operations can be hit in key cache.

4. Set the size of JVM heap

In cassandra 1. 0, key cache is saved in JVM heap, while Row cache is saved in computer memory. If you want to improve the hit rate of row cache, you should pay attention to the setting of JVM heap size. Not only to ensure that the JVM heap can accommodate the use of menber table, key cache and other probably 1GB, but also to prevent the JVM heap from being too large, affecting the hit of row cache in the computer.

Thank you for reading! This is the end of this article on "how to improve the performance of cassandra read and storage". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report