Use fuse to use memcached as a disk

Source: Internet
Author: User

[ArticleAuthor: Sun Li link: http://www.cnblogs.com/sunli/ updated by:]

With the prevalence of Web2.0, memcached is widely used. As a result, more and more products provide data access methods compatible with the memcached protocol. Our self-developed nosql also provides support for the memcached protocol. I 've been wondering if I can mount this nosql directly to a disk, which makes it easier to use in some scenarios. For example, CAT and VI can both be directly viewed and edited.

Google, there is a ready-made tool memcachefs. So I tested it and wrote an article to share it. Follow here to http://memcachefs.sourceforge.net/for installation and use.

 

 

#./Memcachefs 127.0.0.1: 11212./mnt

# Ls-LH./mnt

Total 0

-RW-1 Root 5 Jan 1 1970 AA

-RW-1 Root 5 Jan 1 1970 bb

You can use VI to edit memcached data. Then I tested and mounted the developed nosql (inetdb). It was also successful, but does not support the LS command to list the file list. This is because we did not implement traversal commands such as stats items.

I run a single-thread test using a PHP script:

  <?  PHP
$ Start = Microtime ( True );
For ( $ I = 0 ; $ I < 10000 ; $ I ++ ){
File_put_contents ( " Key _ " . $ I , " Abcdef " );

}
Echo Microtime ( True ) - $ Start ;
?>

It takes about 3.3 seconds to write a local disk mounted through memcached, and about 0.4 seconds to write it directly to the local disk.

Summary:

1. Through memcachefs, you can use the storage that supports the memcached protocol as a local file, provide transparent support, and provide a channel for commands that do not support the memcached protocol. Such as CAT and VI.

2. The memcached protocol can be used to mount to a local disk through memcachefs to implement applications in some special scenarios. For example, if the old system used file caching in the past, you can seamlessly switch to memcached without changingCode

3. Develop your own Distributed File System through the memcached protocol, mainly to store some small files. Because the file data is too large, it is best to remove the stats items and other traversal functions to improve performance.

4. Abnormal application scenarios. For example, attach a database or attach a non-storage device (some commands)

Note: The stability and performance of memcachefs are not tested. This article mainly provides an idea. Some convenient solutions may be provided in some cases.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.