Which is faster/better for caching, File System or Memcached?

后端 未结 7 1231
花落未央
花落未央 2021-02-01 16:54

I don\'t think it\'s clear to me yet, is it faster to read things from a file or from memcached? Why?

相关标签:
7条回答
  • 2021-02-01 17:39

    There are quite a few different aspects that might favour one or the other:

    • Do you need/want to share this data between multiple servers? The filesystem is local, memcached is accessed over a network.
    • How large are the items your caching? The filesystem is likely to be better for large objects.
    • How many memcached requests might be there per page? TCP connections and tear-downs might take up more time than a simple filesystem stat() on the local machine.

    I would suggest you look at your use case and do some profiling of both approaches. If you can get away with using the filesystem then I would. Adding in memcached adds in another layer of complexity and potential points of failure (memcached client/server).

    For what it's worth the other comments about disk vs memory performance might well be academic as if the filesystem data is being accessed regularly then it'll likely be sitting in OS or disk cache memory anyway.

    0 讨论(0)
提交回复
热议问题