Are there any advantages of using memcached locally over using a mounted tmpfs?
Maybe, when the memory-caching system resides on the same host, it's better to use file hierarchy on tmpfs which gives the ability to use standard system API and file-handling tools?
-
My gut suggests that memcached would be noticeably more efficient as the filesystem will be maintaining ownership and permissions flags for each object on each create, and checking them on every file open to read. Also, you are likely to find that memcached's structures are better indexed than the tmpfs filesystem which IIRC uses an unordered linear list for directory listings so has to scan (on average) half a directory listing to find an object instead of being able to do a more efficient divide-and-conquer search.
I'm assuming in the above that you are meaning storing many cached results, most of which are relatively small in size, each in their own file on the RAM based filesystem. If you are meaning keeping many results in a single file on tmpfs then a memory based sqlite database would be more efficient and saves you reinventing the wheel in terms of index management and efficient searching.
Of course, as you say, being able to manipulate your cache with any tool that understands filesystems may be an advantage strong enough to make most efficiency arguments moot points.
Which technique is better will depend greatly on what you are using it for of course, so it might be a good idea to add more detail about your project to the question. As a code/data optimisation query, this might be a questions for StackOverflow rather than ServerFault (a server admin is not likely to be in a position of choosing a project's cache storage option, unless the programmers have implemented more than one to choose from) - you might find people over there who have benchmarked memcached/sqlite/tmpfs/custom_solution for their project and can give you some useful comparative figures.
o_O Tync : Your guts are genius! Mine were not going to think in that direction :) Thank you! My question was about a general situation, there's no need to invite StackOverflow people to the discussion :)From David Spillett
0 comments:
Post a Comment