Web WEB-11 · Nov 2026
Manuscript catalogue: MongoDB, Redis and Elasticsearch
PHP application managing a catalogue of about 200 library manuscripts in MongoDB, with a Redis cache whose gain I measured through load tests, and an Elasticsearch search engine.

AThe context
The catalogue of manuscripts from the heritage library of Clermont Auvergne Métropole is the basis for three parts: a CRUD on MongoDB, a Redis cache with a measurement of its effect, then keyword search with Elasticsearch. Everything runs in Docker: the application, the three databases and the measurement tools.
BWhat I did
- CRUD on MongoDB: paginated list with projection, detail page, add, edit and delete, handling malformed identifiers (404 rather than a 500 error)
- Cache-aside Redis cache: keys per page and per book with a time to live, invalidated at every add, edit or delete, and an X-Cache header showing whether the response came from the cache
- k6 load tests (up to 50 simultaneous users) with and without cache, curves in InfluxDB and Grafana
- Elasticsearch search: French analyser (elision, accents, stemming), title weighted twice as much as author, typo tolerance, batch indexing with the bulk API
- Two-step search: Elasticsearch returns the identifiers by relevance, MongoDB loads the books, then the list is put back in relevance order
CThe challenge
The cache clearly speeds up a single request (from 392 ms to 45 ms for page 7), but under 50 simultaneous users throughput only improves by 6% and p(95) by 24%. The measurements show the bottleneck is not MongoDB but the PHP container: slow shared volume, Twig templates recompiled on every request, connections reopened. Another limit I document: the Elasticsearch index is not updated automatically after a write to MongoDB, which raises the question of synchronisation between the two databases.
DIn pictures
