Softwr

Databases · head to head

Memcached vs MongoDB

M

Memcached

Databases

Distributed memory object caching system

From
Free
Free plan
Yes
MongoDB logo

MongoDB

Databases

The developer data platform

From
Free
Free plan
Yes

The short version

  • MongoDB is a general purpose, document-based, distributed database.
  • Memcached is free; MongoDB starts at $9/mo.
  • Only Memcached lists in-memory key-value cache; only MongoDB lists document model.
  • Where Memcached falls short: no persistence at all: restart a node and its cache is gone, which every design must assume.
  • Where MongoDB falls short: 16 MB maximum document size limits large single objects.

How do Memcached and MongoDB differ?

Memcached and MongoDB differ on platforms and year founded (2003 against 2007). Only the attributes on which Memcached and MongoDB actually diverge.

Attributes where Memcached and MongoDB differ
AttributeMemcachedMongoDB
PlatformsLinux, macOS, Windows, Self-hostedWeb, Self-hosted
Founded20032007

Identical on both: starting price (Free), free tier (Yes), category (Databases).

Not yet recorded: pricing model for MongoDB.

Which features does each one have?

They share no listed features; 4 appear only for Memcached and 20 only for MongoDB. Drawn from each product's published feature list. An absence here means we hold no record of it - not that the product lacks it.

Only in Memcached

  • In-memory key-value cache
  • Multithreaded
  • Client-side sharding
  • Predictable memory use

Only in MongoDB

  • Document model
  • Distributed architecture
  • ACID transactions
  • Real-time analytics
  • Full-text search
  • Time series data
  • Geospatial queries
  • Aggregation framework

What is each one used for?

Memcached is most often brought in for caching expensive database query results to cut load; MongoDB for mobile applications. The jobs each tool is most often brought in to do.

Memcached

  • Caching expensive database query results to cut loadnot MongoDB
  • Session storage where losing sessions on restart is acceptablenot MongoDB
  • Fronting an API whose responses are costly and change slowlynot MongoDB

MongoDB

  • Mobile applicationsnot Memcached
  • Content managementnot Memcached
  • Real-time analyticsnot Memcached
  • IoT applicationsnot Memcached
  • Gaming backendsnot Memcached

Where do Memcached and MongoDB fall short?

Memcached's most cited limit: no persistence at all: restart a node and its cache is gone, which every design must assume. MongoDB's: 16 MB maximum document size limits large single objects. Documented limitations, not opinions. Every one is a constraint you would hit in normal use.

Memcached

  • No persistence at all: restart a node and its cache is gone, which every design must assume
  • No replication or failover, so losing a node loses that share of the cache
  • Only simple key-value, with none of the lists, sorted sets or streams Redis offers
  • Values are capped at 1MB by default, which surprises teams caching large documents

MongoDB

  • 16 MB maximum document size limits large single objects
  • No native JOIN support for relational data operations
  • Higher memory usage due to storing field names with each document
  • Eventual consistency in distributed deployments can cause data stale reads

How much do Memcached and MongoDB cost?

Memcached is free to use; MongoDB has a free plan, with paid plans from $9/mo. Plan by plan below, from each vendor's own pricing page.

Memcached

Free
  • MemcachedFree
    • Full functionality
    • Self-hosted
    • No usage limits

MongoDB

Free
  • M0Free
    • 512 MB storage
    • Learning and exploration
  • M2$9/mo
    • 2 GB storage
    • Development and testing
  • M5$25/mo
    • 5 GB storage
  • M10+$56.94/mo
    • Dedicated clusters for production

Which should you pick?

Choose Memcached if

  • You need in-memory key-value cache.
  • You want to start without paying.
  • You work on Linux, macOS, Windows, Self-hosted.
  • You also want multithreaded.

Choose MongoDB if

  • You need document model.
  • You want to start without paying.
  • You work on Web, Self-hosted.
  • You also want distributed architecture.

Questions people ask

Is Memcached or MongoDB better?
It depends on the job. Memcached fits caching expensive database query results to cut load; MongoDB fits mobile applications. Memcached starts at Free and MongoDB at Free.
Which is cheaper, Memcached or MongoDB?
Memcached starts at Free and MongoDB at Free.
Does Memcached or MongoDB run on more platforms?
Memcached runs on Linux, macOS, Windows, Self-hosted. MongoDB runs on Web, Self-hosted.
Can I use Memcached for free?
Both have a free tier, so you can try either at no cost before committing.
What is Memcached best used for?
Memcached is most often used for caching expensive database query results to cut load, session storage where losing sessions on restart is acceptable, fronting an api whose responses are costly and change slowly. Of those, caching expensive database query results to cut load and session storage where losing sessions on restart is acceptable are not what MongoDB is typically brought in for.
What can Memcached do that MongoDB cannot?
Memcached covers In-memory key-value cache, Multithreaded, Client-side sharding, Predictable memory use. MongoDB covers Document model, Distributed architecture, ACID transactions, Real-time analytics.

Answered from the vendors’ own pages

Memcached: Is Memcached free?

Yes, open source with no licence fee.

MongoDB: Does MongoDB offer a free tier?

Yes. MongoDB Atlas offers an M0 free tier with 512 MB storage for learning and exploration, plus paid options starting at $9/month for M2 with 2 GB storage.

Source
Memcached: Memcached or Redis?

Memcached is a pure cache: simpler, multithreaded and very predictable. Redis adds persistence, replication and rich data structures, which is why it is the default choice unless you specifically want a cache and nothing more.

MongoDB: Can I self-host MongoDB?

Yes. You can run MongoDB Community Edition on your own servers, or use MongoDB Enterprise Advanced for self-managed production deployments with enterprise features.

Source
Memcached: Does Memcached persist data?

No. Everything is in memory and lost on restart, by design.

MongoDB: What is the maximum document size in MongoDB?

Documents are limited to 16 MB. For documents exceeding this limit, you can use MongoDB's GridFS API to store files larger than the maximum size.

Source
MongoDB: Does MongoDB support ACID transactions?

Yes. MongoDB supports ACID transactions within a single document by default, and multi-document ACID transactions are available for replica sets and sharded clusters in MongoDB 4.0+.

Source
Share

Related pages

Other head to heads