Skip to content

Why is it faster than direct communication? #36

@applejag

Description

@applejag

Hello! I was toying around with the pkg/mongoproxy package from this repo, and I was using the mongo plugin to just have my application act as a "middleware" towards the real MongoDB.

As an experiment, I wanted to benchmark it to see what kind of performance impact it has.

I don't know many MongoDB benchmarking tools, so I used https://github.com/johnlpage/POCDriver

git clone https://github.com/johnlpage/POCDriver
cd POCDriver
podman build . -t pocdriver

I then ran it with the following arguments:

podman run --rm -it \
    --network host \
    pocdriver \
    -k 20 -i 10 -u 10 -b 20 -e -d 300 \
    --host 'mongodb://localhost:27017/?retryWrites=false'

The MongoDB I was testing was just:

podman run --rm -it -p 27017:27017 mongo

I ran the test once by letting POCDriver talk directly to MongoDB, and then another time by talking to my Go application that was using the mongoproxy to proxy the requests to MongoDB.

Here's the results:

Operation direct via mongoproxy %
inserts 1,424 20,237 1,561.59%
keyqueries 1,640 6,984 425.85%
updates 2,322 21,209 913.39%

I enabled debug logging to make sure it's working as expected, and also tried creating some new mongoproxy plugins to further analyze that it is working as expected. I'm not 100% sure, but it seems to be.

Any idea of why this is?

I was expecting an overhead, but instead I got a 10x performance boost?

All services were running locally on my machine btw. I also tried running the mongoproxy inside a podman container too to see if that made a difference, but it didn't.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions