Softwr

Databases · head to head

Memcached vs PgBouncer

M

Memcached

Databases

Distributed memory object caching system

From
Free
Free plan
Yes
PgBouncer logo

PgBouncer

Databases

Lightweight open-source connection pooler for PostgreSQL

From
Free
Free plan
Yes

The short version

  • PgBouncer is an open-source connection pooler.
  • Both are free.
  • Only Memcached lists client-side sharding; only PgBouncer lists session pooling.
  • Where Memcached falls short: no persistence at all: restart a node and its cache is gone, which every design must assume.
  • Where PgBouncer falls short: works with PostgreSQL only; it cannot pool connections for other database engines.

How do Memcached and PgBouncer differ?

Memcached and PgBouncer differ on pricing model and platforms. Only the attributes on which Memcached and PgBouncer actually diverge.

Attributes where Memcached and PgBouncer differ
AttributeMemcachedPgBouncer
Pricing modelOpen source, no licence fee; managed cloud billed separatelyOpen-source
PlatformsLinux, macOS, Windows, Self-hostedLinux, macOS, Windows

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

Not yet recorded: founded for PgBouncer.

Which features does each one have?

They share no listed features; 4 appear only for Memcached and 9 only for PgBouncer. 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 PgBouncer

  • Session pooling
  • Transaction pooling
  • Statement pooling
  • Low memory use per connection
  • Online reconfiguration of most settings
  • Online restart and upgrade without dropping clients
  • Backends on different hosts
  • TLS support via OpenSSL

What is each one used for?

Memcached is most often brought in for caching expensive database query results to cut load; PgBouncer for reducing open connections to a busy PostgreSQL server. The jobs each tool is most often brought in to do.

Memcached

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

PgBouncer

  • Reducing open connections to a busy PostgreSQL servernot Memcached
  • Pooling connections from serverless or short-lived application processesnot Memcached
  • Fronting databases spread across several hostsnot Memcached
  • Rolling upgrades without dropping client connectionsnot Memcached

Where do Memcached and PgBouncer fall short?

Memcached's most cited limit: no persistence at all: restart a node and its cache is gone, which every design must assume. PgBouncer's: works with PostgreSQL only; it cannot pool connections for other database engines. 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

PgBouncer

  • Works with PostgreSQL only; it cannot pool connections for other database engines
  • Transaction pooling disables session features such as LISTEN, SET/RESET and session-level advisory locks
  • Windows support is limited to MinGW builds; Cygwin and Visual toolchains are not supported
  • Configured through files and an admin console, with no built-in graphical interface
  • Does not provide failover, replication management or read-replica load balancing

How much do Memcached and PgBouncer cost?

Memcached is free to use; PgBouncer is free to use. Plan by plan below, from each vendor's own pricing page.

Memcached

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

PgBouncer

Free

No published plan breakdown. See the PgBouncer review.

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 PgBouncer if

  • You need session pooling.
  • You want to start without paying.
  • You work on Linux, macOS, Windows.
  • You also want transaction pooling.

Questions people ask

Is Memcached or PgBouncer better?
It depends on the job. Memcached fits caching expensive database query results to cut load; PgBouncer fits reducing open connections to a busy PostgreSQL server. Memcached starts at Free and PgBouncer at Free.
Which is cheaper, Memcached or PgBouncer?
Memcached starts at Free and PgBouncer at Free.
Does Memcached or PgBouncer run on more platforms?
Memcached runs on Linux, macOS, Windows, Self-hosted. PgBouncer runs on Linux, macOS, Windows.
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 PgBouncer is typically brought in for.
What can Memcached do that PgBouncer cannot?
Memcached covers In-memory key-value cache, Multithreaded, Client-side sharding, Predictable memory use. PgBouncer covers Session pooling, Transaction pooling, Statement pooling, Low memory use per connection.

Answered from the vendors’ own pages

Memcached: Is Memcached free?

Yes, open source with no licence fee.

PgBouncer: What is PgBouncer used for?

PgBouncer is a lightweight connection pooler for PostgreSQL. It lets many client connections share fewer server connections, which lowers the load of holding many connections open.

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.

PgBouncer: What pooling modes does PgBouncer support?

It supports session, transaction and statement pooling. Session pooling supports all PostgreSQL features, while transaction and statement pooling restrict some session-based features.

Source
Memcached: Does Memcached persist data?

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

PgBouncer: Does PgBouncer run on Windows?

The project's build instructions support Windows only through MinGW. It states that Cygwin and Visual toolchains are not supported, and that LDAP is not supported on Windows.

Source
PgBouncer: What do I need to build PgBouncer from source?

The README lists a C11-capable compiler, Libevent 2.0 or newer, pkg-config and, for TLS, OpenSSL 1.0.1 or newer. Optional components include c-ares, LDAP libraries and PAM libraries.

Source
Share

Related pages

Other head to heads