Is it practical to use Mongo compiled memory in the memory cache?

How practical is it to use Mongo capped collections as a bad man memcache, assuming it will be stored in memory most of the time?

+6
source share
3 answers

You can definitely use limited collections for this purpose. But it is important to know the basic limitations.

  • Data expires depending on insertion order without expiration
  • Frequently accessed data can be erased from memory Columns
  • _id is not defined by default in Capped Collections, you will need to provide these indexes.
  • Objects cannot be resized to resize the object. For example, you can increase an existing integer, but you cannot add a field or change a string value in a record.
  • Limited collections cannot be delayed .

Because of # 1 and # 4 and # 5, you are definitely losing some of the core features of Memcache.

There is a long outstanding JIRA ticket for TTL-based private collections , which is probably exactly what you want.

Of course, the big question in this whole discussion is "where is the extra RAM." Many people who use MongoDB as their main store just drop Memcache. If you have a ton of extra memory, why not just use it instead of actual data instead of copies of that data?

+12
source

Yes. This is a perfectly acceptable use of the collection compiled by MongoDB. I assume that you will have many other reads besides writing, so make sure you also use the index.

MongoDB Capped Collections: Applications

+2
source

As Gates V.P. said, closed collections are convenient and easy to manage. However, you can also use collections without restriction if you:

  • You have a dedicated server for your "poor man."
  • there is a lot of data that cannot fit on the same server (or you want to query very quickly)
  • ok with TTL itself (just add one field)

The MongoDB cache (mmap for Unix-like systems) will provide an "unlimited" memcache, caching frequently used values. As the mango frequently asked questions page says:

Mongo's goal is to be an alternative to the ORM / memcached / mysql stack

+1
source

Source: https://habr.com/ru/post/898404/


All Articles