microcks icon indicating copy to clipboard operation
microcks copied to clipboard

Add caching layer to reduce MongoDB call volume in request handling

Open Apoorva64 opened this issue 10 months ago • 2 comments

Reason/Context

  • Using microcks to mock partner microservices during perf testing
flowchart LR
    K6[k6 Load Test]
    MS[Microservice Under Test]

    subgraph Microcks [Microcks]
        P1[Partner A - Mock]
        P2[Partner B - Mock]
        P3[Partner C - Mock]
    end

    K6 -->|HTTP Request| MS
    MS -->|Calls| P1
    MS -->|Calls| P2
    MS -->|Calls| P3

Description

Microcks currently makes direct MongoDB queries for each incoming mock request — even when handling repeated or identical requests. This results in increased latency and higher DB load, especially under heavy usage.

Implementation ideas

Introducing a caching layer (e.g. in-memory/Redis) could significantly reduce repetitive DB operations and improve performance.

Apoorva64 avatar Jun 09 '25 08:06 Apoorva64

Hi @Apoorva64

This is an interesting enhancement we have had in mind for a long time but didn't have the necessary background to trigger its implementation.

Before doing performance optimizations, it's good to know the limits of the actual system! It could be nice to use elements from https://microcks.io/documentation/explanations/monitoring/ and share your observations here.

This results in increased latency and higher DB load, especially under heavy usage.

  • Could you share some figures so that we have context on your use-cases?
  • Have you tried setting up the performance tuning recommendations at the MongoDB level (see https://github.com/microcks/community/tree/main/tuning/mongodb-generic)?
  • Did it bring some improvements as expected?
  • Have you tried horizontal scaling?
  • Can you explain why you think limitations are on the database?

And as you have submitted a 1st PR: what are the observed benefits? What is the impact on the memory consumption?

Here again, please reuse elements from our benchmark suite to explain the limits and benefits you foresee.

lbroudoux avatar Jun 10 '25 08:06 lbroudoux

Hey @Apoorva64 any hints on above questions?

lbroudoux avatar Jun 11 '25 19:06 lbroudoux

This issue has been automatically marked as stale because it has not had recent activity :sleeping:

It will be closed in 30 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. Microcks is a Cloud Native Computing Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience :heart:

github-actions[bot] avatar Jul 12 '25 00:07 github-actions[bot]