Facebook has announced a new significant version of Flashcache 3.0, a system for transparent caching of data on fast SSD-drives, designed in the form of a kernel module for Linux, using a framework Device Mapper (DM).
It supports both, reading from block device cashing and writing acceleration due to preliminary data storage on SSD-drive and further dumping of data on the disk. Project code is licensed under the GPLv2.
On the basis of the new Flashcache version Facebook has already deployed the system of mass data caching that covers thousands of servers. Compared with the previous release the transition to Flashcache 3.0 has allowed a 40 % reduction in the number of reads in HDD and a 75 % reduction in the intensity of the input / output during recording. With the use of a more sophisticated algorithm to decide on the placement of data in the cache, the efficiency of caching has been raised from 60 to 80 %. On average, 80% of all transactions are handled by the cache. At the same time the appearance of unclaimed data in the cache has been minimized and the transition to more even distribution of frequently updated data in the cache has been implemented. These changes reduce the load on SSD-drives during the writing of data and prolong their service life.
3 key improvements for Flashcache 3.0:
- Cache filling algorithm has been changed. This which will ensure a more even distribution of data. Analysis of the MySQL (InnoDB) servers load showed that the majority of write operations are concentrated in few disk regions, as well as that the read operation is also unevenly distributed across the disk. In this situation, the previously used linear mapping scheme of 2 MB blocks on the disk with 2MB cache blocks led to the fact that certain areas of SSD-drives were used too intensively, while others being idle. To solve the problem accidentally hashing method has been implemented instead of the linear circuit. Moreover, blocks sizes were changed, - block on the disk has been reduced to 256 KB, and the block in the cache increased to 16 MB. As a result, if earlier 80 % of all disk operations concentrated in 50 % of the cache, now 50 % of the cache covers 50 % of disk operations.
- The organization of the displacement of irrelevant data from the cache has been changed. Instead of the previously used FIFO algorithm, which implies the displacement of records by the time they were added, LRU algorithm was used, where records are displaced on the basis reference age. When using the FIFO it was not uncommon when the actively used unit that was in the cache in the first place was replaced with irrelevant data. Now, entries that have not been used for a while are displaced from the cache in the first instance, regardless of the order data was added to the cache. LRU-2Q implementation has been used, which implies on placing new records not to the very end of the removal queue, allowing you to save 25 % of old records and avoid crowding out old records as a result of any abnormal peak activity , such as when rebuilding or migrating the site.
- Increase the efficiency of dumping of data to disk during caching in posted write- mode (write-back). Earlier dumping to the disk was carried out by combination of portions of ready to write data in relation to segments of the cache and the activity of reading in them, resulting in spotty performance by parts of cache (some data is dumped periodically, as some might be held long enough to be dumped drive). Cleaning and dumping of data in the new version is separated from the caching for reading and is independently done with disregard to activity in the cache. This has smoothed the performance of write caching and allocated more space for read caching.